Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: AYacc |
| 3 | " Maintainer: Mathieu Clabaut <mathieu.clabaut@free.fr> |
Bram Moolenaar | b6b046b | 2011-12-30 13:11:27 +0100 | [diff] [blame] | 4 | " LastChange: 2011 Dec 25 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5 | " Original: Yacc, maintained by Dr. Charles E. Campbell, Jr. |
| 6 | " Comment: Replaced sourcing c.vim file by ada.vim and rename yacc* |
| 7 | " in ayacc* |
| 8 | |
| 9 | " For version 5.x: Clear all syntax items |
| 10 | " For version 6.x: Quit when a syntax file was already loaded |
| 11 | if version < 600 |
| 12 | syntax clear |
| 13 | elseif exists("b:current_syntax") |
| 14 | finish |
| 15 | endif |
| 16 | |
| 17 | " Read the Ada syntax to start with |
| 18 | if version < 600 |
| 19 | so <sfile>:p:h/ada.vim |
| 20 | else |
| 21 | runtime! syntax/ada.vim |
| 22 | unlet b:current_syntax |
| 23 | endif |
| 24 | |
Bram Moolenaar | b6b046b | 2011-12-30 13:11:27 +0100 | [diff] [blame] | 25 | let s:cpo_save = &cpo |
| 26 | set cpo&vim |
| 27 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 28 | " Clusters |
| 29 | syn cluster ayaccActionGroup contains=ayaccDelim,cInParen,cTodo,cIncluded,ayaccDelim,ayaccCurlyError,ayaccUnionCurly,ayaccUnion,cUserLabel,cOctalZero,cCppOut2,cCppSkip,cErrInBracket,cErrInParen,cOctalError |
| 30 | syn cluster ayaccUnionGroup contains=ayaccKey,cComment,ayaccCurly,cType,cStructure,cStorageClass,ayaccUnionCurly |
| 31 | |
| 32 | " Yacc stuff |
| 33 | syn match ayaccDelim "^[ \t]*[:|;]" |
| 34 | syn match ayaccOper "@\d\+" |
| 35 | |
| 36 | syn match ayaccKey "^[ \t]*%\(token\|type\|left\|right\|start\|ident\)\>" |
| 37 | syn match ayaccKey "[ \t]%\(prec\|expect\|nonassoc\)\>" |
| 38 | syn match ayaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+" |
| 39 | syn keyword ayaccKeyActn yyerrok yyclearin |
| 40 | |
| 41 | syn match ayaccUnionStart "^%union" skipwhite skipnl nextgroup=ayaccUnion |
| 42 | syn region ayaccUnion contained matchgroup=ayaccCurly start="{" matchgroup=ayaccCurly end="}" contains=@ayaccUnionGroup |
| 43 | syn region ayaccUnionCurly contained matchgroup=ayaccCurly start="{" matchgroup=ayaccCurly end="}" contains=@ayaccUnionGroup |
| 44 | syn match ayaccBrkt contained "[<>]" |
| 45 | syn match ayaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=ayaccBrkt |
| 46 | syn match ayaccDefinition "^[A-Za-z][A-Za-z0-9_]*[ \t]*:" |
| 47 | |
| 48 | " special Yacc separators |
| 49 | syn match ayaccSectionSep "^[ \t]*%%" |
| 50 | syn match ayaccSep "^[ \t]*%{" |
| 51 | syn match ayaccSep "^[ \t]*%}" |
| 52 | |
| 53 | " I'd really like to highlight just the outer {}. Any suggestions??? |
| 54 | syn match ayaccCurlyError "[{}]" |
| 55 | syn region ayaccAction matchgroup=ayaccCurly start="{" end="}" contains=ALLBUT,@ayaccActionGroup |
| 56 | |
| 57 | if version >= 508 || !exists("did_ayacc_syntax_inits") |
| 58 | if version < 508 |
| 59 | let did_ayacc_syntax_inits = 1 |
| 60 | command -nargs=+ HiLink hi link <args> |
| 61 | else |
| 62 | command -nargs=+ HiLink hi def link <args> |
| 63 | endif |
| 64 | |
| 65 | " Internal ayacc highlighting links |
| 66 | HiLink ayaccBrkt ayaccStmt |
| 67 | HiLink ayaccKey ayaccStmt |
| 68 | HiLink ayaccOper ayaccStmt |
| 69 | HiLink ayaccUnionStart ayaccKey |
| 70 | |
| 71 | " External ayacc highlighting links |
| 72 | HiLink ayaccCurly Delimiter |
| 73 | HiLink ayaccCurlyError Error |
| 74 | HiLink ayaccDefinition Function |
| 75 | HiLink ayaccDelim Function |
| 76 | HiLink ayaccKeyActn Special |
| 77 | HiLink ayaccSectionSep Todo |
| 78 | HiLink ayaccSep Delimiter |
| 79 | HiLink ayaccStmt Statement |
| 80 | HiLink ayaccType Type |
| 81 | |
| 82 | " since Bram doesn't like my Delimiter :| |
| 83 | HiLink Delimiter Type |
| 84 | delcommand HiLink |
| 85 | endif |
| 86 | |
| 87 | let b:current_syntax = "ayacc" |
| 88 | |
Bram Moolenaar | b6b046b | 2011-12-30 13:11:27 +0100 | [diff] [blame] | 89 | let &cpo = s:cpo_save |
| 90 | unlet s:cpo_save |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 91 | " vim: ts=15 |