Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Yacc |
| 3 | " Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> |
Bram Moolenaar | cafda4f | 2005-09-06 19:25:11 +0000 | [diff] [blame] | 4 | " Last Change: Sep 06, 2005 |
| 5 | " Version: 3 |
| 6 | " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7 | " |
| 8 | " Option: |
| 9 | " yacc_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("yacc_uses_cpp") |
| 22 | runtime! syntax/cpp.vim |
| 23 | else |
| 24 | runtime! syntax/c.vim |
| 25 | endif |
| 26 | elseif exists("yacc_uses_cpp") |
| 27 | so <sfile>:p:h/cpp.vim |
| 28 | else |
| 29 | so <sfile>:p:h/c.vim |
| 30 | endif |
| 31 | |
| 32 | " Clusters |
| 33 | syn cluster yaccActionGroup contains=yaccDelim,cInParen,cTodo,cIncluded,yaccDelim,yaccCurlyError,yaccUnionCurly,yaccUnion,cUserLabel,cOctalZero,cCppOut2,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCommentStartError,cParenError |
| 34 | syn cluster yaccUnionGroup contains=yaccKey,cComment,yaccCurly,cType,cStructure,cStorageClass,yaccUnionCurly |
| 35 | |
| 36 | " Yacc stuff |
| 37 | syn match yaccDelim "^\s*[:|;]" |
| 38 | syn match yaccOper "@\d\+" |
| 39 | |
| 40 | syn match yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>" |
| 41 | syn match yaccKey "\s%\(prec\|expect\)\>" |
| 42 | syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+" |
| 43 | syn keyword yaccKeyActn yyerrok yyclearin |
| 44 | |
| 45 | syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion |
| 46 | syn region yaccUnion contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup |
| 47 | syn region yaccUnionCurly contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup |
| 48 | syn match yaccBrkt contained "[<>]" |
| 49 | syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt |
| 50 | syn match yaccDefinition "^[A-Za-z][A-Za-z0-9_]*[ \t]*:" |
| 51 | |
| 52 | " special Yacc separators |
| 53 | syn match yaccSectionSep "^[ \t]*%%" |
| 54 | syn match yaccSep "^[ \t]*%{" |
| 55 | syn match yaccSep "^[ \t]*%}" |
| 56 | |
| 57 | " I'd really like to highlight just the outer {}. Any suggestions??? |
| 58 | syn match yaccCurlyError "[{}]" |
| 59 | syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup |
| 60 | |
| 61 | |
| 62 | " Define the default highlighting. |
| 63 | " For version 5.7 and earlier: only when not done already |
| 64 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 65 | if version >= 508 || !exists("did_yacc_syn_inits") |
| 66 | if version < 508 |
| 67 | let did_yacchdl_syn_inits = 1 |
| 68 | command -nargs=+ HiLink hi link <args> |
| 69 | else |
| 70 | command -nargs=+ HiLink hi def link <args> |
| 71 | endif |
| 72 | |
| 73 | " Internal yacc highlighting links |
| 74 | HiLink yaccBrkt yaccStmt |
| 75 | HiLink yaccKey yaccStmt |
| 76 | HiLink yaccOper yaccStmt |
| 77 | HiLink yaccUnionStart yaccKey |
| 78 | |
| 79 | " External yacc highlighting links |
| 80 | HiLink yaccCurly Delimiter |
| 81 | HiLink yaccCurlyError Error |
| 82 | HiLink yaccDefinition Function |
| 83 | HiLink yaccDelim Function |
| 84 | HiLink yaccKeyActn Special |
| 85 | HiLink yaccSectionSep Todo |
| 86 | HiLink yaccSep Delimiter |
| 87 | HiLink yaccStmt Statement |
| 88 | HiLink yaccType Type |
| 89 | |
| 90 | " since Bram doesn't like my Delimiter :| |
| 91 | HiLink Delimiter Type |
| 92 | |
| 93 | delcommand HiLink |
| 94 | endif |
| 95 | |
| 96 | let b:current_syntax = "yacc" |
| 97 | |
| 98 | " vim: ts=15 |