Skip to content

Commit

Permalink
[WIP] Add SRFI-7 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mnacamura committed Jul 4, 2021
1 parent bed74a9 commit 9beb099
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions syntax/srfi.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,53 @@ if !exists('b:did_r7rs_syntax')
finish
endif

" Options {{{1

" If (b|g):r7rs_strict is true, the following options are set to obey strict R7RS.
if r7rs#GetOption('strict', 0)
let s:brackets_as_parens = 0
let s:braces_as_parens = 0
else
let s:more_parens = r7rs#GetOption('more_parens', ']')
let s:brackets_as_parens = match(s:more_parens, '[\[\]]') > -1
let s:braces_as_parens = match(s:more_parens, '[{}]') > -1
unlet s:more_parens
endif

" }}}

" SRFI 2 {{{1
syn keyword r7rsSyntax and-let*

" SRFI-7 {{{1
syn region r7rsProgram matchgroup=r7rsDelimiter start=/(\ze[[:space:]\n]*program/ end=/)/ contains=r7rsError,@r7rsComments,r7rsProgramSyntax,r7rsProgramClause
syn keyword r7rsProgramSyntax contained program and or not
syn keyword r7rsProgramSyntaxA contained requires files code feature-cond
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/(\ze[[:space:]\n]*requires/ end=/)/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsCEFeatureId
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/(\ze[[:space:]\n]*files/ end=/)/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsString
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/(\ze[[:space:]\n]*code/ end=/)/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,@r7rsExpressions
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/(\ze[[:space:]\n]*feature-cond/ end=/)/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsProgramFCClause
syn region r7rsProgramFCClause matchgroup=r7rsDelimiter start=/(/ end=/)/ contained contains=r7rsError,@r7rsComments,@r7rsProgramFCRequirements,r7rsProgramClause
syn cluster r7rsProgramFCRequirements contains=r7rsCEFeatureId,r7rsProgramFCRequirementsAON,r7rsFCRequirementsElse
syn region r7rsProgramFCRequirementsAON matchgroup=r7rsDelimiter start=/(\ze[[:space:]\n]*\%(and\|or\|not\)/ end=/)/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntax,@r7rsProgramFCRequirements
syn keyword r7rsProgramFCRequirementsElse contained else
if s:brackets_as_parens
syn region r7rsProgram matchgroup=r7rsDelimiter start=/\[\ze[[:space:]\n]*program/ end=/\]/ contains=r7rsError,@r7rsComments,r7rsProgramSyntax,r7rsProgramClause
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/\[\ze[[:space:]\n]*requires/ end=/\]/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsCEFeatureId
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/\[\ze[[:space:]\n]*files/ end=/\]/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsString
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/\[\ze[[:space:]\n]*code/ end=/\]/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,@r7rsExpressions
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/\[\ze[[:space:]\n]*feature-cond/ end=/\]/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsProgramFCClause
syn region r7rsProgramFCClause matchgroup=r7rsDelimiter start=/\[/ end=/\]/ contained contains=r7rsError,@r7rsComments,@r7rsProgramFCRequirements,r7rsProgramClause
endif
if s:braces_as_parens
syn region r7rsProgram matchgroup=r7rsDelimiter start=/{\ze[[:space:]\n]*program/ end=/}/ contains=r7rsError,@r7rsComments,r7rsProgramSyntax,r7rsProgramClause
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/{\ze[[:space:]\n]*requires/ end=/}/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsCEFeatureId
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/{\ze[[:space:]\n]*files/ end=/}/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsString
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/{\ze[[:space:]\n]*code/ end=/}/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,@r7rsExpressions
syn region r7rsProgramClause matchgroup=r7rsDelimiter start=/{\ze[[:space:]\n]*feature-cond/ end=/}/ contained contains=r7rsError,@r7rsComments,r7rsProgramSyntaxA,r7rsProgramFCClause
syn region r7rsProgramFCClause matchgroup=r7rsDelimiter start=/{/ end=/}/ contained contains=r7rsError,@r7rsComments,@r7rsProgramFCRequirements,r7rsProgramClause
endif

" SRFI 8 {{{1
syn keyword r7rsSyntax receive

Expand Down Expand Up @@ -95,6 +139,9 @@ syn keyword r7rsFunction string-replicate string-segment string-split
" Highlights {{{1

hi def link r7rsShebang r7rsComment
hi def link r7rsProgramSyntax r7rsLibrarySyntax
hi def link r7rsProgramSyntaxA r7rsLibrarySyntaxA
hi def link r7rsProgramFCRequirementsElse r7rsProgramSyntaxA

" }}}

Expand Down

0 comments on commit 9beb099

Please sign in to comment.