This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/misc/editors/language-yap/grammars/yap.cson

618 lines
21 KiB
Plaintext
Raw Normal View History

comment: "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain"
fileTypes: [
"yap"
"yss"
"prolog"
"pl"
"pro"
]
firstLineMatch: "^(#!/.*\\byap|\\%.*prolog.*)"
foldingStartMarker: "^(([a-z]\\w*|\\'\\$\\w\\')\\(|\\s*\\(|\\s*\\/\\*)"
foldingStopMarker: "(\\)|\\.|\\*\\/)\\s*$"
name: "YAP-Prolog"
patterns: [
{
include: "#comments"
}
{
begin: "^(:-)\\s*(([a-z]\\w*:)?([a-z]\\w*|\\'\\$\\w*\\'))(?=(\\(|\\s))"
beginCaptures:
"1":
name: "keyword.control.directive.begin.prolog"
"2":
name: "entity.directivesss.prolog"
end: "(\\.)(\\s|$)"
endCaptures:
"2":
name: "keyword.control.directive.end.prolog"
name: "meta.directive.prolog"
patterns: [
{
include: "#functor"
}
{
include: "#atom"
}
{
include: "#variable"
}
{
include: "#constants"
}
{
match: "."
}
]
}
{
begin: "^\\s*(([a-z]\\w*)(:))?([a-z]\\w*|\\'\\$\\w*\\')\\("
beginCaptures:
"0":
name: "meta.clause.prolog.head"
"2":
name: "entity.name.module.clause.prolog"
"3":
name: "keyword.control.module.prolog"
"4":
name: "entity.name.predicate.prolog"
end: "((\\.)(\\s|$))"
endCaptures:
"2":
name: "keyword.control.clause.end.prolog"
name: "meta.clause.prolog"
patterns: [
{
include: "#clause_head_arguments"
}
{
include: "#clause_body"
}
]
}
{
begin: "^\\s*(([a-z]\\w*)(:))?([a-z]\\w*|\\'\\$\\w*\\')\\s*"
beginCaptures:
"0":
name: "meta.clause.prolog.head"
"2":
name: "entity.name.module.clause.prolog"
"3":
name: "keyword.control.module.prolog"
"4":
name: "entity.name.predicate.prolog"
end: "((\\.)(\\s|$))"
endCaptures:
"2":
name: "keyword.control.clause.end.prolog"
name: "meta.clause.prolog"
patterns: [
{
include: "#clause_body"
}
]
}
]
repository:
args:
name: "meta.term.arguments"
patterns: [
{
include: "#term"
}
{
match: "\\,"
}
]
atom:
patterns: [
{
match: "\\[\\]"
name: "constant.other.atom.emptylist.prolog"
}
{
match: "\\b[a-z]\\w*\\b"
name: "support.atom.simple.prolog"
}
{
begin: "(?<!\\w)\\'"
beginCaptures:
"0":
name: "string.quoted.single.prolog"
end: "\\'"
endCaptures:
"0":
name: "string.quoted.single.prolog"
name: "string.quoted.single.prolog"
patterns: [
{
match: "\\\\[abcfnrstv\\'\\\"\\`\\\\]"
name: "constant.character.escape.prolog"
}
{
match: "\\\\(x\\h{2}|u\\h{4}|U\\h{8})"
name: "constant.character.single_u.prolog"
}
{
match: "\\'\\'"
name: "constant.character.single_qu.prolog"
}
{
match: "(.)"
name: "string.quoted.single.prolog"
}
]
}
]
base_call:
name: "meta.call.prolog"
patterns: [
{
match: "!"
name: "keyword.control.clause.cut.prolog"
}
{
include: "#bracketed_call"
}
{
include: "#cbracketed_call"
}
{
include: "#builtin_call"
}
{
include: "#user_call"
}
{
include: "#term"
}
{
match: "\\s"
}
]
"block-comment":
begin: "/\\*"
beginCaptures:
"0":
name: "punctuation.definition.comment.block.begin.prolog"
comment: "Block comment"
end: "\\*/"
endCaptures:
"0":
name: "punctuation.definition.comment.block.end.prolog"
name: "comment.block.prolog"
patterns: [
{
match: "."
}
]
bracketed_call:
begin: "\\s*(\\()\\s*"
beginCaptures:
"0":
name: "keyword.control.clause.block.start.prolog"
end: "\\s*(\\))\\s*"
endCaptures:
"1":
name: "keyword.control.clause.block.end.prolog"
name: "meta.call.brackets.prolog"
patterns: [
{
include: "#conj"
}
{
include: "#disj"
}
{
include: "#base_call"
}
]
builtin_call:
begin: "(asserta|atomic_list_concat|char_type|compile_expressions|compile |create_prolog_flag|current_module|current_op|del_attrs|depth_bound_call |dule|exo_files|export_list|foreign_directory|garbage_collect_atoms|garbage_collect |get_attrs|hread_signal|ignore|incore|initialization|int_message|message_to_string |module_property|msort|mutex_unlock_all|no_style_check|nospy|notrace |ortray_clause|otherwise|predsort|prolog_initialization|qend_program|qsave_file |recordaifnot|set_base_module|sformat|source_file|split_path_file|stream_position |system_error|system_module|t_head|table_statistics|tabling_mode|tabling_statistics |thread_defaults|thread_local|thread_set_defaults|thread_statistics|unix |use_system_module|user_defined_directive|version|get_attrs|C|abolish_all_tables |abolish_frozen_choice_points|abolish_module|abolish_table|abolish|abort |absolute_file_name|absolute_file_system_path|access_file|access|acyclic_term |add_import_module|add_to_array_element|add_to_path|alarm|all|always_prompt_user |arena_size|arg|array_element|array|assert_static|asserta_static|asserta |assertz_static|assertz|assert|at_end_of_line|at_end_of_stream_0|at_end_of_stream |at_halt|atom_chars|atom_codes|atom_concat|atom_length|atom_number|atom_string |atom_to_term|atomic_concat|atomic_length|atomic_list_concat|atomics_to_string |atomic|atom|attvar|b_getval|b_setval|bagof|bb_delete|bb_get|bb_put |bb_update|between|bootstrap|break|call_cleanup|call_count_data|call_count_reset |call_count|call_residue_vars|call_residue|call_shared_object_function |call_with_args|callable|call|catch_ball|catch|cd|cfile_search_path |char_code|char_conversion|char_type|clause_property|clause|close_shared_object |close_static_array|close|code_type|commons_directory|commons_library |compare|compile_expressions|compile_predicates|compile|compound|consult_depth |consult|context_module|copy_term_nat|copy_term|create_mutable|create_prolog_flag |creep_allowed|current_atom|current_char_conversion|current_host|current_input |current_key|current_line_number|current_module|current_mutex|current_op |current_output|current_predicate|current_prolog_flag|current_reference_count |current_stream|current_thread|db_files|db_reference|debugging|debug |decrease_reference_count|del_attrs|del_attr|delete_import_module|depth_bound_call |dif|discontiguous|display|do_c_built_in|do_c_built_metacall|do_not_compile_expressions |dump_active_goals|dum|duplicate_term|dynamic_predicate|dynamic_update_array |dynamic|eamconsult|eamtrans|end_of_file|ensure_loaded|eraseall|erased |erase|exists_directory|exists_file|exists_source|exists|exo_files|expand_exprs |expand_expr|expand_file_name|expand_goal|expand_term|expects_dialect |export_list|export_resource|export|extend|fail|false|file_base_name |file_directory_name|file_exists|file_name_extension|file_search_path|file_size |fileerrors|findall|float|flush_output|forall|foreign_directory|format |freeze_choice_point|freeze|frozen|functor|garbage_collect_atoms|garbage_collect |gc|get0|get_attr|get_byte|get_char|get_code|get_depth_limit|get_mutable |get_string_code|get_value|getcwd|getenv|get|global_trie_statistics|ground |grow_heap|grow_stack|halt|heap_space_info|hide_atom|hide_predicate|hostname_address |hread_get_message|if|ignore|import_module|incore|increase_reference_count |init_random_state|initialization|instance_property|instance|integer|is_absolute_file_name |is_list|is_mutable|is_tabled|isinf|isnan|is|key_erased_statistics|key_statistics |keysort|leash|length|libraries_directories|line_count|listing|load_absolute_foreign_files |load_db|load_files|load_foreign_files|log_event|logsum|ls_imports|ls |make_directory|make_library_index|make|message_queue_create|message_queue_destroy |message_queue_property|message_to_string|mmapped_array|module_property |module_state|module|msort|multifile|must_be_of_type|mutex_create|mutex_property |mutex_unlock_all|name|nb_create|nb_current|nb_delete|nb_getval|nb_linkarg |nb_linkval|nb_set_bit|nb_set_shared_arg|nb_set_shared_val|nb_setarg|nb_setval |new_system_module|nl|no_source|no_style_check|nodebug|nofileel
beginCaptures:
"1":
name: "support.function.prolog"
end: "(\\))"
name: "meta.call.builtin.prolog"
patterns: [
{
include: "#args"
}
]
cbracketed_call:
begin: "\\s*(\\{)\\s*"
beginCaptures:
"0":
name: "keyword.control.clause.block.start.prolog"
end: "\\s*(\\})\\s*"
endCaptures:
"0":
name: "keyword.control.clause.block.end.prolog"
name: "meta.call.curly_brackets.prolog"
patterns: [
{
include: "#conj"
}
{
include: "#disj"
}
{
include: "#base_call"
}
]
clause_body:
begin: "(:-|-->)"
beginCaptures:
"1":
name: "keyword.control.clause.neck.prolog"
end: "(?=((\\.)(\\s|$)))"
name: "meta.clause.prolog.body"
patterns: [
{
include: "#conj"
}
{
include: "#conj"
}
{
include: "#base_call"
}
]
clause_head_arguments:
begin: "(?<=\\()"
end: "(\\))\\s*(?=(:-|-->|\\.))"
name: "meta.clause.prolog.head"
patterns: [
{
include: "#args"
}
]
comments:
comment: "All comment types"
patterns: [
{
include: "#documentation-comment"
}
{
include: "#block-comment"
}
{
include: "#in-line-comment"
}
{
include: "#in-line-documentation"
}
]
conj:
begin: "\\,"
beginCaptures:
"0":
name: "keyword.control.and.prolog"
end: "(?=(\\,|\\)|\\}|\\]|\\.))"
name: "meta.clause.body.conjunction"
patterns: [
{
include: "#disj"
}
{
include: "#conj"
}
{
include: "#base_call"
}
]
constants:
patterns: [
{
match: "0\\'(.)"
name: "constant.character.code.prolog"
}
{
match: "0x\\h+0x"
name: "constant.numeric.hexa.prolog"
}
{
match: "0[0-7]+"
name: "constant.numeric.octal.prolog"
}
{
match: "[+-]?\\d+"
name: "constant.numeric.integer.prolog"
}
{
match: "([0-9_]+)(\\.([0-9]+))?([eE][+\\-]?([0-9]+))?"
name: "constant.numeric.floating-point.prolog"
}
{
begin: "\\\""
beginCaptures:
"0":
name: "string.quoted.double.prolog"
end: "\\\""
endCaptures:
"0":
name: "string.quoted.double.prolog"
name: "string.quoted.double.prolog"
patterns: [
{
match: "\\\\[abcfnrstv\\'\\\"\\`\\\\]"
name: "constant.character.doubleescape.prolog"
}
{
match: "\\\\(x\\h{2}|u\\h{4}|U\\h{8})"
name: "constant.character.double_code.prolog"
}
{
match: "\\\"\\\""
name: "constant.character.double_qu.prolog"
}
{
match: "(.)"
name: "string.quoted.double.prolog"
}
]
}
{
begin: "\\`"
beginCaptures:
"0":
name: "string.quoted.back.prolog"
end: "\\`"
endCaptures:
"0":
name: "string.quoted.back.prolog"
name: "string.quoted.back.prolog"
patterns: [
{
match: "\\\\[abcfnrstv\\'\\\"\\`\\\\]"
name: "constant.character.backescape.prolog"
}
{
match: "\\\\(x\\h{2}|u\\h{4}|U\\h{8})"
name: "constant.character.back_code.prolog"
}
{
match: "\\`\\`"
name: "constant.character.back_qu.prolog"
}
{
match: "(.)"
name: "string.quoted.back.prolog"
}
]
}
]
crlbrackets:
begin: "(\\{)"
end: "(\\})"
name: "curly.brackets"
patterns: [
{
include: "#comments"
}
{
match: "\\s*\\,\\s*"
}
{
include: "#term"
}
]
disj:
begin: "((\\;)|(->))"
beginCaptures:
"2":
name: "keyword.control.or.prolog"
"3":
name: "keyword.control.if.prolog"
end: "\\s*(?=(\\,|\\;|\\.|\\)|\\}|\\|\\.\\]))"
name: "meta.clause.disjunction"
patterns: [
{
include: "#disj"
}
{
include: "#base_call"
}
]
"documentation-comment":
begin: "/\\*[*!]\\s"
beginCaptures:
"0":
name: "punctuation.definition.comment.block.documentation.begin.prolog"
comment: "Documentation comment"
end: "\\*/"
endCaptures:
"0":
name: "punctuation.definition.comment.block.documentation.end.prolog"
name: "comment.block.documentation.prolog"
patterns: [
{
include: "#dox"
}
{
include: "pred"
}
{
match: "."
}
]
dox:
patterns: [
{
captures:
"1":
name: "keyword.language.doxygen.prolog"
"2":
name: "string.unquoted.file.prolog"
match: "(@file)(.*$)"
}
{
captures:
"1":
name: "keyword.language.doxygen.prolog"
"2":
name: "variable.label.group.prolog"
match: "(@ingroup)(.*$)"
}
{
captures:
"1":
name: "keyword.language.doxygen.prolog"
"2":
name: "variable.label.group.prolog"
"3":
name: "string.text.group.prolog"
match: "(@defgroup)\\s+(\\w+)\\s+(.*$)"
}
{
captures:
"1":
name: "keyword.language.doxygen.prolog"
"2":
name: "string.unquoted.text.prolog"
match: "(@pred)(.*$)"
}
{
captures:
"1":
name: "keyword.language.doxygen.prolog"
match: "(@\\w+\\b|\\\\w*)"
}
]
eot:
captures:
"1":
name: "keyword.control.eot.prolog"
match: "(\\.\\s*(\\s|$))"
functor:
captures:
"1":
name: "constant.functor.prolog"
"2":
name: "constant.functor.name.prolog"
"3":
name: "constant.functor.arity.prolog"
match: "(([a-z]\\w*|\\'\\$\\w*\\')/\\d+)"
"in-line-comment":
captures:
"1":
name: "punctuation.definition.comment.line.double-slash.prolog"
comment: "In-line comment"
match: "\\%.*"
name: "comment.line.percentage.prolog"
"in-line-documentation":
captures:
"1":
name: "punctuation.definition.comment.line.percent.prolog"
comment: "In-line comment"
match: "\\%\\%\\s.*"
name: "comment.line.percentage.documentation.prolog"
patterns: [
{
include: "#dox"
}
{
match: "."
}
]
op_infix:
match: "(same|\\^|\\*\\*|rem|mod|\\>\\>| \\<\\<|\\/\\/|\\/|\\*|xor|div|rdiv|\\#| ><|\\\\\\/|\\/\\\\|\\\\-|\\\\+|:|as|>=|=<| >|<|=\\\\=|=:=|\\\\=@=|=@=|@>=|@=<|@>|@<| \\\\==|==|=\\.\\.|is|\\\\=|=|->|\\;|\\,|\\||-->|\\?-)"
name: "keyword.control.op.infix.prolog"
op_prefix:
match: "(spy|nospy|block|\\\\|\\-|\\+|not|\\\\\\+|uncutable| table|discontiguous|module_transparent|meta_predicate|multifile| public|mode|volatile|initialization|thread_local| dynamic|\\?-|\\?-)"
name: "keyword.control.op.prefix.prolog"
protected_term:
begin: "\\b"
beginCaptures:
"1":
name: "meta.term.prolog"
end: "\\b"
name: "meta.call.user.prolog"
patterns: [
{
include: "#term"
}
]
"shebang-line":
captures:
"1":
name: "punctuation.definition.comment.line.shebang.prolog"
comment: "Shebang line"
match: "^(#!).*$"
name: "comment.line.shebang.prolog"
sqrbrackets:
begin: "(\\[)"
end: "(\\])"
name: "sqr.brackets"
patterns: [
{
include: "#comments"
}
{
match: "\\s*(\\,|\\|)\\s*"
}
{
include: "#term"
}
]
term:
name: "meta.term.prolog"
patterns: [
{
include: "#comments"
}
{
include: "#op_infix"
}
{
include: "#op_prefix"
}
{
include: "#atom"
}
{
include: "#variable"
}
{
include: "#constants"
}
{
include: "#brackets"
}
{
include: "#sqrbrackets"
}
{
include: "#crlbrackets"
}
{
match: "\\s"
}
]
user_call:
begin: "([a-z]]w*:)?([a-z]\\w*|\\'\\$\\w*\\')(\\()"
beginCaptures:
"1":
name: "meta.term.prolog"
end: "\\s*(\\))\\s*"
name: "meta.call.user.prolog"
patterns: [
{
include: "#comments"
}
{
include: "#args"
}
]
variable:
patterns: [
{
match: "(?<![a-zA-Z0-9_])[A-Z][a-zA-Z0-9_]*"
name: "variable.parameter.uppercase.prolog"
}
{
match: "(?<!\\w)_\\w*"
name: "variable.parameter.anonymous.prolog"
}
]
scopeName: "source.prolog"