~ubuntu-branches/ubuntu/maverick/vim/maverick

« back to all changes in this revision

Viewing changes to runtime/syntax/yacc.vim

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-05-04 11:13:42 UTC
  • mfrom: (1.1.8 upstream) (0.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090504111342-60miqybsixdpc345
Tags: 2:7.2.148-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/runtime/vimrc: "syntax on" is a sane default for non-tiny vim.
  - runtime/syntax/debcontrol.vim:
    + Add "metapackages" to the list of valid sections.
  - runtime/syntax/grub.vim:
    + Add Ubuntu-specific 'quiet' keyword.
  - Drop vim-lesstif package and lesstif2-dev build-dependency.
  - Enable Python interpreter on basic builds.
  - Disable autoindent, line-wrapping, and backup files by default.
* Dropped changes, merged in Debian:
  - Add jaunty, karmic to the list of valid suites.
  - runtime/syntax/debsources.vim:
    + Add "jaunty" to debsourcesDistrKeyword
  - Create a .pot file for translations.
* Drop gutsy from the list of valid distro series, it's been EOLed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
" Vim syntax file
2
2
" Language:     Yacc
3
3
" Maintainer:   Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4
 
" Last Change:  Jan 09, 2008
5
 
" Version:      5
 
4
" Last Change:  Oct 21, 2008
 
5
" Version:      7
6
6
" URL:  http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
7
7
"
8
8
" Options: {{{1
9
9
"   g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C
10
 
"   g:yacc_minlines : see :help :he syn-sync-minlines -- default 50
11
 
"   g:yacc_maxlines : see :help :he syn-sync-maxlines -- default 200
12
10
 
13
11
" ---------------------------------------------------------------------
14
 
" For version 5.x: Clear all syntax items {{{1
15
 
" For version 6.x: Quit when a syntax file was already loaded
 
12
" this version of syntax/yacc.vim requires 6.0 or later
16
13
if version < 600
17
 
  syntax clear
18
 
elseif exists("b:current_syntax")
19
 
  finish
 
14
 finish
 
15
endif
 
16
if exists("b:current_syntax")
 
17
 syntax clear
 
18
endif
 
19
 
 
20
" ---------------------------------------------------------------------
 
21
"  Folding Support {{{1
 
22
if has("folding")
 
23
 com! -nargs=+ HiFold   <args> fold
 
24
else
 
25
 com! -nargs=+ HiFold   <args>
20
26
endif
21
27
 
22
28
" ---------------------------------------------------------------------
23
29
" Read the C syntax to start with {{{1
24
 
if version >= 600
25
 
  if exists("g:yacc_uses_cpp")
26
 
    runtime! syntax/cpp.vim
27
 
  else
28
 
    runtime! syntax/c.vim
29
 
  endif
30
 
elseif exists("g:yacc_uses_cpp")
31
 
  so <sfile>:p:h/cpp.vim
 
30
if exists("g:yacc_uses_cpp")
 
31
 syn include @yaccCode  <sfile>:p:h/cpp.vim
32
32
else
33
 
  so <sfile>:p:h/c.vim
 
33
 syn include @yaccCode  <sfile>:p:h/c.vim
34
34
endif
35
35
 
36
36
" ---------------------------------------------------------------------
37
 
" Clusters {{{1
38
 
syn cluster     yaccActionGroup contains=yaccDelim,cInParen,cTodo,cIncluded,yaccDelim,yaccCurlyError,yaccUnionCurly,yaccUnion,cUserLabel,cOctalZero,cCppOut2,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCommentStartError,cParenError
39
 
syn cluster     yaccUnionGroup  contains=yaccKey,cComment,yaccCurly,cType,cStructure,cStorageClass,yaccUnionCurly
40
 
 
41
 
" ---------------------------------------------------------------------
42
 
" Yacc stuff {{{1
43
 
syn match       yaccDelim       "^\s*[:|;]"
44
 
syn match       yaccOper        "@\d\+"
45
 
 
46
 
syn match       yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>"
47
 
syn match       yaccKey "\s%\(prec\|expect\)\>"
48
 
syn match       yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+"
49
 
syn keyword     yaccKeyActn     yyerrok yyclearin
50
 
 
51
 
syn match       yaccUnionStart  "^%union"       skipwhite skipnl nextgroup=yaccUnion
52
 
syn region      yaccUnion       contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}"   contains=@yaccUnionGroup
53
 
syn region      yaccUnionCurly  contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
54
 
syn match       yaccBrkt        contained "[<>]"
55
 
syn match       yaccType        "<[a-zA-Z_][a-zA-Z0-9_]*>"      contains=yaccBrkt
56
 
syn match       yaccDefinition  "^[A-Za-z][A-Za-z0-9_]*\_s*:"
57
 
 
58
 
" ---------------------------------------------------------------------
59
 
" special Yacc separators {{{1
60
 
syn match       yaccSectionSep  "^[ \t]*%%"
61
 
syn match       yaccSep "^[ \t]*%{"
62
 
syn match       yaccSep "^[ \t]*%}"
 
37
"  Yacc Clusters: {{{1
 
38
syn cluster yaccInitCluster     contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment
 
39
syn cluster yaccRulesCluster    contains=yaccNonterminal,yaccString
 
40
 
 
41
" ---------------------------------------------------------------------
 
42
"  Yacc Sections: {{{1
 
43
HiFold syn      region  yaccInit        start='.'ms=s-1,rs=s-1  matchgroup=yaccSectionSep       end='^%%$'me=e-2,re=e-2 contains=@yaccInitCluster       nextgroup=yaccRules     skipwhite skipempty contained
 
44
HiFold syn      region  yaccInit2      start='\%^.'ms=s-1,rs=s-1        matchgroup=yaccSectionSep       end='^%%$'me=e-2,re=e-2 contains=@yaccInitCluster       nextgroup=yaccRules     skipwhite skipempty
 
45
HiFold syn      region  yaccHeader2     matchgroup=yaccSep      start="^\s*\zs%{"       end="^\s*%}"            contains=@yaccCode      nextgroup=yaccInit      skipwhite skipempty contained
 
46
HiFold syn      region  yaccHeader      matchgroup=yaccSep      start="^\s*\zs%{"       end="^\s*%}"            contains=@yaccCode      nextgroup=yaccInit      skipwhite skipempty
 
47
HiFold syn      region  yaccRules       matchgroup=yaccSectionSep       start='^%%$'            end='^%%$'me=e-2,re=e-2 contains=@yaccRulesCluster      nextgroup=yaccEndCode   skipwhite skipempty contained
 
48
HiFold syn      region  yaccEndCode     matchgroup=yaccSectionSep       start='^%%$'            end='\%$'               contains=@yaccCode      contained
 
49
 
 
50
" ---------------------------------------------------------------------
 
51
" Yacc Commands: {{{1
 
52
syn     match   yaccDelim       "[:|]"  contained
 
53
syn     match   yaccOper        "@\d\+" contained
 
54
 
 
55
syn     match   yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>"   contained
 
56
syn     match   yaccKey "\s%\(prec\|expect\)\>" contained
 
57
syn     match   yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+"     contained
 
58
syn     keyword yaccKeyActn     yyerrok yyclearin       contained
 
59
 
 
60
syn     match   yaccUnionStart  "^%union"       skipwhite skipnl nextgroup=yaccUnion    contained
 
61
HiFold syn      region  yaccUnion       matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode  contained
 
62
syn     match   yaccBrkt        "[<>]"  contained
 
63
syn     match   yaccType        "<[a-zA-Z_][a-zA-Z0-9_]*>"      contains=yaccBrkt       contained
 
64
 
 
65
HiFold syn      region  yaccNonterminal start="^\s*\a\w*\ze\_s*\(/\*\_.\{-}\*/\)\=\_s*:"        matchgroup=yaccDelim end=";"    matchgroup=yaccSectionSep end='^%%$'me=e-2,re=e-2 contains=yaccAction,yaccDelim,yaccString,yaccComment  contained
 
66
syn     region  yaccComment     start="/\*"     end="\*/"
 
67
syn     match   yaccString      "'[^']*'"       contained
 
68
 
63
69
 
64
70
" ---------------------------------------------------------------------
65
71
" I'd really like to highlight just the outer {}.  Any suggestions??? {{{1
66
 
syn match       yaccCurlyError  "[{}]"
67
 
syn region      yaccAction      matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup
 
72
syn     match   yaccCurlyError  "[{}]"
 
73
HiFold syn      region  yaccAction      matchgroup=yaccCurly start="{" end="}" contains=@yaccCode       contained
68
74
 
69
75
" ---------------------------------------------------------------------
70
76
" Yacc synchronization: {{{1
71
 
if exists("g:yacc_maxlines")
72
 
 exe "syn sync maxlines=".g:yacc_maxlines
73
 
else
74
 
 syn sync maxlines=200
75
 
endif
76
 
if exists("g:yacc_minlines")
77
 
 exe "syn sync minlines=".g:yacc_minlines
78
 
else
79
 
 syn sync minlines=50
80
 
endif
 
77
syn sync fromstart
81
78
 
82
79
" ---------------------------------------------------------------------
83
80
" Define the default highlighting. {{{1
84
 
" For version 5.7 and earlier: only when not done already
85
 
" For version 5.8 and later: only when an item doesn't have highlighting yet
86
 
if version >= 508 || !exists("did_yacc_syn_inits")
87
 
  if version < 508
88
 
    let did_yacchdl_syn_inits = 1
89
 
    command -nargs=+ HiLink hi link <args>
90
 
  else
91
 
    command -nargs=+ HiLink hi def link <args>
92
 
  endif
 
81
if !exists("did_yacc_syn_inits")
 
82
  command -nargs=+ HiLink hi def link <args>
93
83
 
94
84
  " Internal yacc highlighting links {{{2
95
85
  HiLink yaccBrkt       yaccStmt
98
88
  HiLink yaccUnionStart yaccKey
99
89
 
100
90
  " External yacc highlighting links {{{2
 
91
  HiLink yaccComment    Comment
101
92
  HiLink yaccCurly      Delimiter
102
93
  HiLink yaccCurlyError Error
103
 
  HiLink yaccDefinition Function
104
 
  HiLink yaccDelim      Function
 
94
  HiLink yaccNonterminal        Function
 
95
  HiLink yaccDelim      Delimiter
105
96
  HiLink yaccKeyActn    Special
106
97
  HiLink yaccSectionSep Todo
107
98
  HiLink yaccSep        Delimiter
 
99
  HiLink yaccString     String
108
100
  HiLink yaccStmt       Statement
109
101
  HiLink yaccType       Type
110
102
 
113
105
 
114
106
  delcommand HiLink
115
107
endif
 
108
 
 
109
" ---------------------------------------------------------------------
 
110
"  Cleanup: {{{1
 
111
delcommand HiFold
116
112
let b:current_syntax = "yacc"
117
113
 
118
114
" ---------------------------------------------------------------------