home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / unix / vim-6.2.tar.bz2 / vim-6.2.tar / vim62 / runtime / syntax / lex.vim < prev    next >
Encoding:
Text File  |  2002-11-18  |  4.3 KB  |  97 lines

  1. " Vim syntax file
  2. " Language:    Lex
  3. " Maintainer:    Dr. Charles E. Campbell, Jr. <Charles.E.Campbell.1@nasa.gov>
  4. " Last Change:    Nov 18, 2002
  5. " Version:    2
  6. " URL:    http://www.erols.com/astronaut/vim/index.html#vimlinks_syntax
  7. "
  8. " Option:
  9. "   lex_uses_cpp : if this variable exists, then C++ is loaded rather than C
  10.  
  11. " For version 5.x: Clear all syntax items
  12. " For version 6.x: Quit when a syntax file was already loaded
  13. if version < 600
  14.   syntax clear
  15. elseif exists("b:current_syntax")
  16.   finish
  17. endif
  18.  
  19. " Read the C syntax to start with
  20. if version >= 600
  21.   if exists("lex_uses_cpp")
  22.     runtime! syntax/cpp.vim
  23.   else
  24.     runtime! syntax/c.vim
  25.   endif
  26.   unlet b:current_syntax
  27. else
  28.   if exists("lex_uses_cpp")
  29.     so <sfile>:p:h/cpp.vim
  30.   else
  31.     so <sfile>:p:h/c.vim
  32.   endif
  33. endif
  34.  
  35. " --- Lex stuff ---
  36.  
  37. "I'd prefer to use lex.* , but it doesn't handle forward definitions yet
  38. syn cluster lexListGroup        contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatString,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,lexPatCode,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
  39. syn cluster lexListPatCodeGroup    contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
  40.  
  41. " Abbreviations Section
  42. syn region lexAbbrvBlock    start="^\([a-zA-Z_]\+\t\|%{\)" end="^%%$"me=e-2    skipnl    nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment
  43. syn match  lexAbbrv        "^\I\i*\s"me=e-1            skipwhite    contained nextgroup=lexAbbrvRegExp
  44. syn match  lexAbbrv        "^%[sx]"                    contained
  45. syn match  lexAbbrvRegExp    "\s\S.*$"lc=1                contained nextgroup=lexAbbrv,lexInclude
  46. syn region lexInclude    matchgroup=lexSep    start="^%{" end="%}"    contained    contains=ALLBUT,@lexListGroup
  47. syn region lexAbbrvComment    start="^\s\+/\*"    end="\*/"
  48.  
  49. "%% : Patterns {Actions}
  50. syn region lexPatBlock    matchgroup=Todo    start="^%%$" matchgroup=Todo end="^%%$"    skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment
  51. syn region lexPat        start=+\S+ skip="\\\\\|\\."    end="\s"me=e-1    contained nextgroup=lexMorePat,lexPatSep contains=lexPatString,lexSlashQuote,lexBrace
  52. syn region lexBrace    start="\[" skip=+\\\\\|\\+        end="]"        contained
  53. syn region lexPatString    matchgroup=String start=+"+    skip=+\\\\\|\\"+    matchgroup=String end=+"+    contained
  54. syn match  lexPatTag    "^<\I\i*\(,\I\i*\)*>*"            contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
  55. syn match  lexPatTag    +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+        contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
  56. syn region lexPatComment    start="^\s*/\*" end="\*/"        skipnl    contained contains=cTodo nextgroup=lexPatComment,lexPat,lexPatString,lexPatTag
  57. syn match  lexPatCodeLine    ".*$"                    contained contains=ALLBUT,@lexListGroup
  58. syn match  lexMorePat    "\s*|\s*$"            skipnl    contained nextgroup=lexPat,lexPatTag,lexPatComment
  59. syn match  lexPatSep    "\s\+"                    contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
  60. syn match  lexSlashQuote    +\(\\\\\)*\\"+                contained
  61. syn region lexPatCode matchgroup=Delimiter start="{" matchgroup=Delimiter end="}"    skipnl contained contains=ALLBUT,@lexListPatCodeGroup
  62.  
  63. syn keyword lexCFunctions    BEGIN    input    unput    woutput    yyleng    yylook    yytext
  64. syn keyword lexCFunctions    ECHO    output    winput    wunput    yyless    yymore    yywrap
  65.  
  66. " <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups
  67. syn cluster cParenGroup    add=lex.*
  68. syn cluster cDefineGroup    add=lex.*
  69. syn cluster cPreProcGroup    add=lex.*
  70. syn cluster cMultiGroup    add=lex.*
  71.  
  72. " Synchronization
  73. syn sync clear
  74. syn sync minlines=300
  75. syn sync match lexSyncPat    grouphere  lexPatBlock    "^%[a-zA-Z]"
  76. syn sync match lexSyncPat    groupthere lexPatBlock    "^<$"
  77. syn sync match lexSyncPat    groupthere lexPatBlock    "^%%$"
  78.  
  79. " The default highlighting.
  80. hi def link lexSlashQuote    lexPat
  81. hi def link lexBrace    lexPat
  82. hi def link lexAbbrvComment    lexPatComment
  83.  
  84. hi def link lexAbbrv    SpecialChar
  85. hi def link lexAbbrvRegExp    Macro
  86. hi def link lexCFunctions    Function
  87. hi def link lexMorePat    SpecialChar
  88. hi def link lexPat        Function
  89. hi def link lexPatComment    Comment
  90. hi def link lexPatString    Function
  91. hi def link lexPatTag    Special
  92. hi def link lexSep        Delimiter
  93.  
  94. let b:current_syntax = "lex"
  95.  
  96. " vim:ts=10
  97.