Forum: CFEngine Help
Subject: Re: CFEngine Help: Thoughts about some cfengine design decisions?
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,24294,24415#msg-24415
Jesse Becker Wrote:
-------------------------------------------------------
> Would it be possible to publish the regexes uses
> for syntax highlighting? (Yes, I understand that it will
> change over time).
I'm working on expanding the vim syntax highlighter, and have this chunk of
stuff which includes some comments to pull the list of keywords and whatnot
from the current source code.
syn keyword cf3BundleTypes common agent server monitor executor knowledge
runagent reporter keygenerator hub contained
syn keyword cf3BodyTypes action classes contain copy_from delete
delete_select depth_search edit_defaults file_select link_from perms
process_count process_select rename contained
syn match cf3Bundle /^\s*bundle\s.*$/ contains=cf3BundleTypes
syn match cf3Body /^\s*body\s.*$/ contains=Cf3BodyTypes
syn match cf3Comment /#.*/ contains=TODO
syn match cf3Identifier /=>/
syn region cf3Promise start=/\s*"/ end=/;/ skip=/"[^"]*;[^"*]"/
contains=cf3LHS,cf3String,cf3Type
" For actions e.g. reports:, commands:
" list generated based upon TYPESEQUENCE array in src/agent.c
syn match cf3Action
/^\s*\zs\(classes\|commands\|databases\|environments\|files\|interfaces\|methods\|outputs\|packages\|processes\|reports\|services\|storage\|vars\)\ze\:/
" list genreated based upon EDITLINETYPESEQUENCE array in src/files_editline.c
syn match cf3FileAction
/^\s*\zs\(vars\|classes\|delete_lines\|field_edits\|insert_lines\|replace_patterns\|reports\)\ze\:/
" class selectors
syn match cf3Class /^\s*\zs{}]\+\ze::/
" Escape sequences in regexes
syn match cf3Esc /\(\.[\+\*]\|\\\)[\+\*]\{0,1\}/ contained
" Array indexes contained in []. Does not seems to be working.
syn region cf3Array start=/\[/ end=/\]/ contained contains=cf3Var
" Variables wrapped in {} or ()
syn region cf3Var start=/\$[{(]/ end=/[})]/ contained
contains=cf3Var,cf3Array
syn region cf3List start=/@[{(]/ end=/[})]/ contained
syn region cf3String start=/"/ skip=/\\"/ end=/"/
contains=cf3Var,cf3Array,cf3Esc,cf3List
syn keyword cf3Type int ilist string slist float real rlist
syn keyword cf3OnOff on off yes no true false
" LHS list extracted from attributes.c using sed command:
" echo $( { sed -n 's/^.*Get*Constraint(.*"\([^"\*]*\)".*/\1/p'
src/attributes.c; sed -n
's/^.*{\s*"\([^"\*]*\)"\s*,\s*cf_.*/\1/p;s/^\s*{\s*"\*"\s*,\s*"\([^"\*]*\)".*/\1/p'
src/mod_*.c; } | sort -u )
syn keyword cf3LHS abortbundleclasses abortclasses ...truncated...
The keyword list is long and thus truncated...
It's not yet ready to contribute to the community vim site, as I'm having some
challenges with hilighting the way I want within contained regions. So Neil
will be getting an email from me eventually, but not until I get the last few
bugs worked out. Until then, this should provide a good start for someone
doing syntax highlighting.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine