Andy73

Luigi.sublime-syntax

Mar 13th, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 8.83 KB | None | 0 0
  1. %YAML 1.2
  2. ---
  3. # See http://www.sublimetext.com/docs/3/syntax.html
  4. file_extensions:
  5.  - lgi
  6. scope: source.luigi
  7.  
  8. variables:
  9.   ident: '\b[\w@\$_][\w\d@\$_]*''*'
  10.   type: '{{ident}}'
  11.  
  12. contexts:
  13.  # The prototype context is prepended to all contexts but those setting
  14.   # meta_include_prototype: false.
  15.   prototype:
  16.     - include: comment
  17.  
  18.   main:
  19.    # The main context is the initial starting point of our syntax.
  20.     # Include other contexts from here (or specify them directly).
  21.     - include: expression
  22.  
  23.   expression:
  24.     - include: number-literal
  25.     - include: boolean-literal
  26.     - include: string-literal
  27.     - include: operator
  28.     - include: built-in-macros
  29.     - match: '({{ident}})\s*(\!)'
  30.       captures:
  31.         1: support.function.luigi
  32.         2: meta.preprocessor.luigi
  33.       push: macro
  34.     - match: '({{ident}})\s*(\()'
  35.       captures:
  36.         1: variable.function.call.luigi
  37.         2: punctuation.section.parens.begin.luigi
  38.       push: tuple
  39.     - match: '{{ident}}'
  40.       scope: variable.other.member.luigi
  41.     - match: '\('
  42.       scope: punctuation.section.parens.begin.luigi
  43.       push: tuple
  44.     - match: '\{'
  45.       scope: punctuation.section.block.begin.luigi
  46.       push: block
  47.     - match: '\['
  48.       scope: punctuation.section.brackets.begin.luigi
  49.       push: array-literal
  50.     - match: '(~>|=>)'
  51.       scope: keyword.operator.binding.luigi
  52.       push: binding-rhs
  53.     - match: '[~=]'
  54.       scope: keyword.operator.binding.luigi
  55.       push: binding
  56.     - match: ';?'
  57.       scope: punctuation.terminator.luigi
  58.  
  59.   operator:
  60.     - match: '[\*\+\-/]'
  61.       scope: keyword.operator.arithmetic.luigi
  62.     - match: '(==|!=|<=|>=|<|>)'
  63.       scope: keyword.operator.comparison.luigi
  64.     - match: '\.'
  65.       scope: punctuation.accessor.dot.luigi
  66.  
  67.   block:
  68.     - include: expression
  69.     - match: '\}'
  70.       scope: punctuation.section.block.end.luigi
  71.       pop: true
  72.  
  73.   array-literal:
  74.     - include: expression
  75.     - match: ',\s*'
  76.       scope: punctuation.separator.sequence.luigi
  77.     - match: '\]'
  78.       scope: punctuation.section.brackets.end.luigi
  79.       pop: true
  80.  
  81.   number-literal:
  82.     - match: '\b(-)?[0-9]+\.?[0-9]*\b'
  83.       scope: constant.numeric.luigi
  84.  
  85.   boolean-literal:
  86.     - match: '\b(true|false)\b'
  87.       scope: constant.language.luigi
  88.  
  89.   string-literal:
  90.    # Strings begin and end with quotes, and use backslashes as an escape
  91.     # character.
  92.     - match: '"'
  93.      scope: punctuation.definition.string.begin.luigi
  94.      push: inside-string-literal
  95.  
  96.  inside-string-literal:
  97.    - meta_include_prototype: false
  98.    - meta_scope: string.quoted.double.luigi
  99.    - match: '\.'
  100.      scope: constant.character.escape.luigi
  101.    - match: '"'
  102.       scope: punctuation.definition.string.end.luigi
  103.       pop: true
  104.  
  105.   comment:
  106.    # Comments begin with a '--' and finish at the end of the line.
  107.     # '-->' matches too to enable ligatures
  108.     - match: '-->?'
  109.       scope: punctuation.definition.comment.luigi
  110.       push:
  111.        # This is an anonymous context push for brevity.
  112.         - meta_scope: comment.line.double-dash.luigi
  113.         - match: $\n?
  114.           pop: true
  115.  
  116.   binding:
  117.     - match: '\['
  118.       scope: punctuation.definition.parameters.begin.luigi
  119.       set: binding-parameters
  120.     - match: '\('
  121.       scope: punctuation.section.parens.begin.luigi
  122.       push: binding-listeners
  123.     - match: '<'
  124.       scope: punctuation.section.generic.begin.luigi
  125.       push: binding-type
  126.     - match: '>'
  127.       scope: keyword.operator.binding.luigi
  128.       set: binding-rhs
  129.  
  130.   binding-parameters:
  131.     - match: '(({{ident}})\s*(:))?\s*({{ident}})'
  132.       captures:
  133.         2: storage.type.luigi
  134.         3: punctuation.separator.mapping.key-value.luigi
  135.         4: variable.parameter.function.luigi
  136.     - match: ','
  137.       scope: punctuation.separator.sequence.luigi
  138.     - match: '\]'
  139.       scope: punctuation.definition.parameters.end.luigi
  140.       set: binding-parametrised
  141.  
  142.   binding-parametrised:
  143.     - match: '\('
  144.       scope: punctuation.section.parens.begin.luigi
  145.       push: binding-listeners
  146.     - match: '<'
  147.       scope: punctuation.section.generic.begin.luigi
  148.       push: binding-type
  149.     - match: '>'
  150.       scope: keyword.operator.binding.luigi
  151.       set: binding-parametrised-rhs
  152.  
  153.   binding-listeners:
  154.     - match: '{{ident}}'
  155.       scope: variable.language.luigi
  156.     - match: ','
  157.       scope: punctuation.separator.mapping.key-value.luigi
  158.     - match: '\)'
  159.       scope: punctuation.section.parens.end.luigi
  160.       pop: true
  161.  
  162.   binding-type:
  163.     - match: '{{ident}}'
  164.       scope: storage.type.luigi
  165.     - match: ','
  166.       scope: punctuation.separator.sequence.luigi
  167.     - match: '>'
  168.       scope: punctuation.section.generic.end.luigi
  169.       pop: true
  170.  
  171.   binding-rhs:
  172.     - match: '\('
  173.       scope: punctuation.section.parens.begin.luigi
  174.       set: tuple
  175.     - match: '({{ident}})'
  176.       scope: variable.other.member.luigi
  177.       pop: true
  178.  
  179.   binding-parametrised-rhs:
  180.     - match: '\('
  181.       scope: punctuation.section.parens.begin.luigi
  182.       set: tuple-fn
  183.     - match: '{{ident}}'
  184.       scope: variable.other.member.luigi entity.name.function.luigi
  185.       pop: true
  186.  
  187.   tuple:
  188.     - include: expression
  189.     - match: ','
  190.       scope: punctuation.separator.sequence.luigi
  191.     - match: '\)'
  192.       scope: punctuation.section.parens.end.luigi
  193.       pop: true
  194.  
  195.   tuple-fn:
  196.     - match: '{{ident}}'
  197.       scope: variable.other.member.luigi entity.name.function.luigi
  198.     - match: ','
  199.       scope: punctuation.separator.sequence.luigi
  200.     - match: '\)'
  201.       scope: punctuation.section.parens.end.luigi
  202.       pop: true
  203.  
  204.   macro:
  205.     - match: '{{ident}}'
  206.       scope: entity.other.attribute-name.luigi
  207.     - match: '\['
  208.       scope: punctuation.section.brackets.begin.luigi
  209.       push: macro-square
  210.     - match: '\('
  211.       scope: punctuation.section.parens.begin.luigi
  212.       push: macro-paren
  213.     - match: '<'
  214.       scope: punctuation.section.generic.begin.luigi
  215.       push: macro-angled
  216.     - match: '{'
  217.       scope: punctuation.section.block.begin.luigi
  218.       push: macro-curly
  219.     - match: ';?'
  220.       scope: punctuation.terminator.luigi
  221.       pop: true
  222.  
  223.   macro-square:
  224.     - match: '\['
  225.       scope: punctuation.section.brackets.begin.luigi
  226.       push: macro-square
  227.     - match: '\]'
  228.       scope: punctuation.section.brackets.end.luigi
  229.       pop: true
  230.  
  231.   macro-paren:
  232.     - match: '\('
  233.       scope: punctuation.section.parens.begin.luigi
  234.       push: macro-paren
  235.     - match: '\)'
  236.       scope: punctuation.section.parens.end.luigi
  237.       pop: true
  238.  
  239.   macro-angled:
  240.     - match: '<'
  241.       scope: punctuation.section.generic.begin.luigi
  242.     - match: '>'
  243.       scope: punctuation.section.generic.end.luigi
  244.       pop: true
  245.  
  246.   macro-curly:
  247.     - match: '{'
  248.       scope: punctuation.section.block.begin.luigi
  249.     - match: '}'
  250.       scope: punctuation.section.block.end.luigi
  251.       pop: true
  252.  
  253.   built-in-macros:
  254.     - match: '(print)\s*(\!)'
  255.       captures:
  256.         1: support.function.luigi
  257.         2: meta.preprocessor.luigi
  258.       push: built-in-print
  259.     - match: '(fn)\s*(\!)'
  260.       captures:
  261.         1: keyword.control.flow.luigi
  262.         2: meta.preprocessor.luigi
  263.       push: built-in-fn
  264.     - match: '(for)\s*(\!)'
  265.       captures:
  266.         1: keyword.control.flow.luigi
  267.         2: meta.preprocessor.luigi
  268.       push: built-in-for
  269.  
  270.   built-in-print:
  271.     - match: '\('
  272.       scope: punctuation.section.parens.begin.luigi
  273.       set: tuple
  274.  
  275.   built-in-fn:
  276.     - match: '{{ident}}'
  277.       scope: variable.function.luigi entity.name.function.luigi
  278.     - match: '\('
  279.       scope: punctuation.section.parens.begin.luigi
  280.       push: built-in-fn-params
  281.     - match: '<'
  282.       scope: punctuation.section.generic.begin.luigi
  283.       push: binding-type
  284.     - match: '{'
  285.       scope: punctuation.section.block.begin.luigi
  286.       set: block
  287.       # BUG: Uncomment this section to make ST3 run out of memory
  288. #      with_prototype:
  289. #        - match: '\breturn\b'
  290. #          scope: keyword.control.flow.luigi
  291.  
  292.   built-in-fn-params:
  293.     - match: '(({{ident}})\s*(:))?\s*({{ident}})'
  294.       captures:
  295.         2: storage.type.luigi
  296.         3: punctuation.separator.mapping.key-value.luigi
  297.         4: variable.parameter.function.luigi
  298.     - match: ','
  299.       scope: punctuation.separator.sequence.luigi
  300.     - match: '\)'
  301.       scope: punctuation.definition.parameters.end.luigi
  302.       pop: true
  303.  
  304.   built-in-for:
  305.     - match: '\('
  306.       scope: punctuation.section.parens.begin.luigi
  307.       push:
  308.         - match: '\('
  309.           scope: punctuation.section.parens.begin.luigi
  310.           push: tuple
  311.         - match: '\bin\b'
  312.           scope: keyword.control.flow.luigi
  313.         - match: '\)'
  314.           scope: punctuation.section.parens.end.luigi
  315.           pop: true
  316.     - match: '\{'
  317.       scope: punctuation.section.block.begin.luigi
  318.       set: block
Advertisement
Add Comment
Please, Sign In to add comment