about summary refs log tree commit diff stats
path: root/js/baba-yaga/dev/sublime/Baba Yaga.sublime-syntax
blob: 532565121dda58d210af09f20125a74ba2086afc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
%YAML 1.2
---
name: Baba Yaga
file_extensions: [baba]
scope: source.baba-yaga

variables:
  identifier: '[a-zA-Z_][a-zA-Z0-9_]*'

contexts:
  main:
    - include: comments
    - include: strings
    - include: numbers
    - include: keywords
    - include: operators
    - include: functions
    - include: variables
    - include: types
    - include: with-blocks
    - include: when-expressions

  comments:
    - match: '//.*$'
      scope: comment.line.double-slash.baba-yaga
    - match: '/\*'
      push:
        - meta_scope: comment.block.baba-yaga
        - match: '\*/'
          pop: true

  strings:
    - match: '"'
      push:
        - meta_scope: string.quoted.double.baba-yaga
        - match: '\\\\.'
          scope: constant.character.escape.baba-yaga
        - match: '"'
          pop: true

  numbers:
    - match: '\b\d+\b'
      scope: constant.numeric.integer.baba-yaga
    - match: '\b\d+\.\d+\b'
      scope: constant.numeric.float.baba-yaga

  keywords:
    - match: '\b(when|then|is|Ok|Err|true|false|PI|INFINITY|and|or|xor)\b'
      scope: keyword.control.baba-yaga
    - match: '\b(append|set|merge|shape|map|filter|reduce)\b'
      scope: keyword.operator.baba-yaga
    - match: '\b(io\.out|io\.in|str\.concat|str\.split|str\.join|str\.length|str\.substring|str\.replace|str\.trim|str\.upper|str\.lower|math\.abs|math\.sign|math\.floor|math\.ceil|math\.round|math\.trunc|math\.min|math\.max|math\.clamp|math\.pow|math\.sqrt|math\.exp|math\.log|math\.sin|math\.cos|math\.tan|math\.asin|math\.acos|math\.atan|math\.atan2|math\.deg|math\.rad|math\.random|math\.randomInt)\b'
      scope: keyword.other.baba-yaga

  operators:
    - match: '(\+|-|\*|/|%)'
      scope: keyword.operator.arithmetic.baba-yaga
    - match: '(=|!=|>|<|>=|<=)'
      scope: keyword.operator.comparison.baba-yaga
    - match: ':'
      scope: keyword.operator.assignment.baba-yaga
    - match: '->'
      scope: keyword.operator.function.baba-yaga
    - match: '\.\.'
      scope: keyword.operator.string.baba-yaga

  functions:
    - match: '\b([a-zA-Z_][a-zA-Z0-9_]*)\s*:'
      captures:
        1: entity.name.function.baba-yaga
    - match: '\('
      push:
        - meta_scope: meta.function.anonymous.baba-yaga
        - match: '\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
          scope: variable.parameter.baba-yaga
        - include: operators
        - match: '\)'
          pop: true

  variables:
    - match: '\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
      scope: variable.other.baba-yaga

  types:
    - match: '\b(Bool|Int|Float|String|List|Table|Result|Number)\b'
      scope: storage.type.baba-yaga

  with-blocks:
    - match: '\bwith\b'
      push:
        - meta_scope: meta.with-block.baba-yaga
        - match: '\bwith\b'
          scope: keyword.control.with.baba-yaga
        - match: '\brec\b'
          scope: keyword.control.with-rec.baba-yaga
        - match: '\('
          scope: punctuation.definition.block.begin.baba-yaga
        - match: '\)\s*->'
          scope: keyword.operator.function.baba-yaga
          pop: true
        - include: with-block-entries
        - include: comments
        - include: strings
        - include: numbers
        - include: operators
        - include: types

  with-block-entries:
    - match: '\b([a-zA-Z_][a-zA-Z0-9_]*)\s*:'
      captures:
        1: variable.other.with-local.baba-yaga
      push:
        - meta_scope: meta.with-block-entry.baba-yaga
        - match: ';'
          scope: punctuation.terminator.semicolon.baba-yaga
          pop: true
        - include: when-expressions
        - include: comments
        - include: strings
        - include: numbers
        - include: operators
        - include: types

  when-expressions:
    - match: '\bwhen\b'
      push:
        - meta_scope: meta.when-expression.baba-yaga
        - match: '\bwhen\b'
          scope: keyword.control.when.baba-yaga
        - match: '\bthen\b'
          scope: keyword.control.then.baba-yaga
        - match: '\bis\b'
          scope: keyword.control.is.baba-yaga
        - match: '\b_\b'
          scope: constant.language.wildcard.baba-yaga
        - include: strings
        - include: numbers
        - include: variables
        - match: ';'
          pop: true