diff --git a/Anselme.sublime-syntax b/Anselme.sublime-syntax
index a3f58b9..c2e1176 100755
--- a/Anselme.sublime-syntax
+++ b/Anselme.sublime-syntax
@@ -1,237 +1,258 @@
%YAML 1.2
---
-# http://www.sublimetext.com/docs/3/syntax.html
-name: Anselme
-comment: "Anselme v25, and probably later, syntax"
+name: anselme v2
file_extensions:
- ans
- anselme
scope: source.anselme
+version: 2
variables:
- identifier: '[^\~\`\^\+\-\=\<\>\/\[\]\*\{\}\|\\\_\!\?\,\;\:\(\)\"\@\&\$\#\%\.\d\s][^\~\`\^\+\-\=\<\>\/\[\]\*\{\}\|\\\_\!\?\,\;\:\(\)\"\@\&\$\#\%\.]*'
- operator: '[;:=+-/*%^,~?#|&!>\/\[\]\*\{\}\|\\\_\!\?\,\;\:\(\)\"\@\&\$\#\%'
+ identifier: |-
+ (?x:
+ [^0-9\s\'{{identifier_disallowed}}][^{{identifier_disallowed}}]*
+ |\_( \! | \- | \* | \~ )
+ |( \! )\_
+ |\_( \|\> | \+ | \- | \/ | \/\/ | \* | \^ | \% | \& | \| | \=\= | \= | \!\= | \>\= | \<\= | \< | \> | \~ | \~\? | \. | \:\: | \# | \: )\_
+ )
contexts:
- # Line types
+ prototype:
+ - match: '\(\('
+ scope: comment.line.anselme punctuation.definition.comment.anselme
+ push: comment
+ - match: '\s+'
+ - match: '$'
+ pop: true
+
main:
- - match: ^\s*\(.*$
- scope: comment.line.anselme
- - match: ^\s*~[~?]?
- scope: keyword.control.conditional.anselme
- push: expression
- - match: ^\s*@
- scope: keyword.control.anselme
- push: expression
- - match: ^\s*#
- scope: keyword.other.anselme
- push: expression
- - match: ^\s*\>
- scope: keyword.control.conditional.anselme
- push: text
- - match: ^\s*:~?[$!%]
- scope: keyword.other.anselme
- push: function_definition_start
- - match: ^\s*\:~?
- scope: keyword.other.anselme
- push: variable_definition_start
- - match: ^\s*
- push: text
+ - match: ''
+ push: primary
- # Text lines
- text:
- - meta_scope: text.anselme
- - match: \\.
- scope: constant.character.escape.anselme
- - match: '[~#]'
- scope: keyword.operator.anselme
- push: expression
- - include: string_interpolable
- - include: string_subtextable
- - include: pop_on_line_end
-
- # Function definition
- function_definition_start:
- - meta_scope: meta.function.anselme
- - match: '({{identifier}}|_?{{operator}}_?|\{\}|\(\))(?:(:)({{identifier}}))?'
- captures:
- 1: entity.name.function.anselme
- 2: punctuation.separator.anselme
- 3: entity.name.function.anselme
- set: function_definition_args
- - include: pop_on_line_end
- function_definition_args:
- - match: \(
- scope: punctuation.section.parens.start.anselme
- set: parameter_paren
- - include: pop_on_line_end
- parameter_paren:
- - meta_scope: meta.function.parameters.anselme
- - match: '({{identifier}})(?:(:)({{identifier}}))?(=|::)'
- captures:
- 1: variable.parameter.anselme
- 2: punctuation.separator.anselme
- 3: variable.parameter.anselme
- 4: keyword.operator.anselme
- push: parameter_default
- - match: '({{identifier}})(?:(:)({{identifier}}))?'
- captures:
- 1: variable.parameter.anselme
- 2: punctuation.separator.anselme
- 3: variable.parameter.anselme
- - match: ','
- scope: punctuation.separator.anselme
- - match: \)
- scope: punctuation.section.parens.end.anselme
+ comment:
+ - meta_scope: comment.line.anselme
+ - match: '\(\('
+ scope: punctuation.definition.comment.anselme
+ push: comment
+ - match: '\)\)|$'
+ scope: punctuation.definition.comment.anselme
pop: true
- - include: pop_on_line_end
- 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: '(@?)\s*({{identifier}})(?:(:)({{identifier}}))?'
- captures:
- 1: keyword.other.anselme
- 2: variable.other.anselme
- 3: punctuation.separator.anselme
- 4: 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
+ ## Primary elements ##
- # Expressions
- expression:
- - match: \s+
- - match: \d*\.\d+|\d+
+ primary:
+ - 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: string_subtext
- - 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: '(?'
+ scope: keyword.control.conditional.anselme
+ push: primary
+ - match: '\#|\:\:|\:'
+ scope: keyword.operator.anselme
+ push: primary
+ - match: '\&|\|'
+ scope: keyword.operator.logical.anselme
+ push: primary
+ - match: '\=\=|\!\=|\<\=|\>\=|\<|\>'
+ scope: keyword.operator.comparison.anselme
+ push: primary
+ - match: '\+|\-|\*|\/\/|\/|\%|\^'
+ scope: keyword.operator.arithmetic.anselme
+ push: primary
+ - match: '\.'
+ scope: punctuation.accessor.anselme
+ push: primary
+ - match: '(\!)\s*({{identifier}})'
+ scope: meta.function-call
+ captures:
+ 1: keyword.operaor.anselme
+ 2: variable.function.anselme
+ set: secondary
+ - match: '\!'
+ scope: keyword.operaor.anselme
+ push: primary
+ - match: '\='
+ scope: keyword.operator.assignment.anselme
+ push: primary
+ - include: suffix_secondary
+ - match: ''
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
\ No newline at end of file
+ suffix_secondary:
+ - match: '\;'
+ scope: keyword.control.anselme
+ set: secondary
+ - match: '\!'
+ scope: keyword.operator.anselme
+ set: secondary
+ - match: '\('
+ scope: punctuation.section.arguments.begin.anselme
+ set:
+ - match: '\)'
+ scope: punctuation.section.arguments.end.anselme
+ set: secondary
+ - include: primary
diff --git a/Comments.tmPreferences b/Comments.tmPreferences
index 5b52388..1b43c0a 100644
--- a/Comments.tmPreferences
+++ b/Comments.tmPreferences
@@ -13,7 +13,7 @@
name
TM_COMMENT_START
value
- (
+ ((
diff --git a/Indent.tmPreferences b/Indent.tmPreferences
index 3782af0..d150afd 100644
--- a/Indent.tmPreferences
+++ b/Indent.tmPreferences
@@ -8,7 +8,7 @@
settings
increaseIndentPattern
- ^\s*([~#>]|:[$!%])
+ (^.*(\$|\@|\~|\~\?|\|\>|\#|\=)\s*$)|^\s*(\:\:?[\@\!]?\$.*$)