diff --git a/lib/src/grammars/patterns/block_predicate.yaml b/lib/src/grammars/patterns/block_predicate.yaml deleted file mode 100644 index 38bb944..0000000 --- a/lib/src/grammars/patterns/block_predicate.yaml +++ /dev/null @@ -1,27 +0,0 @@ -patterns: - - match: "{{tagged_resource_location}}" - captures: "#tagged_resource_location" - - match: "{{resource_location}}" - captures: "#resource_location" - - match: "{{resource_path}}" - captures: "#resource_path" - - begin: '(\[)' - end: '(\])' - beginCaptures: - 1: - name: "#block_predicate_delims" - endCaptures: - 1: - name: "#block_predicate_delims" - patterns: - - include: "#block_predicate.arguments" - - begin: '(\{)' - end: '(\})' - beginCaptures: - 1: - name: "#nbt_delims" - endCaptures: - 1: - name: "#nbt_delims" - patterns: - - include: "#nbt.compound" diff --git a/lib/src/grammars/patterns/block_predicate/argument/boolean.yaml b/lib/src/grammars/patterns/block_predicate/argument/boolean.yaml deleted file mode 100644 index 654f6a6..0000000 --- a/lib/src/grammars/patterns/block_predicate/argument/boolean.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.block_predicate.argument.boolean.mcfunction -match: "{{boolean}}{{bpat}}" -captures: "#boolean" diff --git a/lib/src/grammars/patterns/block_predicate/argument/literal.yaml b/lib/src/grammars/patterns/block_predicate/argument/literal.yaml deleted file mode 100644 index f6408cc..0000000 --- a/lib/src/grammars/patterns/block_predicate/argument/literal.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.block_predicate.argument.literal.mcfunction -match: "{{literal}}{{bpat}}" -captures: "#literal" diff --git a/lib/src/grammars/patterns/block_predicate/argument/number.yaml b/lib/src/grammars/patterns/block_predicate/argument/number.yaml deleted file mode 100644 index d66fa46..0000000 --- a/lib/src/grammars/patterns/block_predicate/argument/number.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.block_predicate.argument.number.mcfunction -match: "{{number}}{{bpat}}" -captures: "#number" diff --git a/lib/src/grammars/patterns/block_predicate/arguments.yaml b/lib/src/grammars/patterns/block_predicate/arguments.yaml deleted file mode 100644 index 2ce8b45..0000000 --- a/lib/src/grammars/patterns/block_predicate/arguments.yaml +++ /dev/null @@ -1,20 +0,0 @@ -patterns: - - name: meta.block_predicate.argument_spacing.mcfunction - match: " +" - - name: meta.block_predicate.argument.mcfunction - begin: '{{literal}} *(\=) *' - end: '(\,)(?=[\]\n])|(\,)|(?=[\]\n])' - beginCaptures: - 1: - name: "#argument_key" - 2: - name: "#block_predicate_delims" - endCaptures: - 1: - name: "#error" - 2: - name: "#block_predicate_delims" - patterns: - - include: "#block_predicate.argument.number" - - include: "#block_predicate.argument.boolean" - - include: "#block_predicate.argument.literal" diff --git a/lib/src/grammars/patterns/command.yaml b/lib/src/grammars/patterns/command.yaml deleted file mode 100644 index 4e7bd15..0000000 --- a/lib/src/grammars/patterns/command.yaml +++ /dev/null @@ -1,17 +0,0 @@ -patterns: - - name: meta.command.mcfunction - begin: '^\s*{{literal}}[ \n]' - end: "$" - beginCaptures: - # highlight the first command on each line - 1: - name: "#top_level_command" - patterns: - # don't name this one yet, we want to get rid of the space - - begin: "(?<= )" - # consume the space - end: '[ \n]' - # name everything inside as part of the token - contentName: meta.command.token.mcfunction - patterns: - - include: "#command.tokens" diff --git a/lib/src/grammars/patterns/command/token/block_predicate.yaml b/lib/src/grammars/patterns/command/token/block_predicate.yaml deleted file mode 100644 index a8b1b0b..0000000 --- a/lib/src/grammars/patterns/command/token/block_predicate.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# This whole thing is going to look a lot like selector arguments. - -name: meta.command.token.block_predicate.mcfunction - -# Begin whenever we see a resource location followed by an opening bracket. -begin: '{{command_token_l}}(?=(\#)?{{resource_location}}(\[|\{))' - -# Similar to selector arguments; end in several cases. -end: '{{lookahead_newline}}|(?:(?<=\])(?!\{)|(?<=\}))({{not_command_token_delim}}*)' - -endCaptures: - 1: - name: "#error" - -patterns: - - include: "#block_predicate" diff --git a/lib/src/grammars/patterns/command/token/block_predicate_without_namespace.yaml b/lib/src/grammars/patterns/command/token/block_predicate_without_namespace.yaml deleted file mode 100644 index 9644252..0000000 --- a/lib/src/grammars/patterns/command/token/block_predicate_without_namespace.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: meta.command.token.block_predicate_without_namespace.mcfunction - -# We need to be careful here about not selecting an NBT path. We do this -# by using look-ahead to check for a block state property immediately -# inside the braces. Note that we can only disambiguate when a block state -# mapping is present, otherwise we can't differentiate from an NBT path. -begin: '{{command_token_l}}(?=(\#)?{{resource_path}}(\[ *{{literal}} *\=))' - -end: '{{lookahead_newline}}|(?:(?<=\])(?!\{)|(?<=\}))({{not_command_token_delim}}*)' - -endCaptures: - 1: - name: "#error" - -patterns: - - include: "#block_predicate" diff --git a/lib/src/grammars/patterns/command/token/boolean.yaml b/lib/src/grammars/patterns/command/token/boolean.yaml deleted file mode 100644 index d99d424..0000000 --- a/lib/src/grammars/patterns/command/token/boolean.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.boolean.mcfunction -match: "{{command_token_l}}{{boolean}}{{command_token_r}}" -captures: "#boolean" diff --git a/lib/src/grammars/patterns/command/token/coordinate.yaml b/lib/src/grammars/patterns/command/token/coordinate.yaml deleted file mode 100644 index c851b41..0000000 --- a/lib/src/grammars/patterns/command/token/coordinate.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.coordinate.mcfunction -match: "{{command_token_l}}{{coordinate}}{{command_token_r}}" -captures: "#coordinate" diff --git a/lib/src/grammars/patterns/command/token/fakeplayer.yaml b/lib/src/grammars/patterns/command/token/fakeplayer.yaml deleted file mode 100644 index e066c60..0000000 --- a/lib/src/grammars/patterns/command/token/fakeplayer.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.fakeplayer.mcfunction -match: "{{command_token_l}}{{fakeplayer}}{{command_token_r}}" -captures: "#fakeplayer" diff --git a/lib/src/grammars/patterns/command/token/greedy_parent.yaml b/lib/src/grammars/patterns/command/token/greedy_parent.yaml deleted file mode 100644 index aaa9069..0000000 --- a/lib/src/grammars/patterns/command/token/greedy_parent.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Special case for commands like `say` that consume the rest of the line. -name: meta.command.token.greedy_parent.mcfunction -match: "{{greedy_parent}}(.*)$" -captures: "#greedy_parent" diff --git a/lib/src/grammars/patterns/command/token/literal.yaml b/lib/src/grammars/patterns/command/token/literal.yaml deleted file mode 100644 index 64a2691..0000000 --- a/lib/src/grammars/patterns/command/token/literal.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.literal.mcfunction -match: "{{command_token_l}}{{literal}}{{command_token_r}}" -captures: "#literal" diff --git a/lib/src/grammars/patterns/command/token/nbt_compound.yaml b/lib/src/grammars/patterns/command/token/nbt_compound.yaml deleted file mode 100644 index 00faff5..0000000 --- a/lib/src/grammars/patterns/command/token/nbt_compound.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: meta.command.token.nbt_compound.mcfunction -begin: '{{command_token_l}}(\{)' -end: '{{lookahead_newline}}|(\})({{not_command_token_delim}}*)' -beginCaptures: - 1: - name: "#nbt_delims" -endCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#error" -patterns: - - include: "#nbt.compound" diff --git a/lib/src/grammars/patterns/command/token/nbt_list.yaml b/lib/src/grammars/patterns/command/token/nbt_list.yaml deleted file mode 100644 index b9f2e5e..0000000 --- a/lib/src/grammars/patterns/command/token/nbt_list.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: meta.command.token.nbt_list.mcfunction -begin: '{{command_token_l}}(\[){{nbt_array_type}}' -end: '{{lookahead_newline}}|(\])({{not_command_token_delim}}*)' -beginCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#nbt_array_type" -endCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#error" -patterns: - - include: "#nbt.list" diff --git a/lib/src/grammars/patterns/command/token/nbt_path.yaml b/lib/src/grammars/patterns/command/token/nbt_path.yaml deleted file mode 100644 index b3b2ada..0000000 --- a/lib/src/grammars/patterns/command/token/nbt_path.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: meta.command.token.nbt_path.mcfunction - -# This one is tricky, because we won't know when to start recursing. -# There's also a lot of overlap with other token types, like strings. -# So what we're going to do is require at least one character familiar to -# NBT paths, like dots or opening braces, immediately following a word. -# We use lookahead here so that we can process the syntax more accurately -# after we're more confident that the token is an NBT path. -begin: '{{command_token_l}}(?=\w+[\.\[\{])' - -# It's impossible to know what an NBT path will end on, so apart from being -# careful about newlines like usual we just accept anything. -# end: '{{lookahead_newline}}|({{not_command_token_delim}}*)' -end: "{{command_token_r}}" - -patterns: - - include: "#nbt_path.property" diff --git a/lib/src/grammars/patterns/command/token/number.yaml b/lib/src/grammars/patterns/command/token/number.yaml deleted file mode 100644 index 05323d3..0000000 --- a/lib/src/grammars/patterns/command/token/number.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.number.mcfunction -match: "{{command_token_l}}{{number}}{{command_token_r}}" -captures: "#number" diff --git a/lib/src/grammars/patterns/command/token/operation.yaml b/lib/src/grammars/patterns/command/token/operation.yaml deleted file mode 100644 index 1df38fd..0000000 --- a/lib/src/grammars/patterns/command/token/operation.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.operation.mcfunction -match: "{{command_token_l}}{{operation}}{{command_token_r}}" -captures: "#operation" diff --git a/lib/src/grammars/patterns/command/token/quoted_string.yaml b/lib/src/grammars/patterns/command/token/quoted_string.yaml deleted file mode 100644 index f6a802f..0000000 --- a/lib/src/grammars/patterns/command/token/quoted_string.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# quoted strings are a recursive format captured between the quotes -name: meta.command.token.quoted_string.mcfunction - -# begin whenever we see a quote -begin: '{{command_token_l}}(\")' - -# End on anything. This is tricky. If we got to this point, it means the -# child scope has been terminated. According to the child scope, the only -# things that can get us here are an unescaped quote or a newline (which -# cannot be escaped). Also make sure to mark anything following an ending -# quote to the next token delimiter as an error. -end: '{{lookahead_newline}}|(\")({{not_command_token_delim}}*)' - -beginCaptures: - 1: - name: "#quoted_string" - -endCaptures: - 1: - name: "#quoted_string" - 2: - name: "#error" - -patterns: - - include: "#common.quoted_string" diff --git a/lib/src/grammars/patterns/command/token/range.yaml b/lib/src/grammars/patterns/command/token/range.yaml deleted file mode 100644 index 9df04c6..0000000 --- a/lib/src/grammars/patterns/command/token/range.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.range.mcfunction -match: "{{command_token_l}}{{range}}{{command_token_r}}" -captures: "#range" diff --git a/lib/src/grammars/patterns/command/token/resource_location.yaml b/lib/src/grammars/patterns/command/token/resource_location.yaml deleted file mode 100644 index 79b6f97..0000000 --- a/lib/src/grammars/patterns/command/token/resource_location.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.resource_location.mcfunction -match: "{{command_token_l}}{{resource_location}}{{command_token_r}}" -captures: "#resource_location" diff --git a/lib/src/grammars/patterns/command/token/root_redirect.yaml b/lib/src/grammars/patterns/command/token/root_redirect.yaml deleted file mode 100644 index 5916ac3..0000000 --- a/lib/src/grammars/patterns/command/token/root_redirect.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Special case for commands like `execute ... run` that redirect to the -# root command. We use this to highlight the top-level command despite it -# not being on its own line. -name: meta.command.token.root_redirect.mcfunction -match: "{{command_token_l}}{{root_redirect}} {{literal}}?{{command_token_r}}" -captures: "#root_redirect" diff --git a/lib/src/grammars/patterns/command/token/selector_with_arguments.yaml b/lib/src/grammars/patterns/command/token/selector_with_arguments.yaml deleted file mode 100644 index f515718..0000000 --- a/lib/src/grammars/patterns/command/token/selector_with_arguments.yaml +++ /dev/null @@ -1,79 +0,0 @@ -name: meta.command.token.selector_with_arguments.mcfunction - -# Begin whenever we see a base selector followed by an opening square brace. -begin: '{{command_token_l}}{{base_selector}}(\[)' - -# Similar to quotes, we have two distinct ending cases. -# 1. End on a newline, without consuming it. This is technically an error -# case, but will occur frequently with unfinished selectors; e.g. while -# the user is typing a selector at the end of a line. -# 2. End on any other character, although according to the child scope it -# should only ever be a closing square brace. The child scope does not -# consume the closing brace, and so it becomes our job to check for -# erroneous trailing data and to advance the next token. -end: '{{lookahead_newline}}|(\])({{not_command_token_delim}}*)' - -beginCaptures: - 1: - name: "#base_selector" - 2: - name: "#selector_delims" - -endCaptures: - 1: - name: "#selector_delims" - 2: - name: "#error" - -patterns: - # consume whitespace in between arguments - - name: meta.selector.argument_spacing.mcfunction - match: " +" - # now the fun part: recurse yet again whenever we encounter an argument - - name: meta.selector.argument.mcfunction - - # Begin as soon as we see a key, equals, and optional negation operator. - begin: '{{maybe_quoted_key}} *(\=) *(\!)? *' - - # End in three distinct cases: - # 1. Comma followed immediately by a terminal. Consume the comma, but - # not the terminal. This is an error case. - # 2. Just a comma. This is the expected case and we can proceed fine. - # 3. just a terminal. Also an error case. - end: '( *\,)(?=[\]\n])|( *\,)|(?= *[\]\n])' - - beginCaptures: - 1: - # the key - name: "#argument_key" - 2: - # the `=` - name: "#selector_delims" - 3: - # the optional `!` - name: "keyword.control.mcfunction" - - endCaptures: - 1: - # the `,` in invalid case (1) - name: "#error" - 2: - # the `,` in valid case (2) - name: "#selector_delims" - - patterns: - - include: "#selector.argument.resource_location" - - include: "#selector.argument.tagged_resource_location" - - include: "#selector.argument.range" - - include: "#selector.argument.number" - - include: "#selector.argument.boolean" - - include: "#selector.argument.property_map" - - include: "#selector.argument.nbt_compound" - - include: "#selector.argument.quoted_string" - - include: "#selector.argument.single_quoted_string" - - include: "#selector.argument.unquoted_string" - - include: "#selector.argument.unknown" - - # anything else apart from terminals is classified as an error - - name: "#error" - match: '[^\]\n]+' diff --git a/lib/src/grammars/patterns/command/token/selector_without_arguments.yaml b/lib/src/grammars/patterns/command/token/selector_without_arguments.yaml deleted file mode 100644 index 509f852..0000000 --- a/lib/src/grammars/patterns/command/token/selector_without_arguments.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.selector_without_arguments.mcfunction -match: "{{command_token_l}}{{base_selector}}{{command_token_r}}" -captures: "#selector_without_arguments" diff --git a/lib/src/grammars/patterns/command/token/single_quoted_string.yaml b/lib/src/grammars/patterns/command/token/single_quoted_string.yaml deleted file mode 100644 index 2f64102..0000000 --- a/lib/src/grammars/patterns/command/token/single_quoted_string.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: meta.command.token.single_quoted_string.mcfunction -begin: "{{command_token_l}}(\\')" -end: "{{lookahead_newline}}|(\\')({{not_command_token_delim}}*)" -beginCaptures: - 1: - name: "#quoted_string" -endCaptures: - 1: - name: "#quoted_string" - 2: - name: "#error" -patterns: - - include: "#common.single_quoted_string" diff --git a/lib/src/grammars/patterns/command/token/tagged_resource_location.yaml b/lib/src/grammars/patterns/command/token/tagged_resource_location.yaml deleted file mode 100644 index b88b82e..0000000 --- a/lib/src/grammars/patterns/command/token/tagged_resource_location.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.tagged_resource_location.mcfunction -match: "{{command_token_l}}{{tagged_resource_location}}{{command_token_r}}" -captures: "#tagged_resource_location" diff --git a/lib/src/grammars/patterns/command/token/unknown.yaml b/lib/src/grammars/patterns/command/token/unknown.yaml deleted file mode 100644 index 4813360..0000000 --- a/lib/src/grammars/patterns/command/token/unknown.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: meta.command.token.unknown.mcfunction -match: '{{command_token_l}}([^ \n]*){{command_token_r}}' -captures: - 1: - name: "#unknown" diff --git a/lib/src/grammars/patterns/command/token/unquoted_string.yaml b/lib/src/grammars/patterns/command/token/unquoted_string.yaml deleted file mode 100644 index 16626d0..0000000 --- a/lib/src/grammars/patterns/command/token/unquoted_string.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.unquoted_string.mcfunction -match: "{{command_token_l}}{{unquoted_string}}{{command_token_r}}" -captures: "#unquoted_string" diff --git a/lib/src/grammars/patterns/command/token/uuid.yaml b/lib/src/grammars/patterns/command/token/uuid.yaml deleted file mode 100644 index f6243c8..0000000 --- a/lib/src/grammars/patterns/command/token/uuid.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.command.token.uuid.mcfunction -match: "{{command_token_l}}{{uuid}}{{command_token_r}}" -captures: "#uuid" diff --git a/lib/src/grammars/patterns/command/tokens.yaml b/lib/src/grammars/patterns/command/tokens.yaml deleted file mode 100644 index f8c6049..0000000 --- a/lib/src/grammars/patterns/command/tokens.yaml +++ /dev/null @@ -1,24 +0,0 @@ -patterns: - - include: "#command.token.nbt_compound" - - include: "#command.token.nbt_list" - - include: "#command.token.selector_with_arguments" - - include: "#command.token.selector_without_arguments" - - include: "#command.token.block_predicate" - - include: "#command.token.block_predicate_without_namespace" - - include: "#command.token.resource_location" - - include: "#command.token.tagged_resource_location" - - include: "#command.token.range" - - include: "#command.token.number" - - include: "#command.token.coordinate" - - include: "#command.token.boolean" - - include: "#command.token.operation" - - include: "#command.token.root_redirect" - - include: "#command.token.greedy_parent" - - include: "#command.token.literal" - - include: "#command.token.uuid" - - include: "#command.token.fakeplayer" - - include: "#command.token.nbt_path" - - include: "#command.token.quoted_string" - - include: "#command.token.single_quoted_string" - - include: "#command.token.unquoted_string" - - include: "#command.token.unknown" diff --git a/lib/src/grammars/patterns/command_tokens.yaml b/lib/src/grammars/patterns/command_tokens.yaml new file mode 100644 index 0000000..b1f6d82 --- /dev/null +++ b/lib/src/grammars/patterns/command_tokens.yaml @@ -0,0 +1,6 @@ +patterns: + - name: "#command_token.integer" + match: "{{integer}}{{TT}}" + + - name: "#command_token.unknown" + match: '\S+{{TT}}' diff --git a/lib/src/grammars/patterns/comment.yaml b/lib/src/grammars/patterns/comment.yaml deleted file mode 100644 index 824de53..0000000 --- a/lib/src/grammars/patterns/comment.yaml +++ /dev/null @@ -1,33 +0,0 @@ -patterns: - # enter into block comments via alternate comment style - - name: meta.comment.block.mcfunction - - # must begin with unique prefix - begin: '^[ \t]*((#)({{block_comment_prefix}})((.*)))$' - - # end on any line that is not a comment, without consuming anything - # should only get here when an adjacent comment was not found - # this allows the inner block comment loop to run-off - end: '^(?![ \t]*#)' - - beginCaptures: - 1: - name: "#block_comment" - 2: - name: "#block_comment_symbol" - 3: - name: "#block_comment_prefix" - 4: - name: "#block_comment_heading_1" - 5: - name: "#block_comment_heading_2" - - patterns: - - include: "#comment.block" - - # any other type of comment gets caught here - - name: meta.comment.line.mcfunction - match: '^[ \t]*(#.*)$' - captures: - 1: - name: comment.line.mcfunction diff --git a/lib/src/grammars/patterns/comment/block.yaml b/lib/src/grammars/patterns/comment/block.yaml deleted file mode 100644 index 5f9825c..0000000 --- a/lib/src/grammars/patterns/comment/block.yaml +++ /dev/null @@ -1,13 +0,0 @@ -patterns: - # match any type of comment attached to the block - - name: meta.comment.block_line.mcfunction - begin: '^[ \t]*((#)[ \t]*)' - end: "$" - beginCaptures: - 1: - name: "#block_comment" - 2: - name: "#block_comment_symbol" - patterns: - - include: "#comment.block.line" - # otherwise, break from the block loop diff --git a/lib/src/grammars/patterns/comment/block/line.yaml b/lib/src/grammars/patterns/comment/block/line.yaml deleted file mode 100644 index e499420..0000000 --- a/lib/src/grammars/patterns/comment/block/line.yaml +++ /dev/null @@ -1,32 +0,0 @@ -patterns: - # TODO Move this to a separate grammar with more features for block comments. - # doc tags like `@params` and `@returns` - - name: meta.comment.block.annotation.mcfunction - match: '((\@\w*)\b(.*))$' - captures: - 1: - name: "#block_comment" - 2: - name: "#block_comment_annotation_label" - 3: - name: "#block_comment_annotation_text" - - # block headers within blocks - - name: meta.comment.block.heading.mcfunction - match: "(({{block_comment_prefix}})((.*)))$" - captures: - 1: - name: "#block_comment" - 2: - name: "#block_comment_prefix" - 3: - name: "#block_comment_heading_1" - 4: - name: "#block_comment_heading_2" - - # otherwise its just a comment - - name: meta.comment.block.text.mcfunction - match: "(.*)$" - captures: - 1: - name: "#block_comment" diff --git a/lib/src/grammars/patterns/common/quoted_string.yaml b/lib/src/grammars/patterns/common/quoted_string.yaml deleted file mode 100644 index 5b1a5b1..0000000 --- a/lib/src/grammars/patterns/common/quoted_string.yaml +++ /dev/null @@ -1,11 +0,0 @@ -patterns: - # consume everything except for backslashes, quotes, and newlines - - match: '[^\\\"\n]' - name: "#quoted_string" - # consume any escaped characters... except for newlines - - match: '\\[^\n]' - name: "#quoted_string_escape" - # consume a single backslash (implicitly followed by a newline) as an error - - match: '\\' - name: "#error" - # anything else will be handed back to the parent scope diff --git a/lib/src/grammars/patterns/common/single_quoted_string.yaml b/lib/src/grammars/patterns/common/single_quoted_string.yaml deleted file mode 100644 index 22a6123..0000000 --- a/lib/src/grammars/patterns/common/single_quoted_string.yaml +++ /dev/null @@ -1,7 +0,0 @@ -patterns: - - match: "[^\\\\\\'\\n]" - name: "#quoted_string" - - match: '\\[^\n]' - name: "#quoted_string_escape" - - match: '\\' - name: "#error" diff --git a/lib/src/grammars/patterns/nbt/compound.yaml b/lib/src/grammars/patterns/nbt/compound.yaml deleted file mode 100644 index 8b75670..0000000 --- a/lib/src/grammars/patterns/nbt/compound.yaml +++ /dev/null @@ -1,28 +0,0 @@ -patterns: - # skip whitespace: {( )SelectedItem : { Count : 64 } } - - match: " +" - - # quoted keys: { ("text") (:) "hello" } - # unquoted keys: { (SelectedItem) (:) { Count: 64 } } - - begin: '(,)? *({{unquoted_word_nc}}|\"[^\n\"]+\") *(\:) *' - - # Possible ending cases: - # 1. the closing brace of the parent compound - # 2. the comma separating the next element - # 3. newline (error case) - end: ' *(?=[\n\}\,])' - - beginCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#nbt_key" - 3: - name: "#nbt_delims" - - patterns: - - include: "#nbt.value" - - # anything else apart from separators and terminals is an error - - match: '[^\n\}\,]+' - name: "#error" diff --git a/lib/src/grammars/patterns/nbt/list.yaml b/lib/src/grammars/patterns/nbt/list.yaml deleted file mode 100644 index cbba610..0000000 --- a/lib/src/grammars/patterns/nbt/list.yaml +++ /dev/null @@ -1,23 +0,0 @@ -patterns: - # skip whitespace: [( )1 , 2 , 3] - - match: " +" - - # values: [ 1 (,) (2) , 3] - # begin on anything that is not a terminal or separator - - begin: '(,)? *(?=[^\n\]\,])' - - # Possible ending cases: - # 1. the closing brace of the parent compound - # 2. the comma separating the next element - # 3. newline (error case) - end: ' *(?=[\n\]\,])' - - beginCaptures: - 1: - name: "#nbt_delims" - - patterns: - - include: "#nbt.value" - - - match: '[^\n\]\,]+' - name: "#error" diff --git a/lib/src/grammars/patterns/nbt/value.yaml b/lib/src/grammars/patterns/nbt/value.yaml deleted file mode 100644 index 5d3e9df..0000000 --- a/lib/src/grammars/patterns/nbt/value.yaml +++ /dev/null @@ -1,51 +0,0 @@ -patterns: - - begin: '(\{)' - end: '{{lookahead_newline}}|(\})' - beginCaptures: - 1: - name: "#nbt_delims" - endCaptures: - 1: - name: "#nbt_delims" - patterns: - - include: "#nbt.compound" - - begin: '(\[){{nbt_array_type}}' - end: '{{lookahead_newline}}|(\])' - beginCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#nbt_array_type" - endCaptures: - 1: - name: "#nbt_delims" - patterns: - - include: "#nbt.list" - - begin: '(\")' - end: '{{lookahead_newline}}|(\")' - beginCaptures: - 1: - name: "#quoted_string" - endCaptures: - 1: - name: "#quoted_string" - patterns: - - include: "#common.quoted_string" - - begin: "(\\')" - end: "{{lookahead_newline}}|(\\')" - beginCaptures: - 1: - name: "#quoted_string" - endCaptures: - 1: - name: "#quoted_string" - patterns: - - include: "#common.single_quoted_string" - - match: "{{boolean}}" - name: "#boolean" - - match: "{{number}}" - name: "#numeric_constant" - - match: "{{nbt_unquoted_string}}" - name: "#unquoted_string" - - match: '[^\n\,\]\}]+' - name: "#error" diff --git a/lib/src/grammars/patterns/nbt_path/index.yaml b/lib/src/grammars/patterns/nbt_path/index.yaml deleted file mode 100644 index 43c3cb2..0000000 --- a/lib/src/grammars/patterns/nbt_path/index.yaml +++ /dev/null @@ -1,17 +0,0 @@ -patterns: - - match: '(?<=\[){{integer}}(?=\])' - captures: "#integer" - - begin: '(\{)' - end: '{{lookahead_newline}}|(\})([^\]\,\n]*)' - beginCaptures: - 1: - name: "#nbt_delims" - endCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#error" - patterns: - - include: "#nbt.compound" - - match: '[^\n\]]+' - name: "#error" diff --git a/lib/src/grammars/patterns/nbt_path/property.yaml b/lib/src/grammars/patterns/nbt_path/property.yaml deleted file mode 100644 index 7dae288..0000000 --- a/lib/src/grammars/patterns/nbt_path/property.yaml +++ /dev/null @@ -1,61 +0,0 @@ -patterns: - # (Inventory)([){Count: 64}(]) - - begin: '(\.)?(\w+)?(\[)' - end: '(\])|(?=\n)' - beginCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#nbt_key" - 3: - name: "#nbt_delims" - endCaptures: - 1: - name: "#nbt_delims" - patterns: - - include: "#nbt_path.index" - # Inventory[].(tag)({)custom: true(}).display.Name - - begin: '(\.)?(\w+)(\{)' - end: '(\})|(?=\n)' - beginCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#nbt_key" - 3: - name: "#nbt_delims" - endCaptures: - 1: - name: "#nbt_delims" - patterns: - - include: "#nbt.compound" - # SelectedItem.tag(."my quoted key") - - begin: '(\")' - # Anything other than a dot, space, or newline immediately following the quote is invalid. - end: '{{lookahead_newline}}|(\")([^\. \n]*)' - beginCaptures: - 1: - name: "#quoted_string" - endCaptures: - 1: - name: "#quoted_string" - 2: - name: "#error" - patterns: - - include: "#common.quoted_string" - # SelectedItem(.Count) - - match: '(\.)?(\w+)' - captures: - 1: - name: "#nbt_delims" - 2: - name: "#nbt_key" - # (error) look-ahead double dot - - match: '(\.)(?=\.)' - captures: - 1: - name: "#error" - # anything else between dots is an error - # make sure to break before newlines - - match: '[^\.\s]+' - name: "#error" diff --git a/lib/src/grammars/patterns/property_map.yaml b/lib/src/grammars/patterns/property_map.yaml deleted file mode 100644 index 6c74f4b..0000000 --- a/lib/src/grammars/patterns/property_map.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# for `advancements` and `scores` in selectors -patterns: - # skip whitespace - - match: " +" - - # try for things that look like scores first - - begin: '(,)? *{{scoreboard_objective}} *(\=) *' - end: ' *(?=[\n\}\,])' - beginCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#scoreboard_objective" - 3: - name: "#nbt_delims" - patterns: - - include: "#property_map.values" - - # then try for resource locations (advancements) - # with namespace: {minecraft:story/form_obsidian=true} - # without namespace: {story/form_obsidian=true} - - begin: '(,)? *({{resource_location_nc}}|{{resource_path_nc}}) *(\=) *' - end: ' *(?=[\n\}\,])' - beginCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#resource_path" - 3: - name: "#nbt_delims" - patterns: - - include: "#property_map.values" - - # anything else apart from separators and terminals is an error - - match: '[^\n\}\,]+' - name: "#error" diff --git a/lib/src/grammars/patterns/property_map/values.yaml b/lib/src/grammars/patterns/property_map/values.yaml deleted file mode 100644 index e89f9a2..0000000 --- a/lib/src/grammars/patterns/property_map/values.yaml +++ /dev/null @@ -1,19 +0,0 @@ -patterns: - - match: "{{boolean}}" - captures: "#boolean" - - match: "{{range}}" - captures: "#range" - - match: "{{number}}" - captures: "#number" - - begin: '(\{) *' - end: '{{lookahead_newline}}|(\}) *([^\}\,\n]*)' - beginCaptures: - 1: - name: "#nbt_delims" - endCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#error" - patterns: - - include: "#property_map" diff --git a/lib/src/grammars/patterns/root.yaml b/lib/src/grammars/patterns/root.yaml new file mode 100644 index 0000000..2183878 --- /dev/null +++ b/lib/src/grammars/patterns/root.yaml @@ -0,0 +1,34 @@ +patterns: + # Look for root commands. + - name: "#root_command" + # Root commands are anchored to the start of a line, with optional leading + # space. + match: "{{LLS}}{{literal}}{{TT}}" + + # Look for comments. + - name: "#comment" + + # Comments are anchored to the start of a line in the same way as root + # commands. Note that we intentionally leave the comment character for + # the child patterns to consume. + begin: "{{LLS}}(?=#)" + + # Stop at the end of a line. The child patterns will hand one back to us + # when they detect that there is no comment on the following line. We leave + # the newline for the whitespace pattern to consume. + end: "{{LR}}" + + patterns: + # Consume everything up to, but not including, the end of the line. + - match: ".+" + + # Consume a new line, but only if it eventually starts with a comment + # character. + - match: "{{LLS}}#" + + # Consume any whitespace left over in between other patterns. + - name: "#whitespace" + match: '\s' + + # Anything else is expected to be one of many possible command tokens. + - include: "#command_tokens" diff --git a/lib/src/grammars/patterns/selector/argument/boolean.yaml b/lib/src/grammars/patterns/selector/argument/boolean.yaml deleted file mode 100644 index 3c5e719..0000000 --- a/lib/src/grammars/patterns/selector/argument/boolean.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.selector.argument.boolean.mcfunction -match: "{{boolean}}{{sat}}" -captures: "#boolean" diff --git a/lib/src/grammars/patterns/selector/argument/nbt_compound.yaml b/lib/src/grammars/patterns/selector/argument/nbt_compound.yaml deleted file mode 100644 index a96eff4..0000000 --- a/lib/src/grammars/patterns/selector/argument/nbt_compound.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: meta.selector.argument.nbt_compound.mcfunction -begin: '(\{)' -end: '{{lookahead_newline}}|(\}) *([^\]\,\n]*)' -beginCaptures: - 1: - name: "#nbt_delims" -endCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#error" -patterns: - - include: "#nbt.compound" diff --git a/lib/src/grammars/patterns/selector/argument/number.yaml b/lib/src/grammars/patterns/selector/argument/number.yaml deleted file mode 100644 index 373f63b..0000000 --- a/lib/src/grammars/patterns/selector/argument/number.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.selector.argument.number.mcfunction -match: "{{number}}{{sat}}" -captures: "#number" diff --git a/lib/src/grammars/patterns/selector/argument/property_map.yaml b/lib/src/grammars/patterns/selector/argument/property_map.yaml deleted file mode 100644 index 55aa01b..0000000 --- a/lib/src/grammars/patterns/selector/argument/property_map.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: meta.selector.argument.property_map.mcfunction -# we need to try and distinguish this from an nbt argument -# lookahead for something unique to advancements/scores -# (how about we just copy-paste thee capturing part of the property map?) -begin: '(\{)(?= *({{resource_location_nc}}|{{resource_path_nc}}|{{scoreboard_objective}}) *(\=))' -end: '{{lookahead_newline}}|(\}) *([^\]\,\n]*)' -beginCaptures: - 1: - name: "#nbt_delims" -endCaptures: - 1: - name: "#nbt_delims" - 2: - name: "#error" -patterns: - - include: "#property_map" diff --git a/lib/src/grammars/patterns/selector/argument/quoted_string.yaml b/lib/src/grammars/patterns/selector/argument/quoted_string.yaml deleted file mode 100644 index f719166..0000000 --- a/lib/src/grammars/patterns/selector/argument/quoted_string.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: meta.selector.argument.quoted_string.mcfunction -begin: '(\")' -end: '{{lookahead_newline}}|(\") *([^\]\,\n]*)' -beginCaptures: - 1: - name: "#quoted_string" -endCaptures: - 1: - name: "#quoted_string" - 2: - # anything trailing after the quote, apart from whitespace terminals, is an error - name: "#error" -patterns: - - include: "#common.quoted_string" diff --git a/lib/src/grammars/patterns/selector/argument/range.yaml b/lib/src/grammars/patterns/selector/argument/range.yaml deleted file mode 100644 index da332d2..0000000 --- a/lib/src/grammars/patterns/selector/argument/range.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.selector.argument.range.mcfunction -match: "{{range}}{{sat}}" -captures: "#range" diff --git a/lib/src/grammars/patterns/selector/argument/resource_location.yaml b/lib/src/grammars/patterns/selector/argument/resource_location.yaml deleted file mode 100644 index d29950c..0000000 --- a/lib/src/grammars/patterns/selector/argument/resource_location.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.selector.argument.resource_location.mcfunction -match: "{{resource_location}}{{sat}}" -captures: "#resource_location" diff --git a/lib/src/grammars/patterns/selector/argument/single_quoted_string.yaml b/lib/src/grammars/patterns/selector/argument/single_quoted_string.yaml deleted file mode 100644 index a3ad0eb..0000000 --- a/lib/src/grammars/patterns/selector/argument/single_quoted_string.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: meta.selector.argument.single_quoted_string.mcfunction -begin: "(\\')" -end: "{{lookahead_newline}}|(\\') *([^\\]\\,\\n]*)" -beginCaptures: - 1: - name: "#quoted_string" -endCaptures: - 1: - name: "#quoted_string" - 2: - name: "#error" -patterns: - - include: "#common.single_quoted_string" diff --git a/lib/src/grammars/patterns/selector/argument/tagged_resource_location.yaml b/lib/src/grammars/patterns/selector/argument/tagged_resource_location.yaml deleted file mode 100644 index e87fd8d..0000000 --- a/lib/src/grammars/patterns/selector/argument/tagged_resource_location.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.selector.argument.tagged_resource_location.mcfunction -match: "{{tagged_resource_location}}{{sat}}" -captures: "#tagged_resource_location" diff --git a/lib/src/grammars/patterns/selector/argument/unknown.yaml b/lib/src/grammars/patterns/selector/argument/unknown.yaml deleted file mode 100644 index 8c61425..0000000 --- a/lib/src/grammars/patterns/selector/argument/unknown.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: meta.selector.argument.unknown.mcfunction -match: '([^\]\n\,]+)' -captures: - 1: - name: "#unknown" diff --git a/lib/src/grammars/patterns/selector/argument/unquoted_string.yaml b/lib/src/grammars/patterns/selector/argument/unquoted_string.yaml deleted file mode 100644 index 572b692..0000000 --- a/lib/src/grammars/patterns/selector/argument/unquoted_string.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: meta.selector.argument.unquoted_string.mcfunction -match: "{{selector_unquoted_string}}{{sat}}" -captures: "#unquoted_string" diff --git a/lib/src/grammars/patterns/unknown.yaml b/lib/src/grammars/patterns/unknown.yaml deleted file mode 100644 index 4e9292a..0000000 --- a/lib/src/grammars/patterns/unknown.yaml +++ /dev/null @@ -1,6 +0,0 @@ -patterns: - - name: meta.unknown.mcfunction - match: "^(.*)$" - captures: - 1: - name: "#unknown" diff --git a/lib/src/grammars/version-agnostic.yaml b/lib/src/grammars/version-agnostic.yaml index 28f39bf..3cd5861 100644 --- a/lib/src/grammars/version-agnostic.yaml +++ b/lib/src/grammars/version-agnostic.yaml @@ -5,290 +5,37 @@ fileTypes: - mcfunction names: - brace_delims: variable.language.mcfunction - argument_key: variable.other.mcfunction - numeric_constant: constant.numeric.mcfunction - numeric_altered: constant.numeric.mcfunction - range_ellipsis: keyword.control.mcfunction - coordinate_operator: "#numeric_altered" - base_selector: support.class.mcfunction - selector_delims: "#base_selector" - block_predicate_delims: "#brace_delims" - nbt_delims: "#brace_delims" - nbt_array_type: "#brace_delims" - nbt_key: string.interpolated.mcfunction - nbt_index: constant.numeric.mcfunction - resource_namespace: entity.name.function.mcfunction - resource_path: "#resource_namespace" - tagged_resource_namespace: "#resource_namespace" - tagged_resource_path: "#tagged_resource_namespace" - namespace_separator: "#resource_namespace" - scoreboard_objective: "#resource_namespace" - uuid: "#base_selector" - fakeplayer: "#base_selector" - boolean: "#numeric_constant" - operation: "#numeric_constant" - literal: entity.name.mcfunction - unquoted_string: string.unquoted.mcfunction - quoted_string: string.quoted.mcfunction - quoted_string_escape: constant.character.escape.mcfunction - root_redirect: "#literal" - greedy_parent: "#literal" - top_level_command: keyword.control.mcfunction - unknown: invalid.illegal.mcfunction - error: invalid.illegal.mcfunction - block_comment: comment.block.mcfunction - block_comment_symbol: markup.list.mcfunction - block_comment_prefix: markup.list.mcfunction - block_comment_heading_1: markup.bold.mcfunction - block_comment_heading_2: markup.list.mcfunction - block_comment_annotation_label: markup.heading.mcfunction - block_comment_annotation_text: comment.block.mcfunction + # naming convention: ._.. -variables: - lookahead_newline: '(?=\n)' - - command_token_delim: '[ \n]' - not_command_token_delim: '[^ \n]' - - command_token_l: "(?<= )" - command_token_r: '(?=[ \n]|$)' - - selector_argument_terminal: '(?= *[\,\]\n])' - sat: "{{selector_argument_terminal}}" - - block_predicate_argument_terminal: "{{sat}}" - bpat: "{{block_predicate_argument_terminal}}" - - # boolean true/false - boolean: "(true|false)" - - # math/numeric operations - operation: '(\%\=|\*\=|\+\=|\-\=|\/\=|\<|\=|\>|\>\<|\<\=|\>\=)' - - # commands like `execute ... run` that redirect to the root node - root_redirect: "(run)" - - # commands like `say` that consume the rest of the line - greedy_parent: "((?<=^say | say ))" - - # characters for literal subcommands and other strict word-like identifiers - literal: "([a-z_][a-z0-9_]*)" - - # case-insensitive literal or quoted strings (with limited support) - maybe_quoted_key: "((?:[a-z_][a-z0-9_]*)|(?:\"[^\"\n]*\")|(?:\\'[^\\'\n]*\\'))" - - # characters permitted in unquoted string words, like nbt compound keys - unquoted_word_nc: '[A-Za-z0-9_\.\-]+' - unquoted_word: "({{unquoted_word_nc}})" - - # characters permitted in namespaces, resource paths, etc - component_nc: '[a-z0-9_\.\-]+' - component: "({{component_nc}})" - - # an integer or decimal with optional leading digit - number: '(\-?\d*\.?\d+)' - integer: '(\-?\d+)' - - # a resource path is the portion of the resource location following the namespace - resource_path_nc: '[a-z0-9_\.\-\/]+' - resource_path: "({{resource_path_nc}})" - - # resource locations: namespace + path - resource_location_nc: '{{component_nc}}\:{{resource_path_nc}}' - resource_location: '{{component}}(\:){{resource_path}}' - - # uuid format - hex_digit: "[0-9a-fA-F]" - uuid: "({{hex_digit}}+(?:(-){{hex_digit}}+){4})" - - # scorebord objective names - scoreboard_objective: "{{unquoted_word}}" + whitespace: meta._.whitespace.mcfunction + root_command: keyword.control._.root_command.mcfunction + comment: comment._.comment.mcfunction - # unquoted strings are like literals with additional available characters - # basically anything is accepted apart from whitespace - # character ambiguity depends on context - unquoted_string_nc: '\S+' - unquoted_string: "({{unquoted_string_nc}})" - nbt_unquoted_string: '([^\s\{\}\[\]\,\:\=]+)' - selector_unquoted_string: '([^\s\{\}\[\]\,\:\=\!]+)' + command_token.integer: constant.numeric._.integer.command_token.mcfunction + command_token.unknown: string.unquoted._.unknown.command_token.mcfunction - # optional nbt array type declaration - nbt_array_type: "(\\w*;)?" - - # various popular fakeplayer formats - # they'd get classified as unquoted strings anyway - fakeplayer: '([\#\$\%]{{unquoted_string_nc}})' +variables: + # Space + S: '[ \t]*' - # a tagged resource location is a resource location prefaced with `#` - tagged_resource_location: '(\#){{resource_location}}' + # Line Left + LL: '(?:\r\n|\n|^)' - # relative or local coordinate - coordinate: '([\~\^]){{number}}?' + # Line Left with Space + LLS: "{{LL}}{{S}}" - # numeric range - range: '{{number}}?(\.\.){{number}}?' + # Line Right + LR: '(?=\r\n|\n|$)' - # base selectors are defined with a single, lower-case character - base_selector: '(\@[a-z])' + # Token Terminator + TT: '(?=\s|$)' - # prefix following the `#` to initiate a block comment section - block_comment_prefix: '[\#\>\~\!\@\$\%\^\*]+' + literal: "[a-z][a-z0-9_]*" + integer: '\-?\d+' loadPatterns: - comment: comment - comment.block: comment/block - comment.block.line: comment/block/line - command: command - unknown: unknown - command.tokens: command/tokens - command.token.selector_without_arguments: command/token/selector_without_arguments - command.token.resource_location: command/token/resource_location - command.token.tagged_resource_location: command/token/tagged_resource_location - command.token.range: command/token/range - command.token.number: command/token/number - command.token.coordinate: command/token/coordinate - command.token.boolean: command/token/boolean - command.token.operation: command/token/operation - command.token.literal: command/token/literal - command.token.uuid: command/token/uuid - command.token.fakeplayer: command/token/fakeplayer - command.token.unquoted_string: command/token/unquoted_string - command.token.unknown: command/token/unknown - command.token.root_redirect: command/token/root_redirect - command.token.greedy_parent: command/token/greedy_parent - command.token.nbt_compound: command/token/nbt_compound - command.token.nbt_list: command/token/nbt_list - nbt.compound: nbt/compound - nbt.list: nbt/list - nbt.value: nbt/value - command.token.quoted_string: command/token/quoted_string - command.token.single_quoted_string: command/token/single_quoted_string - command.token.block_predicate: command/token/block_predicate - command.token.block_predicate_without_namespace: command/token/block_predicate_without_namespace - command.token.selector_with_arguments: command/token/selector_with_arguments - command.token.nbt_path: command/token/nbt_path - nbt_path.property: nbt_path/property - nbt_path.index: nbt_path/index - block_predicate: block_predicate - block_predicate.arguments: block_predicate/arguments - block_predicate.argument.number: block_predicate/argument/number - block_predicate.argument.boolean: block_predicate/argument/boolean - block_predicate.argument.literal: block_predicate/argument/literal - selector.argument.resource_location: selector/argument/resource_location - selector.argument.tagged_resource_location: selector/argument/tagged_resource_location - selector.argument.range: selector/argument/range - selector.argument.number: selector/argument/number - selector.argument.boolean: selector/argument/boolean - selector.argument.unquoted_string: selector/argument/unquoted_string - selector.argument.unknown: selector/argument/unknown - selector.argument.quoted_string: selector/argument/quoted_string - selector.argument.single_quoted_string: selector/argument/single_quoted_string - selector.argument.property_map: selector/argument/property_map - selector.argument.nbt_compound: selector/argument/nbt_compound - property_map: property_map - property_map.values: property_map/values - common.quoted_string: common/quoted_string - common.single_quoted_string: common/single_quoted_string + root: root + command_tokens: command_tokens patterns: - - include: "#comment" - - include: "#command" - - include: "#unknown" - -capturesRepository: - selector_without_arguments: - 1: - name: "#base_selector" - - resource_path: - 1: - name: "#resource_path" - - resource_location: - 1: - # the namespace - name: "#resource_namespace" - 2: - # the `:` - name: "#namespace_separator" - 3: - # the path - name: "#resource_path" - - tagged_resource_location: - 1: - # the `#` - name: "#tagged_resource_namespace" - 2: - # the namespace - name: "#tagged_resource_namespace" - 3: - # the `:` - name: "#namespace_separator" - 4: - # the path - name: "#tagged_resource_path" - - range: - 1: - # the number on the left side - name: "#numeric_altered" - 2: - # color the `..` differently to distinguish it from decimals - name: "#range_ellipsis" - 3: - # the number on the right side - name: "#numeric_altered" - - number: - 1: - name: "#numeric_constant" - - integer: - 1: - name: "#numeric_constant" - - coordinate: - 1: - # the `~` or `^` - name: "#coordinate_operator" - 2: - # the actual number - name: "#numeric_altered" - - boolean: - 1: - name: "#boolean" - - operation: - 1: - name: "#operation" - - root_redirect: - 1: - name: "#root_redirect" - 2: - name: "#top_level_command" - - greedy_parent: - 1: - name: "#literal" - 2: - name: "#quoted_string" - - literal: - 1: - name: "#literal" - - uuid: - 1: - name: "#uuid" - - fakeplayer: - 1: - name: "#fakeplayer" - - unquoted_string: - 1: - name: "#unquoted_string" + - include: "#root" diff --git a/lib/src/utils.ts b/lib/src/utils.ts index 590591f..607e847 100644 --- a/lib/src/utils.ts +++ b/lib/src/utils.ts @@ -18,18 +18,20 @@ const RECURSE_MAPS = ["captures", "beginCaptures", "endCaptures"]; const RECURSE_LISTS = ["patterns"]; function formatProperty(grammar: any, s: string): string { - if (s.indexOf("{{") < 0) { - return s; - } + const pattern = new RegExp("{{[\\w\\.]+}}", "g"); + const matchResult = [...s.matchAll(pattern)]; let s2 = s; - for (const key in grammar.variables) { - const value = grammar.variables[key]; - if (!value) { - throw Error( - `Grammar "${grammar.name}" -> variables has no item named "${key}"` - ); + for (const matches of matchResult) { + for (const match of matches) { + const name = match.substring(2, match.length - 2); + const variable = grammar.variables[name]; + if (!variable) { + throw Error( + `Grammar "${grammar.name}" -> variables has no item named "${name}"` + ); + } + s2 = s2.replace(new RegExp(match, "g"), variable); } - s2 = s2.replace(new RegExp("{{" + key + "}}", "g"), value); } return s2; } diff --git a/lib/tsconfig.json b/lib/tsconfig.json index 61057b5..217e6fb 100644 --- a/lib/tsconfig.json +++ b/lib/tsconfig.json @@ -1,10 +1,10 @@ { "compilerOptions": { - "target": "es6", + "target": "es2020", "module": "commonjs", "outDir": "out", "rootDir": "src", - "lib": ["es6"], + "lib": ["es2020"], "sourceMap": true }, "include": ["src"], diff --git a/mcfunction.tmLanguage b/mcfunction.tmLanguage index 2ed18cb..f2d90a8 100644 --- a/mcfunction.tmLanguage +++ b/mcfunction.tmLanguage @@ -14,2151 +14,67 @@ include - #comment - - - include - #command - - - include - #unknown + #root repository - comment + root patterns name - meta.comment.block.mcfunction - begin - ^[ \t]*((#)([\#\>\~\!\@\$\%\^\*]+)((.*)))$ - end - ^(?![ \t]*#) - beginCaptures - - 1 - - name - comment.block.mcfunction - - 2 - - name - markup.list.mcfunction - - 3 - - name - markup.list.mcfunction - - 4 - - name - markup.bold.mcfunction - - 5 - - name - markup.list.mcfunction - - - patterns - - - include - #comment.block - - - - - name - meta.comment.line.mcfunction + keyword.control._.root_command.mcfunction match - ^[ \t]*(#.*)$ - captures - - 1 - - name - comment.line.mcfunction - - + (?:\r\n|\n|^)[ \t]*[a-z][a-z0-9_]*(?=\s|$) - - - comment.block - - patterns - name - meta.comment.block_line.mcfunction + comment._.comment.mcfunction begin - ^[ \t]*((#)[ \t]*) + (?:\r\n|\n|^)[ \t]*(?=#) end - $ - beginCaptures - - 1 - - name - comment.block.mcfunction - - 2 - - name - markup.list.mcfunction - - + (?=\r\n|\n|$) patterns - include - #comment.block.line - - - - - - comment.block.line - - patterns - - - name - meta.comment.block.annotation.mcfunction - match - ((\@\w*)\b(.*))$ - captures - - 1 - - name - comment.block.mcfunction - - 2 - - name - markup.heading.mcfunction - - 3 - - name - comment.block.mcfunction - - - - - name - meta.comment.block.heading.mcfunction - match - (([\#\>\~\!\@\$\%\^\*]+)((.*)))$ - captures - - 1 - - name - comment.block.mcfunction - - 2 - - name - markup.list.mcfunction - - 3 - - name - markup.bold.mcfunction + match + .+ - 4 - name - markup.list.mcfunction + match + (?:\r\n|\n|^)[ \t]*# - + name - meta.comment.block.text.mcfunction + meta._.whitespace.mcfunction match - (.*)$ - captures - - 1 - - name - comment.block.mcfunction - - + \s - - - command - - patterns - - name - meta.command.mcfunction - begin - ^\s*([a-z_][a-z0-9_]*)[ \n] - end - $ - beginCaptures - - 1 - - name - keyword.control.mcfunction - - - patterns - - - begin - (?<= ) - end - [ \n] - contentName - meta.command.token.mcfunction - patterns - - - include - #command.tokens - - - - + include + #command_tokens - unknown + command_tokens patterns name - meta.unknown.mcfunction + constant.numeric._.integer.command_token.mcfunction match - ^(.*)$ - captures - - 1 - - name - invalid.illegal.mcfunction - - - - - - command.tokens - - patterns - - - include - #command.token.nbt_compound - - - include - #command.token.nbt_list - - - include - #command.token.selector_with_arguments - - - include - #command.token.selector_without_arguments - - - include - #command.token.block_predicate - - - include - #command.token.block_predicate_without_namespace - - - include - #command.token.resource_location - - - include - #command.token.tagged_resource_location - - - include - #command.token.range - - - include - #command.token.number - - - include - #command.token.coordinate - - - include - #command.token.boolean - - - include - #command.token.operation + \-?\d+(?=\s|$) - - include - #command.token.root_redirect - - - include - #command.token.greedy_parent - - - include - #command.token.literal - - - include - #command.token.uuid - - - include - #command.token.fakeplayer - - - include - #command.token.nbt_path - - - include - #command.token.quoted_string - - - include - #command.token.single_quoted_string - - - include - #command.token.unquoted_string - - - include - #command.token.unknown - - - - command.token.selector_without_arguments - - name - meta.command.token.selector_without_arguments.mcfunction - match - (?<= )(\@[a-z])(?=[ \n]|$) - captures - - 1 - - name - support.class.mcfunction - - - - command.token.resource_location - - name - meta.command.token.resource_location.mcfunction - match - (?<= )([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(?=[ \n]|$) - captures - - 1 - - name - entity.name.function.mcfunction - - 2 - - name - entity.name.function.mcfunction - - 3 - - name - entity.name.function.mcfunction - - - - command.token.tagged_resource_location - - name - meta.command.token.tagged_resource_location.mcfunction - match - (?<= )(\#)([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(?=[ \n]|$) - captures - - 1 - - name - entity.name.function.mcfunction - - 2 - - name - entity.name.function.mcfunction - - 3 - - name - entity.name.function.mcfunction - - 4 - - name - entity.name.function.mcfunction - - - - command.token.range - - name - meta.command.token.range.mcfunction - match - (?<= )(\-?\d*\.?\d+)?(\.\.)(\-?\d*\.?\d+)?(?=[ \n]|$) - captures - - 1 - - name - constant.numeric.mcfunction - - 2 - - name - keyword.control.mcfunction - - 3 - - name - constant.numeric.mcfunction - - - - command.token.number - - name - meta.command.token.number.mcfunction - match - (?<= )(\-?\d*\.?\d+)(?=[ \n]|$) - captures - - 1 - - name - constant.numeric.mcfunction - - - - command.token.coordinate - - name - meta.command.token.coordinate.mcfunction - match - (?<= )([\~\^])(\-?\d*\.?\d+)?(?=[ \n]|$) - captures - - 1 - - name - constant.numeric.mcfunction - - 2 - - name - constant.numeric.mcfunction - - - - command.token.boolean - - name - meta.command.token.boolean.mcfunction - match - (?<= )(true|false)(?=[ \n]|$) - captures - - 1 - - name - constant.numeric.mcfunction - - - - command.token.operation - - name - meta.command.token.operation.mcfunction - match - (?<= )(\%\=|\*\=|\+\=|\-\=|\/\=|\<|\=|\>|\>\<|\<\=|\>\=)(?=[ \n]|$) - captures - - 1 - - name - constant.numeric.mcfunction - - - - command.token.literal - - name - meta.command.token.literal.mcfunction - match - (?<= )([a-z_][a-z0-9_]*)(?=[ \n]|$) - captures - - 1 - - name - entity.name.mcfunction - - - - command.token.uuid - - name - meta.command.token.uuid.mcfunction - match - (?<= )([0-9a-fA-F]+(?:(-)[0-9a-fA-F]+){4})(?=[ \n]|$) - captures - - 1 - - name - support.class.mcfunction - - - - command.token.fakeplayer - - name - meta.command.token.fakeplayer.mcfunction - match - (?<= )([\#\$\%]\S+)(?=[ \n]|$) - captures - - 1 - - name - support.class.mcfunction - - - - command.token.unquoted_string - - name - meta.command.token.unquoted_string.mcfunction - match - (?<= )(\S+)(?=[ \n]|$) - captures - - 1 name - string.unquoted.mcfunction - - - - command.token.unknown - - name - meta.command.token.unknown.mcfunction - match - (?<= )([^ \n]*)(?=[ \n]|$) - captures - - 1 - - name - invalid.illegal.mcfunction - - - - command.token.root_redirect - - name - meta.command.token.root_redirect.mcfunction - match - (?<= )(run) ([a-z_][a-z0-9_]*)?(?=[ \n]|$) - captures - - 1 - - name - entity.name.mcfunction - - 2 - - name - keyword.control.mcfunction - - - - command.token.greedy_parent - - name - meta.command.token.greedy_parent.mcfunction - match - ((?<=^say | say ))(.*)$ - captures - - 1 - - name - entity.name.mcfunction - - 2 - - name - string.quoted.mcfunction - - - - command.token.nbt_compound - - name - meta.command.token.nbt_compound.mcfunction - begin - (?<= )(\{) - end - (?=\n)|(\})([^ \n]*) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #nbt.compound - - - - command.token.nbt_list - - name - meta.command.token.nbt_list.mcfunction - begin - (?<= )(\[)(\w*;)? - end - (?=\n)|(\])([^ \n]*) - beginCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #nbt.list - - - - nbt.compound - - patterns - - - match - + - - - begin - (,)? *([A-Za-z0-9_\.\-]+|\"[^\n\"]+\") *(\:) * - end - *(?=[\n\}\,]) - beginCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - string.interpolated.mcfunction - - 3 - - name - variable.language.mcfunction - - - patterns - - - include - #nbt.value - - - - - match - [^\n\}\,]+ - name - invalid.illegal.mcfunction - - - - nbt.list - - patterns - - - match - + - - - begin - (,)? *(?=[^\n\]\,]) - end - *(?=[\n\]\,]) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - patterns - - - include - #nbt.value - - - - - match - [^\n\]\,]+ - name - invalid.illegal.mcfunction - - - - nbt.value - - patterns - - - begin - (\{) - end - (?=\n)|(\}) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - - patterns - - - include - #nbt.compound - - - - - begin - (\[)(\w*;)? - end - (?=\n)|(\]) - beginCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - - patterns - - - include - #nbt.list - - - - - begin - (\") - end - (?=\n)|(\") - beginCaptures - - 1 - - name - string.quoted.mcfunction - - - endCaptures - - 1 - - name - string.quoted.mcfunction - - - patterns - - - include - #common.quoted_string - - - - - begin - (\') - end - (?=\n)|(\') - beginCaptures - - 1 - - name - string.quoted.mcfunction - - - endCaptures - - 1 - - name - string.quoted.mcfunction - - - patterns - - - include - #common.single_quoted_string - - - - - match - (true|false) - name - constant.numeric.mcfunction - - - match - (\-?\d*\.?\d+) - name - constant.numeric.mcfunction - - - match - ([^\s\{\}\[\]\,\:\=]+) - name - string.unquoted.mcfunction - - - match - [^\n\,\]\}]+ - name - invalid.illegal.mcfunction - - - - command.token.quoted_string - - name - meta.command.token.quoted_string.mcfunction - begin - (?<= )(\") - end - (?=\n)|(\")([^ \n]*) - beginCaptures - - 1 - - name - string.quoted.mcfunction - - - endCaptures - - 1 - - name - string.quoted.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #common.quoted_string - - - - command.token.single_quoted_string - - name - meta.command.token.single_quoted_string.mcfunction - begin - (?<= )(\') - end - (?=\n)|(\')([^ \n]*) - beginCaptures - - 1 - - name - string.quoted.mcfunction - - - endCaptures - - 1 - - name - string.quoted.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #common.single_quoted_string - - - - command.token.block_predicate - - name - meta.command.token.block_predicate.mcfunction - begin - (?<= )(?=(\#)?([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(\[|\{)) - end - (?=\n)|(?:(?<=\])(?!\{)|(?<=\}))([^ \n]*) - endCaptures - - 1 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #block_predicate - - - - command.token.block_predicate_without_namespace - - name - meta.command.token.block_predicate_without_namespace.mcfunction - begin - (?<= )(?=(\#)?([a-z0-9_\.\-\/]+)(\[ *([a-z_][a-z0-9_]*) *\=)) - end - (?=\n)|(?:(?<=\])(?!\{)|(?<=\}))([^ \n]*) - endCaptures - - 1 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #block_predicate - - - - command.token.selector_with_arguments - - name - meta.command.token.selector_with_arguments.mcfunction - begin - (?<= )(\@[a-z])(\[) - end - (?=\n)|(\])([^ \n]*) - beginCaptures - - 1 - - name - support.class.mcfunction - - 2 - - name - support.class.mcfunction - - - endCaptures - - 1 - - name - support.class.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - name - meta.selector.argument_spacing.mcfunction - match - + - - - name - meta.selector.argument.mcfunction - begin - ((?:[a-z_][a-z0-9_]*)|(?:"[^" -]*")|(?:\'[^\' -]*\')) *(\=) *(\!)? * - end - ( *\,)(?=[\]\n])|( *\,)|(?= *[\]\n]) - beginCaptures - - 1 - - name - variable.other.mcfunction - - 2 - - name - support.class.mcfunction - - 3 - - name - keyword.control.mcfunction - - - endCaptures - - 1 - - name - invalid.illegal.mcfunction - - 2 - - name - support.class.mcfunction - - - patterns - - - include - #selector.argument.resource_location - - - include - #selector.argument.tagged_resource_location - - - include - #selector.argument.range - - - include - #selector.argument.number - - - include - #selector.argument.boolean - - - include - #selector.argument.property_map - - - include - #selector.argument.nbt_compound - - - include - #selector.argument.quoted_string - - - include - #selector.argument.single_quoted_string - - - include - #selector.argument.unquoted_string - - - include - #selector.argument.unknown - - - - - name - invalid.illegal.mcfunction - match - [^\]\n]+ - - - - command.token.nbt_path - - name - meta.command.token.nbt_path.mcfunction - begin - (?<= )(?=\w+[\.\[\{]) - end - (?=[ \n]|$) - patterns - - - include - #nbt_path.property - - - - nbt_path.property - - patterns - - - begin - (\.)?(\w+)?(\[) - end - (\])|(?=\n) - beginCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - string.interpolated.mcfunction - - 3 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - - patterns - - - include - #nbt_path.index - - - - - begin - (\.)?(\w+)(\{) - end - (\})|(?=\n) - beginCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - string.interpolated.mcfunction - - 3 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - - patterns - - - include - #nbt.compound - - - - - begin - (\") - end - (?=\n)|(\")([^\. \n]*) - beginCaptures - - 1 - - name - string.quoted.mcfunction - - - endCaptures - - 1 - - name - string.quoted.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #common.quoted_string - - - - - match - (\.)?(\w+) - captures - - 1 - - name - variable.language.mcfunction - - 2 - - name - string.interpolated.mcfunction - - - - - match - (\.)(?=\.) - captures - - 1 - - name - invalid.illegal.mcfunction - - - - - match - [^\.\s]+ - name - invalid.illegal.mcfunction - - - - nbt_path.index - - patterns - - - match - (?<=\[)(\-?\d+)(?=\]) - captures - - 1 - - name - constant.numeric.mcfunction - - - - - begin - (\{) - end - (?=\n)|(\})([^\]\,\n]*) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #nbt.compound - - - - - match - [^\n\]]+ - name - invalid.illegal.mcfunction - - - - block_predicate - - patterns - - - match - (\#)([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+) - captures - - 1 - - name - entity.name.function.mcfunction - - 2 - - name - entity.name.function.mcfunction - - 3 - - name - entity.name.function.mcfunction - - 4 - - name - entity.name.function.mcfunction - - - - - match - ([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+) - captures - - 1 - - name - entity.name.function.mcfunction - - 2 - - name - entity.name.function.mcfunction - - 3 - - name - entity.name.function.mcfunction - - - - - match - ([a-z0-9_\.\-\/]+) - captures - - 1 - - name - entity.name.function.mcfunction - - - - - begin - (\[) - end - (\]) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - - patterns - - - include - #block_predicate.arguments - - - - - begin - (\{) - end - (\}) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - - patterns - - - include - #nbt.compound - - - - - - block_predicate.arguments - - patterns - - - name - meta.block_predicate.argument_spacing.mcfunction - match - + - - - name - meta.block_predicate.argument.mcfunction - begin - ([a-z_][a-z0-9_]*) *(\=) * - end - (\,)(?=[\]\n])|(\,)|(?=[\]\n]) - beginCaptures - - 1 - - name - variable.other.mcfunction - - 2 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - invalid.illegal.mcfunction - - 2 - - name - variable.language.mcfunction - - - patterns - - - include - #block_predicate.argument.number - - - include - #block_predicate.argument.boolean - - - include - #block_predicate.argument.literal - - - - - - block_predicate.argument.number - - name - meta.block_predicate.argument.number.mcfunction - match - (\-?\d*\.?\d+)(?= *[\,\]\n]) - captures - - 1 - - name - constant.numeric.mcfunction - - - - block_predicate.argument.boolean - - name - meta.block_predicate.argument.boolean.mcfunction - match - (true|false)(?= *[\,\]\n]) - captures - - 1 - - name - constant.numeric.mcfunction - - - - block_predicate.argument.literal - - name - meta.block_predicate.argument.literal.mcfunction - match - ([a-z_][a-z0-9_]*)(?= *[\,\]\n]) - captures - - 1 - - name - entity.name.mcfunction - - - - selector.argument.resource_location - - name - meta.selector.argument.resource_location.mcfunction - match - ([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(?= *[\,\]\n]) - captures - - 1 - - name - entity.name.function.mcfunction - - 2 - - name - entity.name.function.mcfunction - - 3 - - name - entity.name.function.mcfunction - - - - selector.argument.tagged_resource_location - - name - meta.selector.argument.tagged_resource_location.mcfunction - match - (\#)([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(?= *[\,\]\n]) - captures - - 1 - - name - entity.name.function.mcfunction - - 2 - - name - entity.name.function.mcfunction - - 3 - - name - entity.name.function.mcfunction - - 4 - - name - entity.name.function.mcfunction - - - - selector.argument.range - - name - meta.selector.argument.range.mcfunction - match - (\-?\d*\.?\d+)?(\.\.)(\-?\d*\.?\d+)?(?= *[\,\]\n]) - captures - - 1 - - name - constant.numeric.mcfunction - - 2 - - name - keyword.control.mcfunction - - 3 - - name - constant.numeric.mcfunction - - - - selector.argument.number - - name - meta.selector.argument.number.mcfunction - match - (\-?\d*\.?\d+)(?= *[\,\]\n]) - captures - - 1 - - name - constant.numeric.mcfunction - - - - selector.argument.boolean - - name - meta.selector.argument.boolean.mcfunction - match - (true|false)(?= *[\,\]\n]) - captures - - 1 - - name - constant.numeric.mcfunction - - - - selector.argument.unquoted_string - - name - meta.selector.argument.unquoted_string.mcfunction - match - ([^\s\{\}\[\]\,\:\=\!]+)(?= *[\,\]\n]) - captures - - 1 - - name - string.unquoted.mcfunction - - - - selector.argument.unknown - - name - meta.selector.argument.unknown.mcfunction - match - ([^\]\n\,]+) - captures - - 1 - - name - invalid.illegal.mcfunction - - - - selector.argument.quoted_string - - name - meta.selector.argument.quoted_string.mcfunction - begin - (\") - end - (?=\n)|(\") *([^\]\,\n]*) - beginCaptures - - 1 - - name - string.quoted.mcfunction - - - endCaptures - - 1 - - name - string.quoted.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #common.quoted_string - - - - selector.argument.single_quoted_string - - name - meta.selector.argument.single_quoted_string.mcfunction - begin - (\') - end - (?=\n)|(\') *([^\]\,\n]*) - beginCaptures - - 1 - - name - string.quoted.mcfunction - - - endCaptures - - 1 - - name - string.quoted.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #common.single_quoted_string - - - - selector.argument.property_map - - name - meta.selector.argument.property_map.mcfunction - begin - (\{)(?= *([a-z0-9_\.\-]+\:[a-z0-9_\.\-\/]+|[a-z0-9_\.\-\/]+|([A-Za-z0-9_\.\-]+)) *(\=)) - end - (?=\n)|(\}) *([^\]\,\n]*) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #property_map - - - - selector.argument.nbt_compound - - name - meta.selector.argument.nbt_compound.mcfunction - begin - (\{) - end - (?=\n)|(\}) *([^\]\,\n]*) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #nbt.compound - - - - property_map - - patterns - - - match - + - - - begin - (,)? *([A-Za-z0-9_\.\-]+) *(\=) * - end - *(?=[\n\}\,]) - beginCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - entity.name.function.mcfunction - - 3 - - name - variable.language.mcfunction - - - patterns - - - include - #property_map.values - - - - - begin - (,)? *([a-z0-9_\.\-]+\:[a-z0-9_\.\-\/]+|[a-z0-9_\.\-\/]+) *(\=) * - end - *(?=[\n\}\,]) - beginCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - entity.name.function.mcfunction - - 3 - - name - variable.language.mcfunction - - - patterns - - - include - #property_map.values - - - - - match - [^\n\}\,]+ - name - invalid.illegal.mcfunction - - - - property_map.values - - patterns - - - match - (true|false) - captures - - 1 - - name - constant.numeric.mcfunction - - - - - match - (\-?\d*\.?\d+)?(\.\.)(\-?\d*\.?\d+)? - captures - - 1 - - name - constant.numeric.mcfunction - - 2 - - name - keyword.control.mcfunction - - 3 - - name - constant.numeric.mcfunction - - - - - match - (\-?\d*\.?\d+) - captures - - 1 - - name - constant.numeric.mcfunction - - - - - begin - (\{) * - end - (?=\n)|(\}) *([^\}\,\n]*) - beginCaptures - - 1 - - name - variable.language.mcfunction - - - endCaptures - - 1 - - name - variable.language.mcfunction - - 2 - - name - invalid.illegal.mcfunction - - - patterns - - - include - #property_map - - - - - - common.quoted_string - - patterns - - - match - [^\\\"\n] - name - string.quoted.mcfunction - - - match - \\[^\n] - name - constant.character.escape.mcfunction - - - match - \\ - name - invalid.illegal.mcfunction - - - - common.single_quoted_string - - patterns - - - match - [^\\\'\n] - name - string.quoted.mcfunction - - - match - \\[^\n] - name - constant.character.escape.mcfunction - - + string.unquoted._.unknown.command_token.mcfunction match - \\ - name - invalid.illegal.mcfunction + \S+(?=\s|$) diff --git a/mcfunction.tmLanguage.json b/mcfunction.tmLanguage.json index 2863e8b..f326dd2 100644 --- a/mcfunction.tmLanguage.json +++ b/mcfunction.tmLanguage.json @@ -6,1378 +6,47 @@ ], "patterns": [ { - "include": "#comment" - }, - { - "include": "#command" - }, - { - "include": "#unknown" + "include": "#root" } ], "repository": { - "comment": { - "patterns": [ - { - "name": "meta.comment.block.mcfunction", - "begin": "^[ \\t]*((#)([\\#\\>\\~\\!\\@\\$\\%\\^\\*]+)((.*)))$", - "end": "^(?![ \\t]*#)", - "beginCaptures": { - "1": { - "name": "comment.block.mcfunction" - }, - "2": { - "name": "markup.list.mcfunction" - }, - "3": { - "name": "markup.list.mcfunction" - }, - "4": { - "name": "markup.bold.mcfunction" - }, - "5": { - "name": "markup.list.mcfunction" - } - }, - "patterns": [ - { - "include": "#comment.block" - } - ] - }, - { - "name": "meta.comment.line.mcfunction", - "match": "^[ \\t]*(#.*)$", - "captures": { - "1": { - "name": "comment.line.mcfunction" - } - } - } - ] - }, - "comment.block": { - "patterns": [ - { - "name": "meta.comment.block_line.mcfunction", - "begin": "^[ \\t]*((#)[ \\t]*)", - "end": "$", - "beginCaptures": { - "1": { - "name": "comment.block.mcfunction" - }, - "2": { - "name": "markup.list.mcfunction" - } - }, - "patterns": [ - { - "include": "#comment.block.line" - } - ] - } - ] - }, - "comment.block.line": { - "patterns": [ - { - "name": "meta.comment.block.annotation.mcfunction", - "match": "((\\@\\w*)\\b(.*))$", - "captures": { - "1": { - "name": "comment.block.mcfunction" - }, - "2": { - "name": "markup.heading.mcfunction" - }, - "3": { - "name": "comment.block.mcfunction" - } - } - }, - { - "name": "meta.comment.block.heading.mcfunction", - "match": "(([\\#\\>\\~\\!\\@\\$\\%\\^\\*]+)((.*)))$", - "captures": { - "1": { - "name": "comment.block.mcfunction" - }, - "2": { - "name": "markup.list.mcfunction" - }, - "3": { - "name": "markup.bold.mcfunction" - }, - "4": { - "name": "markup.list.mcfunction" - } - } - }, - { - "name": "meta.comment.block.text.mcfunction", - "match": "(.*)$", - "captures": { - "1": { - "name": "comment.block.mcfunction" - } - } - } - ] - }, - "command": { - "patterns": [ - { - "name": "meta.command.mcfunction", - "begin": "^\\s*([a-z_][a-z0-9_]*)[ \\n]", - "end": "$", - "beginCaptures": { - "1": { - "name": "keyword.control.mcfunction" - } - }, - "patterns": [ - { - "begin": "(?<= )", - "end": "[ \\n]", - "contentName": "meta.command.token.mcfunction", - "patterns": [ - { - "include": "#command.tokens" - } - ] - } - ] - } - ] - }, - "unknown": { - "patterns": [ - { - "name": "meta.unknown.mcfunction", - "match": "^(.*)$", - "captures": { - "1": { - "name": "invalid.illegal.mcfunction" - } - } - } - ] - }, - "command.tokens": { - "patterns": [ - { - "include": "#command.token.nbt_compound" - }, - { - "include": "#command.token.nbt_list" - }, - { - "include": "#command.token.selector_with_arguments" - }, - { - "include": "#command.token.selector_without_arguments" - }, - { - "include": "#command.token.block_predicate" - }, - { - "include": "#command.token.block_predicate_without_namespace" - }, - { - "include": "#command.token.resource_location" - }, - { - "include": "#command.token.tagged_resource_location" - }, - { - "include": "#command.token.range" - }, - { - "include": "#command.token.number" - }, - { - "include": "#command.token.coordinate" - }, - { - "include": "#command.token.boolean" - }, - { - "include": "#command.token.operation" - }, - { - "include": "#command.token.root_redirect" - }, - { - "include": "#command.token.greedy_parent" - }, - { - "include": "#command.token.literal" - }, - { - "include": "#command.token.uuid" - }, - { - "include": "#command.token.fakeplayer" - }, - { - "include": "#command.token.nbt_path" - }, - { - "include": "#command.token.quoted_string" - }, - { - "include": "#command.token.single_quoted_string" - }, - { - "include": "#command.token.unquoted_string" - }, - { - "include": "#command.token.unknown" - } - ] - }, - "command.token.selector_without_arguments": { - "name": "meta.command.token.selector_without_arguments.mcfunction", - "match": "(?<= )(\\@[a-z])(?=[ \\n]|$)", - "captures": { - "1": { - "name": "support.class.mcfunction" - } - } - }, - "command.token.resource_location": { - "name": "meta.command.token.resource_location.mcfunction", - "match": "(?<= )([a-z0-9_\\.\\-]+)(\\:)([a-z0-9_\\.\\-\\/]+)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "entity.name.function.mcfunction" - }, - "2": { - "name": "entity.name.function.mcfunction" - }, - "3": { - "name": "entity.name.function.mcfunction" - } - } - }, - "command.token.tagged_resource_location": { - "name": "meta.command.token.tagged_resource_location.mcfunction", - "match": "(?<= )(\\#)([a-z0-9_\\.\\-]+)(\\:)([a-z0-9_\\.\\-\\/]+)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "entity.name.function.mcfunction" - }, - "2": { - "name": "entity.name.function.mcfunction" - }, - "3": { - "name": "entity.name.function.mcfunction" - }, - "4": { - "name": "entity.name.function.mcfunction" - } - } - }, - "command.token.range": { - "name": "meta.command.token.range.mcfunction", - "match": "(?<= )(\\-?\\d*\\.?\\d+)?(\\.\\.)(\\-?\\d*\\.?\\d+)?(?=[ \\n]|$)", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - }, - "2": { - "name": "keyword.control.mcfunction" - }, - "3": { - "name": "constant.numeric.mcfunction" - } - } - }, - "command.token.number": { - "name": "meta.command.token.number.mcfunction", - "match": "(?<= )(\\-?\\d*\\.?\\d+)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - "command.token.coordinate": { - "name": "meta.command.token.coordinate.mcfunction", - "match": "(?<= )([\\~\\^])(\\-?\\d*\\.?\\d+)?(?=[ \\n]|$)", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - }, - "2": { - "name": "constant.numeric.mcfunction" - } - } - }, - "command.token.boolean": { - "name": "meta.command.token.boolean.mcfunction", - "match": "(?<= )(true|false)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - "command.token.operation": { - "name": "meta.command.token.operation.mcfunction", - "match": "(?<= )(\\%\\=|\\*\\=|\\+\\=|\\-\\=|\\/\\=|\\<|\\=|\\>|\\>\\<|\\<\\=|\\>\\=)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - "command.token.literal": { - "name": "meta.command.token.literal.mcfunction", - "match": "(?<= )([a-z_][a-z0-9_]*)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "entity.name.mcfunction" - } - } - }, - "command.token.uuid": { - "name": "meta.command.token.uuid.mcfunction", - "match": "(?<= )([0-9a-fA-F]+(?:(-)[0-9a-fA-F]+){4})(?=[ \\n]|$)", - "captures": { - "1": { - "name": "support.class.mcfunction" - } - } - }, - "command.token.fakeplayer": { - "name": "meta.command.token.fakeplayer.mcfunction", - "match": "(?<= )([\\#\\$\\%]\\S+)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "support.class.mcfunction" - } - } - }, - "command.token.unquoted_string": { - "name": "meta.command.token.unquoted_string.mcfunction", - "match": "(?<= )(\\S+)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "string.unquoted.mcfunction" - } - } - }, - "command.token.unknown": { - "name": "meta.command.token.unknown.mcfunction", - "match": "(?<= )([^ \\n]*)(?=[ \\n]|$)", - "captures": { - "1": { - "name": "invalid.illegal.mcfunction" - } - } - }, - "command.token.root_redirect": { - "name": "meta.command.token.root_redirect.mcfunction", - "match": "(?<= )(run) ([a-z_][a-z0-9_]*)?(?=[ \\n]|$)", - "captures": { - "1": { - "name": "entity.name.mcfunction" - }, - "2": { - "name": "keyword.control.mcfunction" - } - } - }, - "command.token.greedy_parent": { - "name": "meta.command.token.greedy_parent.mcfunction", - "match": "((?<=^say | say ))(.*)$", - "captures": { - "1": { - "name": "entity.name.mcfunction" - }, - "2": { - "name": "string.quoted.mcfunction" - } - } - }, - "command.token.nbt_compound": { - "name": "meta.command.token.nbt_compound.mcfunction", - "begin": "(?<= )(\\{)", - "end": "(?=\\n)|(\\})([^ \\n]*)", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.compound" - } - ] - }, - "command.token.nbt_list": { - "name": "meta.command.token.nbt_list.mcfunction", - "begin": "(?<= )(\\[)(\\w*;)?", - "end": "(?=\\n)|(\\])([^ \\n]*)", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.list" - } - ] - }, - "nbt.compound": { - "patterns": [ - { - "match": " +" - }, - { - "begin": "(,)? *([A-Za-z0-9_\\.\\-]+|\\\"[^\\n\\\"]+\\\") *(\\:) *", - "end": " *(?=[\\n\\}\\,])", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "string.interpolated.mcfunction" - }, - "3": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.value" - } - ] - }, - { - "match": "[^\\n\\}\\,]+", - "name": "invalid.illegal.mcfunction" - } - ] - }, - "nbt.list": { + "root": { "patterns": [ { - "match": " +" - }, - { - "begin": "(,)? *(?=[^\\n\\]\\,])", - "end": " *(?=[\\n\\]\\,])", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.value" - } - ] + "name": "keyword.control._.root_command.mcfunction", + "match": "(?:\\r\\n|\\n|^)[ \\t]*[a-z][a-z0-9_]*(?=\\s|$)" }, { - "match": "[^\\n\\]\\,]+", - "name": "invalid.illegal.mcfunction" - } - ] - }, - "nbt.value": { - "patterns": [ - { - "begin": "(\\{)", - "end": "(?=\\n)|(\\})", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, + "name": "comment._.comment.mcfunction", + "begin": "(?:\\r\\n|\\n|^)[ \\t]*(?=#)", + "end": "(?=\\r\\n|\\n|$)", "patterns": [ { - "include": "#nbt.compound" - } - ] - }, - { - "begin": "(\\[)(\\w*;)?", - "end": "(?=\\n)|(\\])", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" + "match": ".+" }, - "2": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.list" - } - ] - }, - { - "begin": "(\\\")", - "end": "(?=\\n)|(\\\")", - "beginCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "patterns": [ - { - "include": "#common.quoted_string" - } - ] - }, - { - "begin": "(\\')", - "end": "(?=\\n)|(\\')", - "beginCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "patterns": [ { - "include": "#common.single_quoted_string" + "match": "(?:\\r\\n|\\n|^)[ \\t]*#" } ] }, { - "match": "(true|false)", - "name": "constant.numeric.mcfunction" + "name": "meta._.whitespace.mcfunction", + "match": "\\s" }, { - "match": "(\\-?\\d*\\.?\\d+)", - "name": "constant.numeric.mcfunction" - }, - { - "match": "([^\\s\\{\\}\\[\\]\\,\\:\\=]+)", - "name": "string.unquoted.mcfunction" - }, - { - "match": "[^\\n\\,\\]\\}]+", - "name": "invalid.illegal.mcfunction" - } - ] - }, - "command.token.quoted_string": { - "name": "meta.command.token.quoted_string.mcfunction", - "begin": "(?<= )(\\\")", - "end": "(?=\\n)|(\\\")([^ \\n]*)", - "beginCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "string.quoted.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#common.quoted_string" - } - ] - }, - "command.token.single_quoted_string": { - "name": "meta.command.token.single_quoted_string.mcfunction", - "begin": "(?<= )(\\')", - "end": "(?=\\n)|(\\')([^ \\n]*)", - "beginCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "string.quoted.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#common.single_quoted_string" - } - ] - }, - "command.token.block_predicate": { - "name": "meta.command.token.block_predicate.mcfunction", - "begin": "(?<= )(?=(\\#)?([a-z0-9_\\.\\-]+)(\\:)([a-z0-9_\\.\\-\\/]+)(\\[|\\{))", - "end": "(?=\\n)|(?:(?<=\\])(?!\\{)|(?<=\\}))([^ \\n]*)", - "endCaptures": { - "1": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#block_predicate" + "include": "#command_tokens" } ] }, - "command.token.block_predicate_without_namespace": { - "name": "meta.command.token.block_predicate_without_namespace.mcfunction", - "begin": "(?<= )(?=(\\#)?([a-z0-9_\\.\\-\\/]+)(\\[ *([a-z_][a-z0-9_]*) *\\=))", - "end": "(?=\\n)|(?:(?<=\\])(?!\\{)|(?<=\\}))([^ \\n]*)", - "endCaptures": { - "1": { - "name": "invalid.illegal.mcfunction" - } - }, + "command_tokens": { "patterns": [ { - "include": "#block_predicate" - } - ] - }, - "command.token.selector_with_arguments": { - "name": "meta.command.token.selector_with_arguments.mcfunction", - "begin": "(?<= )(\\@[a-z])(\\[)", - "end": "(?=\\n)|(\\])([^ \\n]*)", - "beginCaptures": { - "1": { - "name": "support.class.mcfunction" - }, - "2": { - "name": "support.class.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "support.class.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "name": "meta.selector.argument_spacing.mcfunction", - "match": " +" - }, - { - "name": "meta.selector.argument.mcfunction", - "begin": "((?:[a-z_][a-z0-9_]*)|(?:\"[^\"\n]*\")|(?:\\'[^\\'\n]*\\')) *(\\=) *(\\!)? *", - "end": "( *\\,)(?=[\\]\\n])|( *\\,)|(?= *[\\]\\n])", - "beginCaptures": { - "1": { - "name": "variable.other.mcfunction" - }, - "2": { - "name": "support.class.mcfunction" - }, - "3": { - "name": "keyword.control.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "invalid.illegal.mcfunction" - }, - "2": { - "name": "support.class.mcfunction" - } - }, - "patterns": [ - { - "include": "#selector.argument.resource_location" - }, - { - "include": "#selector.argument.tagged_resource_location" - }, - { - "include": "#selector.argument.range" - }, - { - "include": "#selector.argument.number" - }, - { - "include": "#selector.argument.boolean" - }, - { - "include": "#selector.argument.property_map" - }, - { - "include": "#selector.argument.nbt_compound" - }, - { - "include": "#selector.argument.quoted_string" - }, - { - "include": "#selector.argument.single_quoted_string" - }, - { - "include": "#selector.argument.unquoted_string" - }, - { - "include": "#selector.argument.unknown" - } - ] - }, - { - "name": "invalid.illegal.mcfunction", - "match": "[^\\]\\n]+" - } - ] - }, - "command.token.nbt_path": { - "name": "meta.command.token.nbt_path.mcfunction", - "begin": "(?<= )(?=\\w+[\\.\\[\\{])", - "end": "(?=[ \\n]|$)", - "patterns": [ - { - "include": "#nbt_path.property" - } - ] - }, - "nbt_path.property": { - "patterns": [ - { - "begin": "(\\.)?(\\w+)?(\\[)", - "end": "(\\])|(?=\\n)", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "string.interpolated.mcfunction" - }, - "3": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt_path.index" - } - ] - }, - { - "begin": "(\\.)?(\\w+)(\\{)", - "end": "(\\})|(?=\\n)", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "string.interpolated.mcfunction" - }, - "3": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.compound" - } - ] - }, - { - "begin": "(\\\")", - "end": "(?=\\n)|(\\\")([^\\. \\n]*)", - "beginCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "string.quoted.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#common.quoted_string" - } - ] - }, - { - "match": "(\\.)?(\\w+)", - "captures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "string.interpolated.mcfunction" - } - } - }, - { - "match": "(\\.)(?=\\.)", - "captures": { - "1": { - "name": "invalid.illegal.mcfunction" - } - } - }, - { - "match": "[^\\.\\s]+", - "name": "invalid.illegal.mcfunction" - } - ] - }, - "nbt_path.index": { - "patterns": [ - { - "match": "(?<=\\[)(\\-?\\d+)(?=\\])", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - { - "begin": "(\\{)", - "end": "(?=\\n)|(\\})([^\\]\\,\\n]*)", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.compound" - } - ] - }, - { - "match": "[^\\n\\]]+", - "name": "invalid.illegal.mcfunction" - } - ] - }, - "block_predicate": { - "patterns": [ - { - "match": "(\\#)([a-z0-9_\\.\\-]+)(\\:)([a-z0-9_\\.\\-\\/]+)", - "captures": { - "1": { - "name": "entity.name.function.mcfunction" - }, - "2": { - "name": "entity.name.function.mcfunction" - }, - "3": { - "name": "entity.name.function.mcfunction" - }, - "4": { - "name": "entity.name.function.mcfunction" - } - } - }, - { - "match": "([a-z0-9_\\.\\-]+)(\\:)([a-z0-9_\\.\\-\\/]+)", - "captures": { - "1": { - "name": "entity.name.function.mcfunction" - }, - "2": { - "name": "entity.name.function.mcfunction" - }, - "3": { - "name": "entity.name.function.mcfunction" - } - } - }, - { - "match": "([a-z0-9_\\.\\-\\/]+)", - "captures": { - "1": { - "name": "entity.name.function.mcfunction" - } - } - }, - { - "begin": "(\\[)", - "end": "(\\])", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#block_predicate.arguments" - } - ] - }, - { - "begin": "(\\{)", - "end": "(\\})", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.compound" - } - ] - } - ] - }, - "block_predicate.arguments": { - "patterns": [ - { - "name": "meta.block_predicate.argument_spacing.mcfunction", - "match": " +" - }, - { - "name": "meta.block_predicate.argument.mcfunction", - "begin": "([a-z_][a-z0-9_]*) *(\\=) *", - "end": "(\\,)(?=[\\]\\n])|(\\,)|(?=[\\]\\n])", - "beginCaptures": { - "1": { - "name": "variable.other.mcfunction" - }, - "2": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "invalid.illegal.mcfunction" - }, - "2": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#block_predicate.argument.number" - }, - { - "include": "#block_predicate.argument.boolean" - }, - { - "include": "#block_predicate.argument.literal" - } - ] - } - ] - }, - "block_predicate.argument.number": { - "name": "meta.block_predicate.argument.number.mcfunction", - "match": "(\\-?\\d*\\.?\\d+)(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - "block_predicate.argument.boolean": { - "name": "meta.block_predicate.argument.boolean.mcfunction", - "match": "(true|false)(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - "block_predicate.argument.literal": { - "name": "meta.block_predicate.argument.literal.mcfunction", - "match": "([a-z_][a-z0-9_]*)(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "entity.name.mcfunction" - } - } - }, - "selector.argument.resource_location": { - "name": "meta.selector.argument.resource_location.mcfunction", - "match": "([a-z0-9_\\.\\-]+)(\\:)([a-z0-9_\\.\\-\\/]+)(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "entity.name.function.mcfunction" - }, - "2": { - "name": "entity.name.function.mcfunction" - }, - "3": { - "name": "entity.name.function.mcfunction" - } - } - }, - "selector.argument.tagged_resource_location": { - "name": "meta.selector.argument.tagged_resource_location.mcfunction", - "match": "(\\#)([a-z0-9_\\.\\-]+)(\\:)([a-z0-9_\\.\\-\\/]+)(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "entity.name.function.mcfunction" - }, - "2": { - "name": "entity.name.function.mcfunction" - }, - "3": { - "name": "entity.name.function.mcfunction" - }, - "4": { - "name": "entity.name.function.mcfunction" - } - } - }, - "selector.argument.range": { - "name": "meta.selector.argument.range.mcfunction", - "match": "(\\-?\\d*\\.?\\d+)?(\\.\\.)(\\-?\\d*\\.?\\d+)?(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - }, - "2": { - "name": "keyword.control.mcfunction" - }, - "3": { - "name": "constant.numeric.mcfunction" - } - } - }, - "selector.argument.number": { - "name": "meta.selector.argument.number.mcfunction", - "match": "(\\-?\\d*\\.?\\d+)(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - "selector.argument.boolean": { - "name": "meta.selector.argument.boolean.mcfunction", - "match": "(true|false)(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - "selector.argument.unquoted_string": { - "name": "meta.selector.argument.unquoted_string.mcfunction", - "match": "([^\\s\\{\\}\\[\\]\\,\\:\\=\\!]+)(?= *[\\,\\]\\n])", - "captures": { - "1": { - "name": "string.unquoted.mcfunction" - } - } - }, - "selector.argument.unknown": { - "name": "meta.selector.argument.unknown.mcfunction", - "match": "([^\\]\\n\\,]+)", - "captures": { - "1": { - "name": "invalid.illegal.mcfunction" - } - } - }, - "selector.argument.quoted_string": { - "name": "meta.selector.argument.quoted_string.mcfunction", - "begin": "(\\\")", - "end": "(?=\\n)|(\\\") *([^\\]\\,\\n]*)", - "beginCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "string.quoted.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#common.quoted_string" - } - ] - }, - "selector.argument.single_quoted_string": { - "name": "meta.selector.argument.single_quoted_string.mcfunction", - "begin": "(\\')", - "end": "(?=\\n)|(\\') *([^\\]\\,\\n]*)", - "beginCaptures": { - "1": { - "name": "string.quoted.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "string.quoted.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#common.single_quoted_string" - } - ] - }, - "selector.argument.property_map": { - "name": "meta.selector.argument.property_map.mcfunction", - "begin": "(\\{)(?= *([a-z0-9_\\.\\-]+\\:[a-z0-9_\\.\\-\\/]+|[a-z0-9_\\.\\-\\/]+|([A-Za-z0-9_\\.\\-]+)) *(\\=))", - "end": "(?=\\n)|(\\}) *([^\\]\\,\\n]*)", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#property_map" - } - ] - }, - "selector.argument.nbt_compound": { - "name": "meta.selector.argument.nbt_compound.mcfunction", - "begin": "(\\{)", - "end": "(?=\\n)|(\\}) *([^\\]\\,\\n]*)", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#nbt.compound" - } - ] - }, - "property_map": { - "patterns": [ - { - "match": " +" - }, - { - "begin": "(,)? *([A-Za-z0-9_\\.\\-]+) *(\\=) *", - "end": " *(?=[\\n\\}\\,])", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "entity.name.function.mcfunction" - }, - "3": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#property_map.values" - } - ] - }, - { - "begin": "(,)? *([a-z0-9_\\.\\-]+\\:[a-z0-9_\\.\\-\\/]+|[a-z0-9_\\.\\-\\/]+) *(\\=) *", - "end": " *(?=[\\n\\}\\,])", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "entity.name.function.mcfunction" - }, - "3": { - "name": "variable.language.mcfunction" - } - }, - "patterns": [ - { - "include": "#property_map.values" - } - ] - }, - { - "match": "[^\\n\\}\\,]+", - "name": "invalid.illegal.mcfunction" - } - ] - }, - "property_map.values": { - "patterns": [ - { - "match": "(true|false)", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - { - "match": "(\\-?\\d*\\.?\\d+)?(\\.\\.)(\\-?\\d*\\.?\\d+)?", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - }, - "2": { - "name": "keyword.control.mcfunction" - }, - "3": { - "name": "constant.numeric.mcfunction" - } - } - }, - { - "match": "(\\-?\\d*\\.?\\d+)", - "captures": { - "1": { - "name": "constant.numeric.mcfunction" - } - } - }, - { - "begin": "(\\{) *", - "end": "(?=\\n)|(\\}) *([^\\}\\,\\n]*)", - "beginCaptures": { - "1": { - "name": "variable.language.mcfunction" - } - }, - "endCaptures": { - "1": { - "name": "variable.language.mcfunction" - }, - "2": { - "name": "invalid.illegal.mcfunction" - } - }, - "patterns": [ - { - "include": "#property_map" - } - ] - } - ] - }, - "common.quoted_string": { - "patterns": [ - { - "match": "[^\\\\\\\"\\n]", - "name": "string.quoted.mcfunction" - }, - { - "match": "\\\\[^\\n]", - "name": "constant.character.escape.mcfunction" - }, - { - "match": "\\\\", - "name": "invalid.illegal.mcfunction" - } - ] - }, - "common.single_quoted_string": { - "patterns": [ - { - "match": "[^\\\\\\'\\n]", - "name": "string.quoted.mcfunction" - }, - { - "match": "\\\\[^\\n]", - "name": "constant.character.escape.mcfunction" + "name": "constant.numeric._.integer.command_token.mcfunction", + "match": "\\-?\\d+(?=\\s|$)" }, { - "match": "\\\\", - "name": "invalid.illegal.mcfunction" + "name": "string.unquoted._.unknown.command_token.mcfunction", + "match": "\\S+(?=\\s|$)" } ] } diff --git a/mcfunction.tmLanguage.yaml b/mcfunction.tmLanguage.yaml index c602d76..f7656a3 100644 --- a/mcfunction.tmLanguage.yaml +++ b/mcfunction.tmLanguage.yaml @@ -3,725 +3,24 @@ scopeName: source.mcfunction fileTypes: - mcfunction patterns: - - include: '#comment' - - include: '#command' - - include: '#unknown' + - include: '#root' repository: - comment: - patterns: - - name: meta.comment.block.mcfunction - begin: '^[ \t]*((#)([\#\>\~\!\@\$\%\^\*]+)((.*)))$' - end: '^(?![ \t]*#)' - beginCaptures: - '1': - name: comment.block.mcfunction - '2': - name: markup.list.mcfunction - '3': - name: markup.list.mcfunction - '4': - name: markup.bold.mcfunction - '5': - name: markup.list.mcfunction - patterns: - - include: '#comment.block' - - name: meta.comment.line.mcfunction - match: '^[ \t]*(#.*)$' - captures: - '1': - name: comment.line.mcfunction - comment.block: - patterns: - - name: meta.comment.block_line.mcfunction - begin: '^[ \t]*((#)[ \t]*)' - end: $ - beginCaptures: - '1': - name: comment.block.mcfunction - '2': - name: markup.list.mcfunction - patterns: - - include: '#comment.block.line' - comment.block.line: - patterns: - - name: meta.comment.block.annotation.mcfunction - match: ((\@\w*)\b(.*))$ - captures: - '1': - name: comment.block.mcfunction - '2': - name: markup.heading.mcfunction - '3': - name: comment.block.mcfunction - - name: meta.comment.block.heading.mcfunction - match: '(([\#\>\~\!\@\$\%\^\*]+)((.*)))$' - captures: - '1': - name: comment.block.mcfunction - '2': - name: markup.list.mcfunction - '3': - name: markup.bold.mcfunction - '4': - name: markup.list.mcfunction - - name: meta.comment.block.text.mcfunction - match: (.*)$ - captures: - '1': - name: comment.block.mcfunction - command: - patterns: - - name: meta.command.mcfunction - begin: '^\s*([a-z_][a-z0-9_]*)[ \n]' - end: $ - beginCaptures: - '1': - name: keyword.control.mcfunction - patterns: - - begin: (?<= ) - end: '[ \n]' - contentName: meta.command.token.mcfunction - patterns: - - include: '#command.tokens' - unknown: - patterns: - - name: meta.unknown.mcfunction - match: ^(.*)$ - captures: - '1': - name: invalid.illegal.mcfunction - command.tokens: - patterns: - - include: '#command.token.nbt_compound' - - include: '#command.token.nbt_list' - - include: '#command.token.selector_with_arguments' - - include: '#command.token.selector_without_arguments' - - include: '#command.token.block_predicate' - - include: '#command.token.block_predicate_without_namespace' - - include: '#command.token.resource_location' - - include: '#command.token.tagged_resource_location' - - include: '#command.token.range' - - include: '#command.token.number' - - include: '#command.token.coordinate' - - include: '#command.token.boolean' - - include: '#command.token.operation' - - include: '#command.token.root_redirect' - - include: '#command.token.greedy_parent' - - include: '#command.token.literal' - - include: '#command.token.uuid' - - include: '#command.token.fakeplayer' - - include: '#command.token.nbt_path' - - include: '#command.token.quoted_string' - - include: '#command.token.single_quoted_string' - - include: '#command.token.unquoted_string' - - include: '#command.token.unknown' - command.token.selector_without_arguments: - name: meta.command.token.selector_without_arguments.mcfunction - match: '(?<= )(\@[a-z])(?=[ \n]|$)' - captures: - '1': - name: support.class.mcfunction - command.token.resource_location: - name: meta.command.token.resource_location.mcfunction - match: '(?<= )([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(?=[ \n]|$)' - captures: &ref_1 - '1': - name: entity.name.function.mcfunction - '2': - name: entity.name.function.mcfunction - '3': - name: entity.name.function.mcfunction - command.token.tagged_resource_location: - name: meta.command.token.tagged_resource_location.mcfunction - match: '(?<= )(\#)([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(?=[ \n]|$)' - captures: &ref_0 - '1': - name: entity.name.function.mcfunction - '2': - name: entity.name.function.mcfunction - '3': - name: entity.name.function.mcfunction - '4': - name: entity.name.function.mcfunction - command.token.range: - name: meta.command.token.range.mcfunction - match: '(?<= )(\-?\d*\.?\d+)?(\.\.)(\-?\d*\.?\d+)?(?=[ \n]|$)' - captures: &ref_5 - '1': - name: constant.numeric.mcfunction - '2': - name: keyword.control.mcfunction - '3': - name: constant.numeric.mcfunction - command.token.number: - name: meta.command.token.number.mcfunction - match: '(?<= )(\-?\d*\.?\d+)(?=[ \n]|$)' - captures: &ref_2 - '1': - name: constant.numeric.mcfunction - command.token.coordinate: - name: meta.command.token.coordinate.mcfunction - match: '(?<= )([\~\^])(\-?\d*\.?\d+)?(?=[ \n]|$)' - captures: - '1': - name: constant.numeric.mcfunction - '2': - name: constant.numeric.mcfunction - command.token.boolean: - name: meta.command.token.boolean.mcfunction - match: '(?<= )(true|false)(?=[ \n]|$)' - captures: &ref_3 - '1': - name: constant.numeric.mcfunction - command.token.operation: - name: meta.command.token.operation.mcfunction - match: '(?<= )(\%\=|\*\=|\+\=|\-\=|\/\=|\<|\=|\>|\>\<|\<\=|\>\=)(?=[ \n]|$)' - captures: - '1': - name: constant.numeric.mcfunction - command.token.literal: - name: meta.command.token.literal.mcfunction - match: '(?<= )([a-z_][a-z0-9_]*)(?=[ \n]|$)' - captures: &ref_4 - '1': - name: entity.name.mcfunction - command.token.uuid: - name: meta.command.token.uuid.mcfunction - match: '(?<= )([0-9a-fA-F]+(?:(-)[0-9a-fA-F]+){4})(?=[ \n]|$)' - captures: - '1': - name: support.class.mcfunction - command.token.fakeplayer: - name: meta.command.token.fakeplayer.mcfunction - match: '(?<= )([\#\$\%]\S+)(?=[ \n]|$)' - captures: - '1': - name: support.class.mcfunction - command.token.unquoted_string: - name: meta.command.token.unquoted_string.mcfunction - match: '(?<= )(\S+)(?=[ \n]|$)' - captures: &ref_6 - '1': - name: string.unquoted.mcfunction - command.token.unknown: - name: meta.command.token.unknown.mcfunction - match: '(?<= )([^ \n]*)(?=[ \n]|$)' - captures: - '1': - name: invalid.illegal.mcfunction - command.token.root_redirect: - name: meta.command.token.root_redirect.mcfunction - match: '(?<= )(run) ([a-z_][a-z0-9_]*)?(?=[ \n]|$)' - captures: - '1': - name: entity.name.mcfunction - '2': - name: keyword.control.mcfunction - command.token.greedy_parent: - name: meta.command.token.greedy_parent.mcfunction - match: ((?<=^say | say ))(.*)$ - captures: - '1': - name: entity.name.mcfunction - '2': - name: string.quoted.mcfunction - command.token.nbt_compound: - name: meta.command.token.nbt_compound.mcfunction - begin: '(?<= )(\{)' - end: '(?=\n)|(\})([^ \n]*)' - beginCaptures: - '1': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#nbt.compound' - command.token.nbt_list: - name: meta.command.token.nbt_list.mcfunction - begin: '(?<= )(\[)(\w*;)?' - end: '(?=\n)|(\])([^ \n]*)' - beginCaptures: - '1': - name: variable.language.mcfunction - '2': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#nbt.list' - nbt.compound: - patterns: - - match: ' +' - - begin: '(,)? *([A-Za-z0-9_\.\-]+|\"[^\n\"]+\") *(\:) *' - end: ' *(?=[\n\}\,])' - beginCaptures: - '1': - name: variable.language.mcfunction - '2': - name: string.interpolated.mcfunction - '3': - name: variable.language.mcfunction - patterns: - - include: '#nbt.value' - - match: '[^\n\}\,]+' - name: invalid.illegal.mcfunction - nbt.list: - patterns: - - match: ' +' - - begin: '(,)? *(?=[^\n\]\,])' - end: ' *(?=[\n\]\,])' - beginCaptures: - '1': - name: variable.language.mcfunction - patterns: - - include: '#nbt.value' - - match: '[^\n\]\,]+' - name: invalid.illegal.mcfunction - nbt.value: - patterns: - - begin: '(\{)' - end: '(?=\n)|(\})' - beginCaptures: - '1': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - patterns: - - include: '#nbt.compound' - - begin: '(\[)(\w*;)?' - end: '(?=\n)|(\])' - beginCaptures: - '1': - name: variable.language.mcfunction - '2': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - patterns: - - include: '#nbt.list' - - begin: (\") - end: (?=\n)|(\") - beginCaptures: - '1': - name: string.quoted.mcfunction - endCaptures: - '1': - name: string.quoted.mcfunction - patterns: - - include: '#common.quoted_string' - - begin: (\') - end: (?=\n)|(\') - beginCaptures: - '1': - name: string.quoted.mcfunction - endCaptures: - '1': - name: string.quoted.mcfunction - patterns: - - include: '#common.single_quoted_string' - - match: (true|false) - name: constant.numeric.mcfunction - - match: (\-?\d*\.?\d+) - name: constant.numeric.mcfunction - - match: '([^\s\{\}\[\]\,\:\=]+)' - name: string.unquoted.mcfunction - - match: '[^\n\,\]\}]+' - name: invalid.illegal.mcfunction - command.token.quoted_string: - name: meta.command.token.quoted_string.mcfunction - begin: (?<= )(\") - end: '(?=\n)|(\")([^ \n]*)' - beginCaptures: - '1': - name: string.quoted.mcfunction - endCaptures: - '1': - name: string.quoted.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#common.quoted_string' - command.token.single_quoted_string: - name: meta.command.token.single_quoted_string.mcfunction - begin: (?<= )(\') - end: '(?=\n)|(\'')([^ \n]*)' - beginCaptures: - '1': - name: string.quoted.mcfunction - endCaptures: - '1': - name: string.quoted.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#common.single_quoted_string' - command.token.block_predicate: - name: meta.command.token.block_predicate.mcfunction - begin: '(?<= )(?=(\#)?([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(\[|\{))' - end: '(?=\n)|(?:(?<=\])(?!\{)|(?<=\}))([^ \n]*)' - endCaptures: - '1': - name: invalid.illegal.mcfunction - patterns: - - include: '#block_predicate' - command.token.block_predicate_without_namespace: - name: meta.command.token.block_predicate_without_namespace.mcfunction - begin: '(?<= )(?=(\#)?([a-z0-9_\.\-\/]+)(\[ *([a-z_][a-z0-9_]*) *\=))' - end: '(?=\n)|(?:(?<=\])(?!\{)|(?<=\}))([^ \n]*)' - endCaptures: - '1': - name: invalid.illegal.mcfunction - patterns: - - include: '#block_predicate' - command.token.selector_with_arguments: - name: meta.command.token.selector_with_arguments.mcfunction - begin: '(?<= )(\@[a-z])(\[)' - end: '(?=\n)|(\])([^ \n]*)' - beginCaptures: - '1': - name: support.class.mcfunction - '2': - name: support.class.mcfunction - endCaptures: - '1': - name: support.class.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - name: meta.selector.argument_spacing.mcfunction - match: ' +' - - name: meta.selector.argument.mcfunction - begin: |- - ((?:[a-z_][a-z0-9_]*)|(?:"[^" - ]*")|(?:\'[^\' - ]*\')) *(\=) *(\!)? * - end: '( *\,)(?=[\]\n])|( *\,)|(?= *[\]\n])' - beginCaptures: - '1': - name: variable.other.mcfunction - '2': - name: support.class.mcfunction - '3': - name: keyword.control.mcfunction - endCaptures: - '1': - name: invalid.illegal.mcfunction - '2': - name: support.class.mcfunction - patterns: - - include: '#selector.argument.resource_location' - - include: '#selector.argument.tagged_resource_location' - - include: '#selector.argument.range' - - include: '#selector.argument.number' - - include: '#selector.argument.boolean' - - include: '#selector.argument.property_map' - - include: '#selector.argument.nbt_compound' - - include: '#selector.argument.quoted_string' - - include: '#selector.argument.single_quoted_string' - - include: '#selector.argument.unquoted_string' - - include: '#selector.argument.unknown' - - name: invalid.illegal.mcfunction - match: '[^\]\n]+' - command.token.nbt_path: - name: meta.command.token.nbt_path.mcfunction - begin: '(?<= )(?=\w+[\.\[\{])' - end: '(?=[ \n]|$)' - patterns: - - include: '#nbt_path.property' - nbt_path.property: - patterns: - - begin: '(\.)?(\w+)?(\[)' - end: '(\])|(?=\n)' - beginCaptures: - '1': - name: variable.language.mcfunction - '2': - name: string.interpolated.mcfunction - '3': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - patterns: - - include: '#nbt_path.index' - - begin: '(\.)?(\w+)(\{)' - end: '(\})|(?=\n)' - beginCaptures: - '1': - name: variable.language.mcfunction - '2': - name: string.interpolated.mcfunction - '3': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - patterns: - - include: '#nbt.compound' - - begin: (\") - end: '(?=\n)|(\")([^\. \n]*)' - beginCaptures: - '1': - name: string.quoted.mcfunction - endCaptures: - '1': - name: string.quoted.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#common.quoted_string' - - match: (\.)?(\w+) - captures: - '1': - name: variable.language.mcfunction - '2': - name: string.interpolated.mcfunction - - match: (\.)(?=\.) - captures: - '1': - name: invalid.illegal.mcfunction - - match: '[^\.\s]+' - name: invalid.illegal.mcfunction - nbt_path.index: - patterns: - - match: '(?<=\[)(\-?\d+)(?=\])' - captures: - '1': - name: constant.numeric.mcfunction - - begin: '(\{)' - end: '(?=\n)|(\})([^\]\,\n]*)' - beginCaptures: - '1': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#nbt.compound' - - match: '[^\n\]]+' - name: invalid.illegal.mcfunction - block_predicate: - patterns: - - match: '(\#)([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)' - captures: *ref_0 - - match: '([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)' - captures: *ref_1 - - match: '([a-z0-9_\.\-\/]+)' - captures: - '1': - name: entity.name.function.mcfunction - - begin: '(\[)' - end: '(\])' - beginCaptures: - '1': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - patterns: - - include: '#block_predicate.arguments' - - begin: '(\{)' - end: '(\})' - beginCaptures: - '1': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - patterns: - - include: '#nbt.compound' - block_predicate.arguments: - patterns: - - name: meta.block_predicate.argument_spacing.mcfunction - match: ' +' - - name: meta.block_predicate.argument.mcfunction - begin: '([a-z_][a-z0-9_]*) *(\=) *' - end: '(\,)(?=[\]\n])|(\,)|(?=[\]\n])' - beginCaptures: - '1': - name: variable.other.mcfunction - '2': - name: variable.language.mcfunction - endCaptures: - '1': - name: invalid.illegal.mcfunction - '2': - name: variable.language.mcfunction - patterns: - - include: '#block_predicate.argument.number' - - include: '#block_predicate.argument.boolean' - - include: '#block_predicate.argument.literal' - block_predicate.argument.number: - name: meta.block_predicate.argument.number.mcfunction - match: '(\-?\d*\.?\d+)(?= *[\,\]\n])' - captures: *ref_2 - block_predicate.argument.boolean: - name: meta.block_predicate.argument.boolean.mcfunction - match: '(true|false)(?= *[\,\]\n])' - captures: *ref_3 - block_predicate.argument.literal: - name: meta.block_predicate.argument.literal.mcfunction - match: '([a-z_][a-z0-9_]*)(?= *[\,\]\n])' - captures: *ref_4 - selector.argument.resource_location: - name: meta.selector.argument.resource_location.mcfunction - match: '([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(?= *[\,\]\n])' - captures: *ref_1 - selector.argument.tagged_resource_location: - name: meta.selector.argument.tagged_resource_location.mcfunction - match: '(\#)([a-z0-9_\.\-]+)(\:)([a-z0-9_\.\-\/]+)(?= *[\,\]\n])' - captures: *ref_0 - selector.argument.range: - name: meta.selector.argument.range.mcfunction - match: '(\-?\d*\.?\d+)?(\.\.)(\-?\d*\.?\d+)?(?= *[\,\]\n])' - captures: *ref_5 - selector.argument.number: - name: meta.selector.argument.number.mcfunction - match: '(\-?\d*\.?\d+)(?= *[\,\]\n])' - captures: *ref_2 - selector.argument.boolean: - name: meta.selector.argument.boolean.mcfunction - match: '(true|false)(?= *[\,\]\n])' - captures: *ref_3 - selector.argument.unquoted_string: - name: meta.selector.argument.unquoted_string.mcfunction - match: '([^\s\{\}\[\]\,\:\=\!]+)(?= *[\,\]\n])' - captures: *ref_6 - selector.argument.unknown: - name: meta.selector.argument.unknown.mcfunction - match: '([^\]\n\,]+)' - captures: - '1': - name: invalid.illegal.mcfunction - selector.argument.quoted_string: - name: meta.selector.argument.quoted_string.mcfunction - begin: (\") - end: '(?=\n)|(\") *([^\]\,\n]*)' - beginCaptures: - '1': - name: string.quoted.mcfunction - endCaptures: - '1': - name: string.quoted.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#common.quoted_string' - selector.argument.single_quoted_string: - name: meta.selector.argument.single_quoted_string.mcfunction - begin: (\') - end: '(?=\n)|(\'') *([^\]\,\n]*)' - beginCaptures: - '1': - name: string.quoted.mcfunction - endCaptures: - '1': - name: string.quoted.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#common.single_quoted_string' - selector.argument.property_map: - name: meta.selector.argument.property_map.mcfunction - begin: >- - (\{)(?= - *([a-z0-9_\.\-]+\:[a-z0-9_\.\-\/]+|[a-z0-9_\.\-\/]+|([A-Za-z0-9_\.\-]+)) - *(\=)) - end: '(?=\n)|(\}) *([^\]\,\n]*)' - beginCaptures: - '1': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#property_map' - selector.argument.nbt_compound: - name: meta.selector.argument.nbt_compound.mcfunction - begin: '(\{)' - end: '(?=\n)|(\}) *([^\]\,\n]*)' - beginCaptures: - '1': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#nbt.compound' - property_map: - patterns: - - match: ' +' - - begin: '(,)? *([A-Za-z0-9_\.\-]+) *(\=) *' - end: ' *(?=[\n\}\,])' - beginCaptures: - '1': - name: variable.language.mcfunction - '2': - name: entity.name.function.mcfunction - '3': - name: variable.language.mcfunction - patterns: - - include: '#property_map.values' - - begin: '(,)? *([a-z0-9_\.\-]+\:[a-z0-9_\.\-\/]+|[a-z0-9_\.\-\/]+) *(\=) *' - end: ' *(?=[\n\}\,])' - beginCaptures: - '1': - name: variable.language.mcfunction - '2': - name: entity.name.function.mcfunction - '3': - name: variable.language.mcfunction - patterns: - - include: '#property_map.values' - - match: '[^\n\}\,]+' - name: invalid.illegal.mcfunction - property_map.values: - patterns: - - match: (true|false) - captures: *ref_3 - - match: (\-?\d*\.?\d+)?(\.\.)(\-?\d*\.?\d+)? - captures: *ref_5 - - match: (\-?\d*\.?\d+) - captures: *ref_2 - - begin: '(\{) *' - end: '(?=\n)|(\}) *([^\}\,\n]*)' - beginCaptures: - '1': - name: variable.language.mcfunction - endCaptures: - '1': - name: variable.language.mcfunction - '2': - name: invalid.illegal.mcfunction - patterns: - - include: '#property_map' - common.quoted_string: - patterns: - - match: '[^\\\"\n]' - name: string.quoted.mcfunction - - match: '\\[^\n]' - name: constant.character.escape.mcfunction - - match: \\ - name: invalid.illegal.mcfunction - common.single_quoted_string: - patterns: - - match: '[^\\\''\n]' - name: string.quoted.mcfunction - - match: '\\[^\n]' - name: constant.character.escape.mcfunction - - match: \\ - name: invalid.illegal.mcfunction + root: + patterns: + - name: keyword.control._.root_command.mcfunction + match: '(?:\r\n|\n|^)[ \t]*[a-z][a-z0-9_]*(?=\s|$)' + - name: comment._.comment.mcfunction + begin: '(?:\r\n|\n|^)[ \t]*(?=#)' + end: (?=\r\n|\n|$) + patterns: + - match: .+ + - match: '(?:\r\n|\n|^)[ \t]*#' + - name: meta._.whitespace.mcfunction + match: \s + - include: '#command_tokens' + command_tokens: + patterns: + - name: constant.numeric._.integer.command_token.mcfunction + match: \-?\d+(?=\s|$) + - name: string.unquoted._.unknown.command_token.mcfunction + match: \S+(?=\s|$) diff --git a/tests/lone.mcfunction b/tests/lone.mcfunction new file mode 100644 index 0000000..6320cd2 --- /dev/null +++ b/tests/lone.mcfunction @@ -0,0 +1 @@ +data \ No newline at end of file diff --git a/tests/root.mcfunction b/tests/root.mcfunction new file mode 100644 index 0000000..85be1db --- /dev/null +++ b/tests/root.mcfunction @@ -0,0 +1,86 @@ +# ... + +say hello world + +# ... +# ... + +say hello world + +# ... +# ... +# ... + +say hello world + +# ... +say hello world + +# ... +# ... +say hello world + +# ... +# ... +# ... +say hello world + +say hello world +# ... + +say hello world +# ... +# ... + +say hello world +# ... +# ... +# ... + +say hello world + +# ... + # ... +say hello world + + # ... + # ... +say hello world + + # ... +# ... +say hello world + +# ... + # ... +# ... +say hello world + + # ... + say hello world + + # ... + # ... + say hello world + say hello world + + # ... + # ... + # ... + say hello world + say hello world + say hello world + + # ... +# ... + # ... + say hello world +say hello world + say hello world + +# ... + # ... +# ... +say hello world + say hello world +say hello world