Last active
August 29, 2015 14:13
-
-
Save peckpeck/ca3e6204b1d7a6fb80e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"comment": "Grammar that match cfengine code syntax", | |
"fileTypes": ["cf", "cf3"], | |
"scopeName": "source.cfengine", | |
# Main file : only comment, body and bundle | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#body" | |
}, { | |
"include": "#bundle" | |
}, { | |
"include": "#st" | |
}, { | |
# catch syntax error, but show only 1 char as illegal to avoid ugliness | |
"match": "(\\s*[^\\s]).*", | |
"captures": { | |
"1": { | |
"name": "invalid.illegal" | |
} | |
} | |
}], | |
"repository": { | |
# comment can be almost everywhere, include at the beginning of patterns | |
"comment": { | |
"name": "comment.line.number-sign.cfengine", | |
"match": "\\s*#.*" | |
}, | |
# allow separator only and consider everything else broken, include at the end of list patterns | |
"separator": { | |
# \w should be a syntax error, but adding it allows for a nice catch up case of error | |
"match": "[^\\s,\\w]+", | |
"name": "invalid.illegal" | |
}, | |
"parameter": { | |
"name": "variable.parameter.cfengine", | |
"match": "\\w+" | |
}, | |
"parameters": { | |
"begin": "\\(", | |
"end": "\\)", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#parameter" | |
}, { | |
"include": "#separator" | |
}] | |
}, | |
"variable": { | |
"patterns": [{ | |
# with parentheses syntax | |
"begin": "\\$\\(", | |
"end": "\\)", | |
"name": "string.quoted.double.untitled.cfengine" | |
}, { | |
# with brace syntax | |
"begin": "\\${", | |
"end": "}", | |
"name": "string.quoted.double.untitled.cfengine" | |
}] | |
}, | |
"string": { | |
"patterns": [{ | |
# string with double quote | |
"name": "string.quoted.double.untitled.cfengine", | |
"begin": "\"", | |
"end": "(?<!\\\\)\"" | |
}, { | |
# string with single quote | |
"name": "string.quoted.double.untitled.cfengine", | |
"begin": "'", | |
"end": "(?<!\\\\)'" | |
}] | |
}, | |
"st": { | |
"begin": "&", | |
"end": "&", | |
"name": "meta", | |
"patterns": [{ | |
"begin": "{", | |
"end": "}" | |
}] | |
}, | |
# can be : function call, string, variable, litteral | |
"scalar": { | |
"patterns": [{ | |
"include": "#call" | |
}, { | |
"include": "#string" | |
}, { | |
"include": "#variable" | |
}, { | |
"name": "variable.other.cfengine", | |
"match": "\\w+" | |
}, { | |
"include": "#st" | |
}] | |
}, | |
# function call / body call | |
"call": { | |
"begin": "(\\w+)\\s*\\(", | |
"beginCaptures": { | |
"1": { | |
"patterns": [{ | |
# stdlib functions/bodies | |
# generated from vim syntax file /keyword cf3BuiltIns|keyword cf3Stdlib/ | |
# thanks Neil Watson | |
"match": "\\b(?:accessedbefore|accumulated|ago|and|canonify|contained|canonifyuniquely|changedbefore|classesmatching|classify|classmatch|concat|contained|countclassesmatching|countlinesmatching|difference|dirname|diskfree|escape|contained|eval|every|execresult|fileexists|filesexist|filesize|contained|filestat|filter|findfiles|format|getenv|getfields|contained|getgid|getindices|getuid|getusers|getvalues|grep|contained|groupexists|hash|hashmatch|host2ip|hostinnetgroup|hostrange|contained|hostsseen|hostswithclass|hubknowledge|ifelse|intersection|ip2host|contained|iprange|irange|isdir|isexecutable|isgreaterthan|islessthan|contained|islink|isnewerthan|isplain|isvariable|join|lastnode|contained|laterthan|ldaparray|ldaplist|ldapvalue|length|lsdir|contained|maparray|maplist|mergecontainer|none|not|now|contained|nth|on|or|parseintrealstringarray|parsejson|parsestringarrayidx|contained|peerleader|peerleaders|peers|product|randomint|readfile|contained|readintrealstringarray|readintrealstringlist|readjson)\\b", | |
"name": "support.function.cfengine" | |
}, { | |
"match": "\\b(?:readstringarrayidx|readtcp|regarray|contained|regcmp|regextract|registryvalue|regldap|regline|reglist|contained|remoteclassesmatching|remotescalar|returnszero|reverse|rrange|selectservers|contained|shuffle|some|sort|splayclass|splitstring|strcmp|contained|strftime|sublist|sum|translatepath|unique|usemodule|contained|userexists|contained|INI_section|access_generic|after|all|all_changes|contained|alpinelinux|always|any_count|append_groups_starting|append_if_no_line|append_if_no_lines|contained|append_to_line_end|append_user_field|append_users_starting|apt|apt_get|apt_get_release|contained|backup_local_cp|backup_timestamp|before|bg|bigger_than|bootstart|contained|brew|by_name|by_owner|cf2_if_else|check_range|classes_generic|contained|cmd_repair|col|comment|comment_lines_containing|comment_lines_matching|common_knowledge|contained|control|create_solaris_admin_file|cronjob|darwin_knowledge|days_old|days_older_than|contained|debian_knowledge|delete_lines_matching|detect_all_change)\\b", | |
"name": "support.function.cfengine" | |
}, { | |
"match": "\\b(?:detect_all_change_using|detect_content|detect_content_using|contained|diff|diff_noupdate|dirs|disable|dpkg_version|emerge|contained|empty|enumerate|ex_list|exclude|exclude_procs|expand_template|contained|feature|feature_cancel|feature_test|fileinfo|filetype_older_than|filetypes_older_than|contained|force_deps|freebsd|freebsd_portmaster|generic|if_elapsed|if_elapsed_day|contained|if_else|if_notkept|if_ok|if_ok_cancel|if_repaired|ifwin_bg|contained|immediate|in_dir|in_dir_shell|in_dir_shell_and_silent|in_shell|in_shell_and_silent|contained|in_shell_bg|include_base|insert_file|insert_lines|ips|jail|contained|kvm|line|line_match_value|linkchildren|ln_s|local_cp|contained|local_dcp|local_mysql|local_postgresql|log_repaired|log_verbose|logrotate|contained|m|maintain_key_values|manage_variable_values_ini|measure_performance|min_free_space|mo|contained|mog|msi_explicit|msi_implicit|name_age|nfs|nfs_p|contained|no_backup|no_backup_cp|no_backup_dcp|no_backup_rcp|noupdate|ntfs|contained|og|older_than)\\b", | |
"name": "support.function.cfengine" | |
}, { | |
"match": "\\b(?:opencsw|owner|pacman|paths|contained|perms_cp|plain|policy|prunedir|quoted_var|recurse|contained|recurse_ignore|recurse_with_base|redhat_knowledge|regex_replace|remote_cp|remote_dcp|contained|replace_line_end|replace_or_add|resolvconf|resolvconf_o|rm_rf|rm_rf_depth|contained|rotate|rpm_filebased|rpm_version|sample_rate|scan_changing_file|scan_log|contained|scoped_classes_generic|secure_cp|seed_cp|set_colon_field|set_config_values|set_config_values_matching|contained|set_quoted_values|set_user_field|set_variable_values|set_variable_values_ini|setuid|setuid_sh|contained|setuid_umask|setuidgid_sh|silent|silent_in_dir|single_value|size_range|contained|smartos|solaris|standard_services|start|state_repaired|std_defs|contained|strict|sync_cp|tidy|to|uncomment|uncomment_lines_containing|contained|uncomment_lines_matching|unmount|value|warn_lines_matching|warn_only|windows_feature|contained|yum|yum_group|yum_rpm|yum_rpm_enable_repo|zypper|contained)\\b", | |
"name": "support.function.cfengine" | |
}, { | |
"match": ".*", | |
"name": "variable.other.cfengine" | |
}] | |
} | |
}, | |
"end": "\\)", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#list_include" | |
}, { | |
"include": "#scalar" | |
}, { | |
"include": "#separator" | |
}] | |
}, | |
"list_include": { | |
"patterns": [{ | |
# list include with brace syntax | |
"match": "@{([\\w.]+)}", | |
"name": "string.quoted.double.untitled.cfengine" | |
}, { | |
# list include with parentheses syntax | |
"match": "@\\(([\\w.]+)\\)", | |
"name": "string.quoted.double.untitled.cfengine" | |
}] | |
}, | |
"list": { | |
"begin": "{", | |
"end": "}", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#list_include" | |
}, { | |
"include": "#scalar" | |
}, { | |
"include": "#separator" | |
}] | |
}, | |
"class": { | |
"match": "^\\s*([^\\s\"]\\S*)::", | |
"captures": { | |
"1": { | |
"patterns": [{ | |
"match": "\\w+", | |
"name": "constant.language.cfengine" | |
}, { | |
"match": "[^\\s!.|&()]+", | |
"name": "invalid.illegal" | |
}] | |
} | |
} | |
}, | |
"body": { | |
# all possible bodies including syntax error | |
"begin": "^\\s*(body)\\s+(?:(common|agent|server|monitor|runagent|executor|knowledge|hub|reporter|file)\\s+(control)\\s*([^{]?)|(action|classes|contain|acl|changes|copy_from|delete|depth_search|edit_defaults|file_select|link_from|perms|rename|tcp_ip|package_method|process_count|process_select|service_method|mount|volume|printfile|match_value|association|select_region|delete_select|insert_select|location|edit_field|replace_with|common|database_server|environment_resources)\\s+(\\w+)|(\\S+)\\s+(\\w+))", | |
"beginCaptures": { | |
"1": { | |
"name": "storage.type.class.cfengine" | |
}, | |
"2": { | |
"name": "storage.type.class.cfengine" | |
}, | |
"3": { | |
"name": "entity.name.type.cfengine" | |
}, | |
"4": { | |
"name": "invalid.illegal" | |
}, | |
"5": { | |
"name": "storage.type.class.cfengine" | |
}, | |
"6": { | |
"name": "entity.name.type.cfengine" | |
}, | |
"7": { | |
"name": "invalid.illegal" | |
}, | |
"8": { | |
"name": "entity.name.type.cfengine" | |
} | |
}, | |
"end": "}", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#parameters" | |
}, { | |
# body content | |
"begin": "{", | |
# keep the brace to allow end detection in parent | |
"end": "(?=})", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#class" | |
}, { | |
"begin": "(\\w+)\\s*(=>)", | |
"beginCaptures": { | |
"1": { | |
"patterns": [{ | |
"match": "\\b(?:leaf_name|path_name|search_mode|search_size|search_owners|contained|search_groups|search_bsdflags|ctime|mtime|atime|contained|exec_regex|exec_program|file_types|issymlinkto|file_result|contained|promise_repaired|repair_failed|repair_denied|contained|repair_timeout|promise_kept|cancel_kept|cancel_repaired|contained|cancel_notkept|kept_returncodes|repaired_returncodes|contained|failed_returncodes|persist_time|scope|timer_policy|contained|copy_patterns|link_children|link_type|source|contained|when_linking_children|when_no_source|contained|bsdflags|groups|mode|owners|rxdirs|contained|aces|acl_directory_inherit|acl_method|acl_type|specify_inherit_aces|contained|depth|exclude_dirs|include_basedir|include_dirs|contained|rmdeadlinks|traverse_links|xdev|contained|dirlinks|rmdirs|contained|disable|disable_mode|disable_suffix|newname|rotate|contained|hash|report_changes|update_hashes|report_diffs|contained|package_add_command|package_arch_regex|contained|package_changes|package_delete_command)\\b", | |
"name": "entity.name.tag.cfengine" | |
}, { | |
"match": "\\b(?:contained|package_delete_convention|package_file_repositories|contained|package_installed_regex|package_list_arch_regex|contained|package_list_command|package_list_name_regex|contained|package_list_update_command|package_list_update_ifelapsed|contained|package_list_version_regex|package_name_convention|contained|package_name_regex|package_noverify_regex|contained|package_noverify_returncode|package_patch_arch_regex|contained|package_patch_command|package_patch_installed_regex|contained|package_patch_list_command|package_patch_name_regex|contained|package_patch_version_regex|package_update_command|contained|package_verify_command|package_version_regex|contained|package_version_less_command|package_version_equal_command|contained|package_multiline_start|contained|action_policy|ifelapsed|expireafter|log_string|contained|log_level|log_kept|log_priority|log_repaired|contained|log_failed|value_kept|value_repaired|value_notkept|contained|audit|background|report_level|contained|measurement_class)\\b", | |
"name": "entity.name.tag.cfengine" | |
}, { | |
"match": "\\b(?:contained|useshell|umask|exec_owner|exec_group|exec_timeout|contained|chdir|chroot|preview|no_output|contained|source|servers|collapse_destination_dir|contained|compare|copy_backup|encrypt|check_root|contained|copylink_patterns|copy_size|findertype|contained|linkcopy_patterns|link_type|force_update|contained|force_ipv4|portnumber|preserve|protocol_version|purge|contained|stealth|timeout|trustkey|type_check|verify|contained|check_foreign|freespace|sensible_size|contained|sensible_count|scan_arrivals|contained|edit_fstab|mount_type|mount_source|contained|mount_server|mount_options|unmount|contained|service_type|service_args|contained|service_autostart_policy|service_dependence_chain|contained|db_server_owner|db_server_password|contained|db_server_host|db_server_type|contained|db_server_connection_db|contained|env_cpus|env_memory|env_disk|contained|env_baseline|env_spec_file|env_spec|contained|select_line_matching|select_line_number|contained|extraction_regex|track_growing_file|contained)\\b", | |
"name": "entity.name.tag.cfengine" | |
}, { | |
"match": "\\b(?:service_type|service_args|service_bundle|contained|service_autostart_policy|service_dependence_chain|contained|env_addresses|env_name|env_network|contained|allowallconnects|allowconnects|allowlegacyconnects|contained|allowusers|auditing|bindtointerface|contained|cfruncommand|denybadclocks|denyconnects|contained|dynamicaddresses|hostnamekeys|keycacheTTL|contained|logallconnections|logencryptedtransfers|contained|maxconnections|port|serverfacility|contained|skipverify|trustkeysfrom|contained|abortclasses|abortbundleclasses|addclasses|contained|agentaccess|agentfacility|alwaysvalidate|contained|auditing|binarypaddingchar|bindtointerface|contained|hashupdates|childlibpath|checksum_alert_time|contained|defaultcopytype|dryrun|editbinaryfilesize|contained|editfilesize|environment|exclamation|expireafter|contained|files_single_copy|files_auto_define|hostnamekeys|contained|ifelapsed|inform|intermittency|max_children|contained|maxconnections|mountfilesystems|nonalphanumfiles|contained|repchar)\\b", | |
"name": "entity.name.tag.cfengine" | |
}, { | |
"match": "\\b(?:refresh_processes|default_repository|contained|secureinput|sensiblecount|sensiblesize|contained|skipidentify|suspiciousnames|syslog|verbose|contained|track_value|timezone|default_timeout|contained|splaytime|mailfrom|mailsubject|mailto|smtpserver|contained|mailmaxlines|schedule|executorfacility|contained|exec_command|contained|edit_backup|empty_file_before_editing|contained|max_file_size|recognize_join|inherit|contained|delete_if_startwith_from_list|contained|delete_if_not_startwith_from_list|contained|delete_if_match_from_list|contained|delete_if_not_match_from_list|contained|delete_if_contains_from_list|contained|delete_if_not_contains_from_list|contained|insert_if_startwith_from_list|contained|insert_if_not_startwith_from_list|contained|insert_if_match_from_list|contained|insert_if_not_match_from_list|contained|insert_if_contains_from_list|contained|insert_if_not_contains_from_list|contained|forgetrate|monitorfacility|histograms|contained|tcpdump|tcpdumpcommand|contained|file_to_print|number_of_lines|contained)\\b", | |
"name": "entity.name.tag.cfengine" | |
}, { | |
"match": ".*", | |
"name": "variable.other.cfengine" | |
}] | |
}, | |
"2": { | |
"name": "keyword.operator.cfengine" | |
} | |
}, | |
"end": ";", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#list" | |
}, { | |
"include": "#scalar" | |
}, { | |
"include": "#separator" | |
}] | |
}, { | |
"include": "#st" | |
}] | |
}] | |
}, | |
"bundle": { | |
# All possible bundles | |
"begin": "^\\s*(bundle)\\s+(?:(agent|common|server|knowledge|monitor|edit_line|edit_xml)|(\\S+))\\s+(\\w+)", | |
"beginCaptures": { | |
"1": { | |
"name": "storage.type.class.cfengine" | |
}, | |
"2": { | |
"name": "storage.type.class.cfengine" | |
}, | |
"3": { | |
"name": "invalid.illegal" | |
}, | |
"4": { | |
"name": "entity.name.type.cfengine" | |
} | |
}, | |
"end": "}", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#parameters" | |
}, { | |
# bundle content | |
"begin": "{", | |
# keep the brace to allow end detection in parent | |
"end": "(?=})", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"match": "^\\s*(vars|classes|reports|meta|commands|databases|files|interfaces|methods|packages|storage|access|measurements|roles|topics|occurrences|defaults|control|guest_environments|outputs|processes|services|things|delete_lines|field_edits|insert_lines|replace_patterns):(?!:)", | |
"captures": { | |
"1": { | |
"name": "entity.name.section.cfengine" | |
} | |
} | |
}, { | |
"match": "^\\s*(\\w+):(?!:)", | |
"captures": { | |
"1": { | |
"name": "invalid.illegal" | |
} | |
} | |
}, { | |
"include": "#class" | |
}, { | |
"begin": "^\\s*(?=[\"'])", | |
"end": ";", | |
"patterns": [{ | |
"include": "#comment" | |
}, { | |
"include": "#string" | |
}, { | |
"begin": "(\\w+)\\s*(=>)", | |
"beginCaptures": { | |
"1": { | |
"patterns": [{ | |
"match": "\\b(?:string|int|real|slist|ilist|rlist|data|bundlesequence|cache_system_functions|goal_categories|contained|ignore_missing_bundles|ignore_missing_inputs|inputs|contained|version|lastseenexpireafter|output_prefix|domain|contained|require_comments|host_licenses_paid|site_classes|contained|syslog_host|syslog_port|fips_mode|protocol_version|contained|usebundle|useresult|inherit|contained|action|classes|ifvarclass|handle|depends_on|comment|policy|contained|and|dist|expression|not|or|persistence|scope|select_class|xor|contained|args|contain|module|contained|process_count|process_select|contained|process_stop|restart_class|signals|contained|package_architectures|package_method|package_policy|contained|package_select|package_version|contained|environment_host|environment_interface|contained|environment_resources|environment_state|contained|environment_type|contained|association|synonyms|generalizations|contained|service_policy|service_dependencies|service_method|contained|database_server|database_type|contained|database_operation)\\b", | |
"name": "entity.name.tag.cfengine" | |
}, { | |
"match": "\\b(?:database_columns|contained|database_rows|registry_exclude|contained|if_match_regex|contained|mount|volume|contained|acl|changes|copy_from|create|delete|depth_search|contained|edit_defaults|edit_line|edit_template|edit_xml|file_select|contained|link_from|move_obstructions|pathtype|perms|contained|rename|repository|touch|transformer|contained|admit_ips|admit_hostnames|admit_keys|admit|deny|deny_ips|deny_hostnames|deny_keys|maproot|contained|ifencrypted|resource_type|contained|stream_type|data_type|history_type|contained|units|match_value|contained|friend_pattern|intermittency|lastseen|contained|printfile|report_to_file|showstate|contained|bundle_return_value_index|contained|replace_with|edit_field|whitespace_policy|location|contained|insert_select|insert_type|expand_scalars)\\b", | |
"name": "entity.name.tag.cfengine" | |
}, { | |
"match": "\\b(?:not_matching|contained|delete_select|select_region|contained|allow_blank_fields|extend_fields|field_operation|contained|field_separator|field_value|select_field|contained|start_fields_from_zero|value_separator|contained|occurrences|replace_value|contained|include_start_delimiter|include_end_delimiter|contained|select_start|select_end|contained|in_range_define|match_range|out_of_range_define|contained|command|pid|ppid|pgid|priority|process_owner|contained|process_result|rsize|status|stime_range|ttime_range|contained|tty|threads|vsize|contained|edit_backup|empty_file_before_editing|max_file_size|recognize_join|contained|before_after|first_last|select_line_matching|contained)\\b", | |
"name": "entity.name.tag.cfengine" | |
}, { | |
"match": ".*", | |
"name": "variable.other.cfengine" | |
}] | |
}, | |
"2": { | |
"name": "keyword.operator.cfengine" | |
} | |
}, | |
"end": "(?=[,;])", | |
"patterns": [{ | |
"include": "#list" | |
}, { | |
"include": "#scalar" | |
}] | |
}, { | |
"begin": "->", | |
"beginCaptures": { | |
"1": { | |
"name": "keyword.operator.cfengine" | |
} | |
}, | |
"end": "", | |
"patterns": [{ | |
"include": "#list" | |
}] | |
}] | |
}, { | |
"include": "#st" | |
}] | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment