1
0
Fork 0
mirror of https://github.com/Reuh/sublime-anselme.git synced 2025-10-27 11:49:30 +00:00

Update to latest Anselme version

This commit is contained in:
Étienne Fildadut 2022-09-17 13:54:07 +09:00
parent 5fb5596229
commit 2f3dd1ee56
2 changed files with 206 additions and 100 deletions

View file

@ -2,122 +2,228 @@
--- ---
# http://www.sublimetext.com/docs/3/syntax.html # http://www.sublimetext.com/docs/3/syntax.html
name: Anselme name: Anselme
comment: "Anselme v0.10.0 syntax" comment: "Anselme v25, and probably later, syntax"
file_extensions: file_extensions:
- ans - ans
- anselme - anselme
scope: source.anselme scope: source.anselme
variables: variables:
identifier: '[^\{\}\§\>\<\(\)\~\+\-\*\/\%\=\?\!\&\|\:\^\,\@\s\.\#\"\d][^\{\}\§\>\<\(\)\~\+\-\*\/\%\=\?\!\&\|\:\^\,\@\s\.\#\"]*' identifier: '[^\~\`\^\+\-\=\<\>\/\[\]\*\{\}\|\\\_\!\?\,\;\:\(\)\"\@\&\$\#\%\.\d\s][^\~\`\^\+\-\=\<\>\/\[\]\*\{\}\|\\\_\!\?\,\;\:\(\)\"\@\&\$\#\%\.]*'
operator: '[;:=+-/*%^,~?#|&!><!.]+'
contexts: contexts:
# Line types
main: main:
- match: ^\s*\(.*$ - match: ^\s*\(.*$
scope: comment.anselme scope: comment.line.anselme
- match: ^\s*(§)(.*?)\((.*)\)$ - match: ^\s*~[~?]?
captures:
1: keyword.control.anselme
2: entity.name.function.anselme
3: variable.parameter.anselme
- match: ^\s*(§)(.*)$
captures:
1: keyword.control.anselme
2: entity.name.function.anselme
- match: '^\s*>'
scope: keyword.control.conditional.anselme scope: keyword.control.conditional.anselme
push: text_formatting push: expression
- match: '^\s*[:=+\-*/%!&|]' - match: ^\s*@
scope: keyword.operator.assignment.anselme
push: line_expression
- match: '^\s*~~?'
scope: keyword.control.conditional.anselme
push: line_expression
- match: '^\s*#'
scope: keyword.other.anselme
push: line_expression
- match: '^\s*@'
scope: keyword.control.anselme scope: keyword.control.anselme
push: line_expression push: expression
- match: '^\s*(?<!\n)(?![(§>:=+\-*/%!&|~\n@])' - match: ^\s*#
push: text_formatting
text_formatting:
- meta_scope: markup.quote.anselme
- match: '\{'
scope: keyword.other.anselme scope: keyword.other.anselme
push: brace_expression push: expression
- match: '\\$' - match: ^\s*\>
scope: keyword.other.anselme
- include: decorable
- match: '\n'
pop: true
line_expression:
- include: expression
- include: decorable
- match: '\n'
pop: true
decorable:
- match: '~'
scope: keyword.control.conditional.anselme scope: keyword.control.conditional.anselme
set: line_expression push: text
- match: '#' - match: ^\s*:~?[$!%]
scope: keyword.other.anselme scope: keyword.other.anselme
set: line_expression push: function_definition_start
- match: '(§)([^\~\#\§\n]*)' - match: ^\s*\:~?
captures: scope: keyword.other.anselme
1: keyword.control.anselme push: variable_definition_start
2: entity.name.function.anselme - match: ^\s*
set: line_expression push: text
expression: # Text lines
- meta_scope: meta.group.anselme text:
- match: '[|&!?]' - meta_scope: text.anselme
scope: keyword.operator.logical.anselme - match: \\.
- match: '[+\-*/%^<>=]' scope: constant.character.escape.anselme
scope: keyword.operator.arithmetic.anselme - match: '[~#]'
- match: '[:,]'
scope: keyword.operator.anselme scope: keyword.operator.anselme
- match: \d*\.\d+ push: expression
scope: constant.numeric.float.anselme - include: string_interpolable
- match: \d+ - include: string_subtextable
scope: constant.numeric.integer.anselme - include: pop_on_line_end
- match: \"
scope: punctuation.definition.string.begin # Function definition
push: string function_definition_start:
- match: '({{identifier}})(\()' - meta_scope: meta.function.anselme
- match: '({{identifier}}|_?{{operator}}_?|\{\}|\(\))(?:(:)({{identifier}}))?'
captures: captures:
1: variable.function.anselme 1: entity.name.function.anselme
2: keyword.other.anselme 2: punctuation.separator.anselme
push: arguments 3: entity.name.function.anselme
- match: '\(' set: function_definition_args
scope: keyword.other.anselme - include: pop_on_line_end
push: parenthesis_expression function_definition_args:
- match: '{{identifier}}' - match: \(
scope: variable.other.anselme scope: punctuation.section.parens.start.anselme
push: parameter_paren
parenthesis_expression: - include: pop_on_line_end
- include: expression parameter_paren:
- match: '\)' - meta_scope: meta.function.parameters.anselme
scope: keyword.other.anselme - match: '({{identifier}})(?:(:)({{identifier}}))?(=|::)'
pop: true captures:
1: variable.parameter.anselme
brace_expression: 2: punctuation.separator.anselme
- include: expression 3: variable.parameter.anselme
- match: '\}' 4: keyword.operator.anselme
scope: keyword.other.anselme push: parameter_default
pop: true - match: '({{identifier}})(?:(:)({{identifier}}))?'
captures:
string: 1: variable.parameter.anselme
- meta_scope: string.quoted.double 2: punctuation.separator.anselme
- match: \" 3: variable.parameter.anselme
scope: punctuation.definition.string.end
pop: true
arguments:
- include: parenthesis_expression
- meta_content_scope: variable.parameter.anselme
- match: ',' - match: ','
scope: punctuation.separator.anselme scope: punctuation.separator.anselme
- match: \)
scope: punctuation.section.parens.end.anselme
pop: true
parameter_default:
- match: '(?=,|\))'
scope: punctuation.separator.anselme
pop: true
- include: expression
# Variable definition
variable_definition_start:
- match: '(:)\s*({{identifier}})(?:(:)({{identifier}}))?'
captures:
1: keyword.other.anselme
2: variable.other.constant.anselme
3: punctuation.separator.anselme
4: variable.other.constant.anselme
set: variable_definition_value
- match: '({{identifier}})(?:(:)({{identifier}}))?'
captures:
1: variable.other.anselme
2: punctuation.separator.anselme
3: variable.other.anselme
set: variable_definition_value
- include: pop_on_line_end
variable_definition_value:
- match: \=
scope: keyword.operator.assignment.anselme
push: expression
- include: pop_on_line_end
# Expressions
expression:
- match: \s+
- match: \d*\.\d+|\d+
scope: constant.numeric.anselme
- match: \(
scope: punctuation.section.parens.start.anselme
push: paren
- match: \)
scope: invalid.illegal.stray-paren-end.anselme
- match: \[
scope: punctuation.section.brackets.start.anselme
push: list
- match: \]
scope: invalid.illegal.stray-bracket-end.anselme
- match: \{
scope: punctuation.section.braces.start.anselme
push: map
- match: \{
scope: invalid.illegal.stray-brace-end.anselme
- match: '({{identifier}})(?=\(|!\s*(?!\(|{{identifier}}|\[|\{))'
scope: variable.function.anselme
- match: '({{identifier}})(=)(?!{{operator}})'
captures:
1: string.unquoted.anselme
2: keyword.operator.anselme
- match: '{{identifier}}'
scope: variable.other.anselme
- match: '(?<!\s)\s*(!)\s*({{identifier}})'
captures:
1: keyword.operator.anselme
2: variable.function.anselme
- match: \.
scope: punctuation.accessor.anselme
- match: ','
scope: punctuation.separator.anselme
- match: '{{operator}}'
scope: keyword.operator.anselme
- match: \"
scope: punctuation.definition.string.begin.anselme
push: string
- match: ""
pop: true
# Sub-expressions
string_interpolation:
- clear_scopes: true
- meta_scope: meta.interpolation.anselme
- match: \}
scope: punctuation.section.interpolation.end.anselme
pop: true
- include: expression
string_subtext:
- clear_scopes: true
- meta_scope: meta.brackets.anselme
- meta_content_scope: text.anselme
- match: \]
scope: punctuation.section.brackets.end.anselme
pop: true
- match: '[~#]'
scope: keyword.operator.anselme
push: expression_in_subtext
- include: text
expression_in_subtext:
- match: \]
scope: punctuation.section.brackets.end.anselme
pop: true
- include: expression
string:
- meta_scope: string.quoted.double.anselme
- meta_content_scope: meta.string.anselme
- match: \\.
scope: constant.character.escape.anselme
- match: \"
scope: punctuation.definition.string.end.anselme
pop: true
- include: string_interpolable
paren:
- meta_scope: meta.parens.anselme
- match: \)
scope: punctuation.section.parens.end.anselme
pop: true
- include: expression
list:
- meta_scope: meta.brackets.anselme
- match: \]
scope: punctuation.section.brackets.end.anselme
pop: true
- include: expression
map:
- meta_scope: meta.braces.anselme
- match: \}
scope: punctuation.section.braces.end.anselme
pop: true
- include: expression
# Includes
string_interpolable:
- match: \{
scope: punctuation.section.interpolation.begin.anselme
push: string_interpolation
string_subtextable:
- match: \[
scope: punctuation.section.brackets.begin.anselme
push: string_subtext
pop_on_line_end:
- match: $
pop: true

View file

@ -8,7 +8,7 @@
<key>settings</key> <key>settings</key>
<dict> <dict>
<key>increaseIndentPattern</key> <key>increaseIndentPattern</key>
<string>^\s*[§>~#]</string> <string>^\s*([~#>]|:[$!%])</string>
</dict> </dict>
</dict> </dict>
</plist> </plist>