├── tests
├── fuzz_input
│ ├── 000.wl
│ ├── 001.wl
│ ├── 002.wl
│ ├── 003.wl
│ ├── 004.wl
│ ├── 007.wl
│ ├── 008.wl
│ ├── 009.wl
│ ├── 010.wl
│ ├── 011.wl
│ ├── 012.wl
│ ├── 017.wl
│ ├── 021.wl
│ ├── 024.wl
│ ├── 025.wl
│ ├── 026.wl
│ ├── 027.wl
│ ├── 028.wl
│ ├── 029.wl
│ ├── 030.wl
│ ├── 031.wl
│ ├── 038.wl
│ ├── 039.wl
│ ├── 040.wl
│ ├── 041.wl
│ ├── 042.wl
│ ├── 043.wl
│ ├── 044.wl
│ ├── 045.wl
│ ├── 046.wl
│ ├── 047.wl
│ ├── 048.wl
│ ├── 049.wl
│ ├── 055.wl
│ ├── 057.wl
│ ├── 058.wl
│ ├── 059.wl
│ ├── 060.wl
│ ├── 061.wl
│ ├── 062.wl
│ ├── 063.wl
│ ├── 064.wl
│ ├── 013.wl
│ ├── 014.wl
│ ├── 015.wl
│ ├── 016.wl
│ ├── 018.wl
│ ├── 020.wl
│ ├── 022.wl
│ ├── 023.wl
│ ├── 032.wl
│ ├── 033.wl
│ ├── 034.wl
│ ├── 035.wl
│ ├── 036.wl
│ ├── 037.wl
│ ├── 050.wl
│ ├── 052.wl
│ ├── 053.wl
│ ├── 056.wl
│ ├── 005.wl
│ ├── 006.wl
│ ├── 019.wl
│ ├── 051.wl
│ ├── 065.wl
│ ├── 067.wl
│ ├── 068.wl
│ ├── 069.wl
│ ├── 054.wl
│ ├── 070.wl
│ ├── 071.wl
│ ├── 072.wl
│ ├── 073.wl
│ ├── 074.wl
│ ├── 075.wl
│ ├── 109.wl
│ ├── 066.wl
│ ├── 085.wl
│ ├── 086.wl
│ ├── 094.wl
│ ├── 095.wl
│ ├── 103.wl
│ ├── 090.wl
│ ├── 092.wl
│ ├── 097.wl
│ ├── 102.wl
│ ├── 110.wl
│ ├── 077.wl
│ ├── 078.wl
│ ├── 079.wl
│ ├── 080.wl
│ ├── 082.wl
│ ├── 083.wl
│ ├── 087.wl
│ ├── 088.wl
│ ├── 076.wl
│ ├── 081.wl
│ ├── 111.wl
│ ├── 093.wl
│ ├── 112.wl
│ ├── 091.wl
│ ├── 096.wl
│ ├── 104.wl
│ ├── 105.wl
│ ├── 108.wl
│ ├── 084.wl
│ ├── 106.wl
│ ├── 107.wl
│ ├── 089.wl
│ ├── 098.wl
│ ├── 099.wl
│ ├── 100.wl
│ └── 101.wl
├── fuzz.c
└── test.c
├── .gitignore
├── TODO.md
├── examples
├── loop.wl
├── procedure.wl
└── procedure_2.wl
├── ide
└── vscode
│ └── wl-language
│ ├── language-configuration.json
│ ├── package.json
│ ├── themes
│ └── wl-theme.json
│ └── syntaxes
│ └── wl.tmLanguage.json
├── Makefile
├── main.c
├── wl.h
├── README.md
└── LANGUAGE.md
/tests/fuzz_input/000.wl:
--------------------------------------------------------------------------------
1 | 1
--------------------------------------------------------------------------------
/tests/fuzz_input/001.wl:
--------------------------------------------------------------------------------
1 | 0.4
--------------------------------------------------------------------------------
/tests/fuzz_input/002.wl:
--------------------------------------------------------------------------------
1 | none
--------------------------------------------------------------------------------
/tests/fuzz_input/003.wl:
--------------------------------------------------------------------------------
1 | true
--------------------------------------------------------------------------------
/tests/fuzz_input/004.wl:
--------------------------------------------------------------------------------
1 | false
--------------------------------------------------------------------------------
/tests/fuzz_input/007.wl:
--------------------------------------------------------------------------------
1 | "\\"
--------------------------------------------------------------------------------
/tests/fuzz_input/008.wl:
--------------------------------------------------------------------------------
1 | "\n"
--------------------------------------------------------------------------------
/tests/fuzz_input/009.wl:
--------------------------------------------------------------------------------
1 | "\t"
--------------------------------------------------------------------------------
/tests/fuzz_input/010.wl:
--------------------------------------------------------------------------------
1 | "\r"
--------------------------------------------------------------------------------
/tests/fuzz_input/011.wl:
--------------------------------------------------------------------------------
1 | "\""
--------------------------------------------------------------------------------
/tests/fuzz_input/012.wl:
--------------------------------------------------------------------------------
1 | "\'"
--------------------------------------------------------------------------------
/tests/fuzz_input/017.wl:
--------------------------------------------------------------------------------
1 | +{}
--------------------------------------------------------------------------------
/tests/fuzz_input/021.wl:
--------------------------------------------------------------------------------
1 | 1+2*3
--------------------------------------------------------------------------------
/tests/fuzz_input/024.wl:
--------------------------------------------------------------------------------
1 | 1+2
--------------------------------------------------------------------------------
/tests/fuzz_input/025.wl:
--------------------------------------------------------------------------------
1 | 2-1
--------------------------------------------------------------------------------
/tests/fuzz_input/026.wl:
--------------------------------------------------------------------------------
1 | 1-2
--------------------------------------------------------------------------------
/tests/fuzz_input/027.wl:
--------------------------------------------------------------------------------
1 | 2*3
--------------------------------------------------------------------------------
/tests/fuzz_input/028.wl:
--------------------------------------------------------------------------------
1 | 2/3
--------------------------------------------------------------------------------
/tests/fuzz_input/029.wl:
--------------------------------------------------------------------------------
1 | 4/2
--------------------------------------------------------------------------------
/tests/fuzz_input/030.wl:
--------------------------------------------------------------------------------
1 | 0%2
--------------------------------------------------------------------------------
/tests/fuzz_input/031.wl:
--------------------------------------------------------------------------------
1 | 3%2
--------------------------------------------------------------------------------
/tests/fuzz_input/038.wl:
--------------------------------------------------------------------------------
1 | 1+2.0
--------------------------------------------------------------------------------
/tests/fuzz_input/039.wl:
--------------------------------------------------------------------------------
1 | 2-1.0
--------------------------------------------------------------------------------
/tests/fuzz_input/040.wl:
--------------------------------------------------------------------------------
1 | 1-2.0
--------------------------------------------------------------------------------
/tests/fuzz_input/041.wl:
--------------------------------------------------------------------------------
1 | 2*3.0
--------------------------------------------------------------------------------
/tests/fuzz_input/042.wl:
--------------------------------------------------------------------------------
1 | 2/3.0
--------------------------------------------------------------------------------
/tests/fuzz_input/043.wl:
--------------------------------------------------------------------------------
1 | 4/2.0
--------------------------------------------------------------------------------
/tests/fuzz_input/044.wl:
--------------------------------------------------------------------------------
1 | 1.0+2
--------------------------------------------------------------------------------
/tests/fuzz_input/045.wl:
--------------------------------------------------------------------------------
1 | 2.0-1
--------------------------------------------------------------------------------
/tests/fuzz_input/046.wl:
--------------------------------------------------------------------------------
1 | 1.0-2
--------------------------------------------------------------------------------
/tests/fuzz_input/047.wl:
--------------------------------------------------------------------------------
1 | 2.0*3
--------------------------------------------------------------------------------
/tests/fuzz_input/048.wl:
--------------------------------------------------------------------------------
1 | 2.0/3
--------------------------------------------------------------------------------
/tests/fuzz_input/049.wl:
--------------------------------------------------------------------------------
1 | 4.0/2
--------------------------------------------------------------------------------
/tests/fuzz_input/055.wl:
--------------------------------------------------------------------------------
1 | -12
--------------------------------------------------------------------------------
/tests/fuzz_input/057.wl:
--------------------------------------------------------------------------------
1 | 1<2
--------------------------------------------------------------------------------
/tests/fuzz_input/058.wl:
--------------------------------------------------------------------------------
1 | 2<1
--------------------------------------------------------------------------------
/tests/fuzz_input/059.wl:
--------------------------------------------------------------------------------
1 | 1>2
--------------------------------------------------------------------------------
/tests/fuzz_input/060.wl:
--------------------------------------------------------------------------------
1 | 2>1
--------------------------------------------------------------------------------
/tests/fuzz_input/061.wl:
--------------------------------------------------------------------------------
1 | 1==1
--------------------------------------------------------------------------------
/tests/fuzz_input/062.wl:
--------------------------------------------------------------------------------
1 | 1==2
--------------------------------------------------------------------------------
/tests/fuzz_input/063.wl:
--------------------------------------------------------------------------------
1 | 1!=1
--------------------------------------------------------------------------------
/tests/fuzz_input/064.wl:
--------------------------------------------------------------------------------
1 | 1!=2
--------------------------------------------------------------------------------
/tests/fuzz_input/013.wl:
--------------------------------------------------------------------------------
1 | "\xFF"
--------------------------------------------------------------------------------
/tests/fuzz_input/014.wl:
--------------------------------------------------------------------------------
1 | "\x0F"
--------------------------------------------------------------------------------
/tests/fuzz_input/015.wl:
--------------------------------------------------------------------------------
1 | "\xF0"
--------------------------------------------------------------------------------
/tests/fuzz_input/016.wl:
--------------------------------------------------------------------------------
1 | [1, 2, 3]
--------------------------------------------------------------------------------
/tests/fuzz_input/018.wl:
--------------------------------------------------------------------------------
1 | +{a:1}
--------------------------------------------------------------------------------
/tests/fuzz_input/020.wl:
--------------------------------------------------------------------------------
1 | 10-1-2
--------------------------------------------------------------------------------
/tests/fuzz_input/022.wl:
--------------------------------------------------------------------------------
1 | (1+2)*3
--------------------------------------------------------------------------------
/tests/fuzz_input/023.wl:
--------------------------------------------------------------------------------
1 | 1+(2*3)
--------------------------------------------------------------------------------
/tests/fuzz_input/032.wl:
--------------------------------------------------------------------------------
1 | 1.0+2.0
--------------------------------------------------------------------------------
/tests/fuzz_input/033.wl:
--------------------------------------------------------------------------------
1 | 2.0-1.0
--------------------------------------------------------------------------------
/tests/fuzz_input/034.wl:
--------------------------------------------------------------------------------
1 | 1.0-2.0
--------------------------------------------------------------------------------
/tests/fuzz_input/035.wl:
--------------------------------------------------------------------------------
1 | 2.0*3.0
--------------------------------------------------------------------------------
/tests/fuzz_input/036.wl:
--------------------------------------------------------------------------------
1 | 2.0/3.0
--------------------------------------------------------------------------------
/tests/fuzz_input/037.wl:
--------------------------------------------------------------------------------
1 | 4.0/2.0
--------------------------------------------------------------------------------
/tests/fuzz_input/050.wl:
--------------------------------------------------------------------------------
1 | len []
--------------------------------------------------------------------------------
/tests/fuzz_input/052.wl:
--------------------------------------------------------------------------------
1 | len {}
--------------------------------------------------------------------------------
/tests/fuzz_input/053.wl:
--------------------------------------------------------------------------------
1 | len {a:1}
--------------------------------------------------------------------------------
/tests/fuzz_input/056.wl:
--------------------------------------------------------------------------------
1 | -12.34
--------------------------------------------------------------------------------
/tests/fuzz_input/005.wl:
--------------------------------------------------------------------------------
1 | "Hello, world!"
--------------------------------------------------------------------------------
/tests/fuzz_input/006.wl:
--------------------------------------------------------------------------------
1 | 'Hello, world!'
--------------------------------------------------------------------------------
/tests/fuzz_input/019.wl:
--------------------------------------------------------------------------------
1 | +{a:1,b:2,c:3}
--------------------------------------------------------------------------------
/tests/fuzz_input/051.wl:
--------------------------------------------------------------------------------
1 | len [1, 2, 3]
--------------------------------------------------------------------------------
/tests/fuzz_input/065.wl:
--------------------------------------------------------------------------------
1 | let a = 1
2 | a
--------------------------------------------------------------------------------
/tests/fuzz_input/067.wl:
--------------------------------------------------------------------------------
1 | [5, 6, 7][0]
--------------------------------------------------------------------------------
/tests/fuzz_input/068.wl:
--------------------------------------------------------------------------------
1 | [5, 6, 7][1]
--------------------------------------------------------------------------------
/tests/fuzz_input/069.wl:
--------------------------------------------------------------------------------
1 | [5, 6, 7][2]
--------------------------------------------------------------------------------
/tests/fuzz_input/054.wl:
--------------------------------------------------------------------------------
1 | len {a:1,b:2,c:3}
--------------------------------------------------------------------------------
/tests/fuzz_input/070.wl:
--------------------------------------------------------------------------------
1 | +{a:5,b:6,c:7}.a
--------------------------------------------------------------------------------
/tests/fuzz_input/071.wl:
--------------------------------------------------------------------------------
1 | +{a:5,b:6,c:7}.b
--------------------------------------------------------------------------------
/tests/fuzz_input/072.wl:
--------------------------------------------------------------------------------
1 | +{a:5,b:6,c:7}.c
--------------------------------------------------------------------------------
/tests/fuzz_input/073.wl:
--------------------------------------------------------------------------------
1 | +{a:5,b:6,c:7}['a']
--------------------------------------------------------------------------------
/tests/fuzz_input/074.wl:
--------------------------------------------------------------------------------
1 | +{a:5,b:6,c:7}['b']
--------------------------------------------------------------------------------
/tests/fuzz_input/075.wl:
--------------------------------------------------------------------------------
1 | +{a:5,b:6,c:7}['c']
--------------------------------------------------------------------------------
/tests/fuzz_input/109.wl:
--------------------------------------------------------------------------------
1 | Hello, world!
--------------------------------------------------------------------------------
/tests/fuzz_input/066.wl:
--------------------------------------------------------------------------------
1 | let a = 1
2 | a = 2
3 | a
--------------------------------------------------------------------------------
/tests/fuzz_input/085.wl:
--------------------------------------------------------------------------------
1 | if 1 < 2:
2 | 1
3 | 2
--------------------------------------------------------------------------------
/tests/fuzz_input/086.wl:
--------------------------------------------------------------------------------
1 | if 1 > 2:
2 | 1
3 | 2
--------------------------------------------------------------------------------
/tests/fuzz_input/094.wl:
--------------------------------------------------------------------------------
1 | procedure P()
2 | 0
--------------------------------------------------------------------------------
/tests/fuzz_input/095.wl:
--------------------------------------------------------------------------------
1 | procedure P(a)
2 | a
--------------------------------------------------------------------------------
/tests/fuzz_input/103.wl:
--------------------------------------------------------------------------------
1 | P()
2 | procedure P() 1
--------------------------------------------------------------------------------
/tests/fuzz_input/090.wl:
--------------------------------------------------------------------------------
1 | for a in ['A', 'B', 'C']:
2 | a
--------------------------------------------------------------------------------
/tests/fuzz_input/092.wl:
--------------------------------------------------------------------------------
1 | for a in {x:1,y:2,z:3}:
2 | a
--------------------------------------------------------------------------------
/tests/fuzz_input/097.wl:
--------------------------------------------------------------------------------
1 | procedure P()
2 | 0
3 | P()
--------------------------------------------------------------------------------
/tests/fuzz_input/102.wl:
--------------------------------------------------------------------------------
1 | procedure N(n) n
2 | N(1) + N(2)
--------------------------------------------------------------------------------
/tests/fuzz_input/110.wl:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fuzz_input/077.wl:
--------------------------------------------------------------------------------
1 | let x = {a:5,b:6,c:7}
2 | x.a = true
3 | x
--------------------------------------------------------------------------------
/tests/fuzz_input/078.wl:
--------------------------------------------------------------------------------
1 | let x = {a:5,b:6,c:7}
2 | x.b = true
3 | x
--------------------------------------------------------------------------------
/tests/fuzz_input/079.wl:
--------------------------------------------------------------------------------
1 | let x = {a:5,b:6,c:7}
2 | x.c = true
3 | x
--------------------------------------------------------------------------------
/tests/fuzz_input/080.wl:
--------------------------------------------------------------------------------
1 | let x = {a:5,b:6,c:7}
2 | x['a'] = true
3 | x
--------------------------------------------------------------------------------
/tests/fuzz_input/082.wl:
--------------------------------------------------------------------------------
1 | let x = {a:5,b:6,c:7}
2 | x['c'] = true
3 | x
--------------------------------------------------------------------------------
/tests/fuzz_input/083.wl:
--------------------------------------------------------------------------------
1 | let a
2 | let b
3 | let c
4 | a = b = c = 5
--------------------------------------------------------------------------------
/tests/fuzz_input/087.wl:
--------------------------------------------------------------------------------
1 | if 1 < 2:
2 | 1
3 | else
4 | 2
5 | 3
--------------------------------------------------------------------------------
/tests/fuzz_input/088.wl:
--------------------------------------------------------------------------------
1 | if 1 > 2:
2 | 1
3 | else
4 | 2
5 | 3
--------------------------------------------------------------------------------
/tests/fuzz_input/076.wl:
--------------------------------------------------------------------------------
1 | let x = 1
2 | {
3 | let x = 2
4 | x
5 | }
--------------------------------------------------------------------------------
/tests/fuzz_input/081.wl:
--------------------------------------------------------------------------------
1 | let x = {a:5,b:6,c:7}
2 | x['b'] = true
3 | x
4 |
--------------------------------------------------------------------------------
/tests/fuzz_input/111.wl:
--------------------------------------------------------------------------------
1 | let a =
--------------------------------------------------------------------------------
/tests/fuzz_input/093.wl:
--------------------------------------------------------------------------------
1 | for a, b in {x:1,y:2,z:3}: {
2 | a
3 | b
4 | }
--------------------------------------------------------------------------------
/tests/fuzz_input/112.wl:
--------------------------------------------------------------------------------
1 | let a =
2 | a
--------------------------------------------------------------------------------
/tests/fuzz_input/091.wl:
--------------------------------------------------------------------------------
1 | for a, b in ['A', 'B', 'C']: {
2 | a
3 | b
4 | }
--------------------------------------------------------------------------------
/tests/fuzz_input/096.wl:
--------------------------------------------------------------------------------
1 | procedure P(a, b, c) {
2 | a
3 | b
4 | c
5 | }
--------------------------------------------------------------------------------
/tests/fuzz_input/104.wl:
--------------------------------------------------------------------------------
1 | P()
2 | procedure P() 1
3 | {
4 | procedure P() 2
5 | }
--------------------------------------------------------------------------------
/tests/fuzz_input/105.wl:
--------------------------------------------------------------------------------
1 | procedure P() 1
2 | P()
3 | {
4 | procedure P() 2
5 | }
--------------------------------------------------------------------------------
/tests/fuzz_input/108.wl:
--------------------------------------------------------------------------------
1 | procedure P() 1
2 | {
3 | procedure P() 2
4 | }
5 | P()
--------------------------------------------------------------------------------
/tests/fuzz_input/084.wl:
--------------------------------------------------------------------------------
1 | let a
2 | let b
3 | let c
4 | a = b = c = 5
5 | a
6 | b
7 | c
--------------------------------------------------------------------------------
/tests/fuzz_input/106.wl:
--------------------------------------------------------------------------------
1 | procedure P() 1
2 | {
3 | P()
4 | procedure P() 2
5 | }
--------------------------------------------------------------------------------
/tests/fuzz_input/107.wl:
--------------------------------------------------------------------------------
1 | procedure P() 1
2 | {
3 | procedure P() 2
4 | P()
5 | }
--------------------------------------------------------------------------------
/tests/fuzz_input/089.wl:
--------------------------------------------------------------------------------
1 | let i = 0
2 | while i < 3: {
3 | true
4 | i = i + 1
5 | }
6 |
--------------------------------------------------------------------------------
/tests/fuzz_input/098.wl:
--------------------------------------------------------------------------------
1 | procedure P(a, b, c) {
2 | a
3 | b
4 | c
5 | }
6 | P()
--------------------------------------------------------------------------------
/tests/fuzz_input/099.wl:
--------------------------------------------------------------------------------
1 | procedure P(a, b, c) {
2 | a
3 | b
4 | c
5 | }
6 | P(1)
--------------------------------------------------------------------------------
/tests/fuzz_input/100.wl:
--------------------------------------------------------------------------------
1 | procedure P(a, b, c) {
2 | a
3 | b
4 | c
5 | }
6 | P(1, 2)
--------------------------------------------------------------------------------
/tests/fuzz_input/101.wl:
--------------------------------------------------------------------------------
1 | procedure P(a, b, c) {
2 | a
3 | b
4 | c
5 | }
6 | P(1, 2, 3)
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | a.out
2 | coverage_html/
3 | test
4 | test.exe
5 | test_cov
6 | fuzz
7 | wl
8 | wl.exe
9 | wl_cov
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | * Don't allow [] selections to go over newlines
2 | * Make sure maps and arrays can't be keys of a map
3 | * Decide and document how comments work
4 | * Improve the formatting of the output
5 |
--------------------------------------------------------------------------------
/examples/loop.wl:
--------------------------------------------------------------------------------
1 | let items = ['Apple', 'Orange', 'Strawberry']
2 |
3 | let list =
4 |
5 | \for item in items:
6 | - \{escape item}
7 |
8 |
9 |
10 |
11 | Fruit List
12 |
13 |
14 | My list:
15 | \{list}
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/procedure.wl:
--------------------------------------------------------------------------------
1 |
2 | procedure my_page_template(title, content) {
3 |
4 |
5 | \{escape title}
6 |
7 |
8 | \{content}
9 |
10 |
11 | }
12 |
13 | my_page_template("Welcome to my webpage!", Content of my page)
14 |
--------------------------------------------------------------------------------
/ide/vscode/wl-language/language-configuration.json:
--------------------------------------------------------------------------------
1 | {
2 | "comments": {
3 | "blockComment": [""]
4 | },
5 | "brackets": [
6 | ["{", "}"],
7 | ["[", "]"],
8 | ["(", ")"]
9 | ],
10 | "autoClosingPairs": [
11 | { "open": "{", "close": "}" },
12 | { "open": "[", "close": "]" },
13 | { "open": "(", "close": ")" },
14 | { "open": "\"", "close": "\"" },
15 | { "open": "'", "close": "'" }
16 | ],
17 | "surroundingPairs": [
18 | ["{", "}"],
19 | ["[", "]"],
20 | ["(", ")"],
21 | ["\"", "\""],
22 | ["'", "'"]
23 | ],
24 | "folding": {
25 | "markers": {
26 | "start": "^\\s*",
41 | "patterns": []
42 | }
43 | ]
44 | },
45 | "keywords": {
46 | "patterns": [
47 | {
48 | "name": "keyword.control.wl",
49 | "match": "\\b(if|else|while|for|in)\\b"
50 | },
51 | {
52 | "name": "keyword.other.wl",
53 | "match": "\\b(procedure|let|include)\\b"
54 | },
55 | {
56 | "name": "keyword.operator.wl",
57 | "match": "\\b(len|escape)\\b"
58 | }
59 | ]
60 | },
61 | "constants": {
62 | "patterns": [
63 | {
64 | "name": "constant.language.wl",
65 | "match": "\\b(none|true|false)\\b"
66 | }
67 | ]
68 | },
69 | "strings": {
70 | "patterns": [
71 | {
72 | "name": "string.quoted.double.wl",
73 | "begin": "\"",
74 | "end": "\"",
75 | "patterns": [
76 | {
77 | "name": "constant.character.escape.wl",
78 | "match": "\\\\(n|t|r|\"|'|\\\\|x[0-9A-Fa-f]{2})"
79 | }
80 | ]
81 | },
82 | {
83 | "name": "string.quoted.single.wl",
84 | "begin": "'",
85 | "end": "'",
86 | "patterns": [
87 | {
88 | "name": "constant.character.escape.wl",
89 | "match": "\\\\(n|t|r|\"|'|\\\\|x[0-9A-Fa-f]{2})"
90 | }
91 | ]
92 | }
93 | ]
94 | },
95 | "numbers": {
96 | "patterns": [
97 | {
98 | "name": "constant.numeric.float.wl",
99 | "match": "\\b[0-9]+\\.[0-9]+\\b"
100 | },
101 | {
102 | "name": "constant.numeric.integer.wl",
103 | "match": "\\b[0-9]+\\b"
104 | }
105 | ]
106 | },
107 | "operators": {
108 | "patterns": [
109 | {
110 | "name": "keyword.operator.append.wl",
111 | "match": "<<"
112 | },
113 | {
114 | "name": "keyword.operator.comparison.wl",
115 | "match": "(==|!=|<=|>=)"
116 | },
117 | {
118 | "name": "keyword.operator.relational.wl",
119 | "match": "(<|>)"
120 | },
121 | {
122 | "name": "keyword.operator.assignment.wl",
123 | "match": "="
124 | },
125 | {
126 | "name": "keyword.operator.arithmetic.wl",
127 | "match": "(\\+|-|\\*|/|%)"
128 | }
129 | ]
130 | },
131 | "system-variables": {
132 | "patterns": [
133 | {
134 | "name": "variable.other.system.wl",
135 | "match": "\\$[a-zA-Z_][a-zA-Z0-9_]*"
136 | }
137 | ]
138 | },
139 | "functions": {
140 | "patterns": [
141 | {
142 | "name": "entity.name.function.wl",
143 | "match": "\\b[a-zA-Z_][a-zA-Z0-9_]*(?=\\s*\\()"
144 | }
145 | ]
146 | },
147 | "html-tags": {
148 | "patterns": [
149 | {
150 | "name": "meta.tag.html.wl",
151 | "begin": "(<)([a-zA-Z][a-zA-Z0-9]*)",
152 | "beginCaptures": {
153 | "1": {
154 | "name": "punctuation.definition.tag.begin.wl"
155 | },
156 | "2": {
157 | "name": "entity.name.tag.wl"
158 | }
159 | },
160 | "end": "(/>)|(>)",
161 | "endCaptures": {
162 | "1": {
163 | "name": "punctuation.definition.tag.self-closing.wl"
164 | },
165 | "2": {
166 | "name": "punctuation.definition.tag.end.wl"
167 | }
168 | },
169 | "patterns": [
170 | {
171 | "name": "string.quoted.double.html.wl",
172 | "begin": "\"",
173 | "end": "\"",
174 | "patterns": [
175 | {
176 | "include": "#embedded-expression"
177 | }
178 | ]
179 | },
180 | {
181 | "name": "string.quoted.single.html.wl",
182 | "begin": "'",
183 | "end": "'",
184 | "patterns": [
185 | {
186 | "include": "#embedded-expression"
187 | }
188 | ]
189 | },
190 | {
191 | "include": "#embedded-expression"
192 | }
193 | ]
194 | },
195 | {
196 | "name": "meta.tag.closing.html.wl",
197 | "match": "()([a-zA-Z][a-zA-Z0-9]*)(>)",
198 | "captures": {
199 | "1": {
200 | "name": "punctuation.definition.tag.begin.wl"
201 | },
202 | "2": {
203 | "name": "entity.name.tag.wl"
204 | },
205 | "3": {
206 | "name": "punctuation.definition.tag.end.wl"
207 | }
208 | }
209 | }
210 | ]
211 | },
212 | "embedded-expression": {
213 | "patterns": [
214 | {
215 | "name": "meta.embedded.block.wl",
216 | "begin": "\\\\\\{",
217 | "end": "\\}",
218 | "patterns": [
219 | {
220 | "include": "#expression-contents"
221 | }
222 | ]
223 | },
224 | {
225 | "name": "meta.embedded.wl",
226 | "begin": "\\\\",
227 | "end": "(?=[\\s\"'/>])",
228 | "patterns": [
229 | {
230 | "include": "#expression-contents"
231 | }
232 | ]
233 | }
234 | ]
235 | },
236 | "expression-contents": {
237 | "patterns": [
238 | {
239 | "include": "#keywords"
240 | },
241 | {
242 | "include": "#strings"
243 | },
244 | {
245 | "include": "#numbers"
246 | },
247 | {
248 | "include": "#operators"
249 | },
250 | {
251 | "include": "#system-variables"
252 | },
253 | {
254 | "include": "#functions"
255 | },
256 | {
257 | "include": "#constants"
258 | },
259 | {
260 | "include": "#brackets"
261 | }
262 | ]
263 | },
264 | "brackets": {
265 | "patterns": [
266 | {
267 | "begin": "\\[",
268 | "end": "\\]",
269 | "patterns": [
270 | {
271 | "include": "#keywords"
272 | },
273 | {
274 | "include": "#strings"
275 | },
276 | {
277 | "include": "#numbers"
278 | },
279 | {
280 | "include": "#operators"
281 | },
282 | {
283 | "include": "#system-variables"
284 | },
285 | {
286 | "include": "#functions"
287 | },
288 | {
289 | "include": "#constants"
290 | },
291 | {
292 | "include": "#brackets"
293 | }
294 | ]
295 | },
296 | {
297 | "begin": "\\{",
298 | "end": "\\}",
299 | "patterns": [
300 | {
301 | "include": "#keywords"
302 | },
303 | {
304 | "include": "#strings"
305 | },
306 | {
307 | "include": "#numbers"
308 | },
309 | {
310 | "include": "#operators"
311 | },
312 | {
313 | "include": "#system-variables"
314 | },
315 | {
316 | "include": "#functions"
317 | },
318 | {
319 | "include": "#constants"
320 | },
321 | {
322 | "include": "#brackets"
323 | }
324 | ]
325 | },
326 | {
327 | "begin": "\\(",
328 | "end": "\\)",
329 | "patterns": [
330 | {
331 | "include": "#keywords"
332 | },
333 | {
334 | "include": "#strings"
335 | },
336 | {
337 | "include": "#numbers"
338 | },
339 | {
340 | "include": "#operators"
341 | },
342 | {
343 | "include": "#system-variables"
344 | },
345 | {
346 | "include": "#functions"
347 | },
348 | {
349 | "include": "#constants"
350 | },
351 | {
352 | "include": "#brackets"
353 | }
354 | ]
355 | }
356 | ]
357 | }
358 | }
359 | }
--------------------------------------------------------------------------------
/LANGUAGE.md:
--------------------------------------------------------------------------------
1 | # WL Language Manual
2 |
3 | ## WL Programs
4 |
5 | A WL program is composed by zero or more statements, which may include
6 |
7 | 1. Expressions
8 | 2. If-else conditionals
9 | 3. While loops
10 | 4. For loops
11 | 5. Variable declarations
12 | 6. Procedure declarations
13 | 7. Code Blocks
14 | 8. External file inclusions
15 |
16 | Note that statements have no separators. To avoid ambiguities, it is useful to split statements over multiple lines.
17 |
18 | The output of a program is defined as the cumulative results of all expressions evaluated in the global scope.
19 |
20 | ## Expressions
21 |
22 | Programs operate on a set of types that one would expect from a scripting language:
23 | * integers
24 | * floats
25 | * booleans
26 | * none (equivalent to null)
27 | * strings
28 | * arrays
29 | * maps (equivalent to dicts in Python and associative arrays in PHP)
30 |
31 | ### Integers and Floats
32 |
33 | Integers are encoded as 64 bits signed, and therefore can encode the same value as an `int64_t` in C.
34 |
35 | Similarly, floats are also encoded over 64 bits and can encode the same precision of a `double` in C.
36 |
37 | The usual aritmethic operators are available
38 |
39 | ```
40 | 3.5 + 4
41 | 3.5 - 4
42 | 3.5 * 4
43 | 3.5 / 4
44 | ```
45 |
46 | Aritmethic operations between integers, with the exception of division, also return integers. Any operation involving a float, or a division, will also return a float.
47 |
48 | The modulo operator is also available for integers, which returns the division remainder
49 |
50 | ```
51 | 101 % 10
52 | ```
53 |
54 | You can use the unary plus and minus to express the sign of a numeric literal
55 |
56 | ```
57 | +100
58 | -100
59 | ```
60 |
61 | The plus can generally be omitted as it does nothing.
62 |
63 | ### Booleans
64 |
65 | Boolean values work as you would expect. These are the true and false literals:
66 |
67 | ```
68 | true
69 | false
70 | ```
71 |
72 | You can use comparison operators to produce true and false values
73 |
74 | ```
75 | 1 < 2
76 | 1 > 2
77 | 1 == 2
78 | 1 != 2
79 | ```
80 |
81 | Note that the `>=` and `<=` operators are not implemented yet as I never needed them up to now. The same goes for `and` and `or`.
82 |
83 | The ordering operators `<` and `>` may only be used on numeric values, while `==` and `!=` are allowed on any type.
84 |
85 | ### None
86 |
87 | The none value is usually referred to as "null" or "nil" in other languages. It's only quality is being equal to itself and may be used to encode the absence of a value.
88 |
89 | You can encode the none literal using the keyword
90 | ```
91 | none
92 | ```
93 |
94 | ### Strings
95 |
96 | Strings are sequence of characters delimited by single or double quotes. They can only contain printable ASCII characters (bytes from 32 to 127).
97 |
98 | ```
99 | "Hello, world!"
100 | 'Hello, world!'
101 | ```
102 |
103 | Any character outside the printable ASCII range must be encoded with its hexadecimal representation prefixed by `\x`. For instance, let's say we wanted to write the FF byte
104 |
105 | ```
106 | "This byte is not printable: \xFF"
107 | ```
108 |
109 | Some special characters that are not within the printable range may be escaped using their own specific escape sequence
110 |
111 | ```
112 | "This is a newline \n"
113 | "This is an horizontal tab \t"
114 | "This is a carriage return \r"
115 | ```
116 |
117 | Although the `'` and `"` characters are printable, they may interfere with the string delimiters, therefore strings the contain `'` characters should be delimited with `"` and viceversa. When avoiding the ambiguity is not possible, the `'` and `"` may themselves be escaped
118 |
119 | ```
120 | " This is a double quote \" "
121 | ' This is a single quote \' '
122 | ```
123 |
124 | Since the `\` character is used to escape other character, when used as its own character it also needs to be escaped
125 |
126 | ```
127 | " This is a backslash \\ "
128 | ```
129 |
130 | Note that the requirement that strings only contain printable characters implies that strings can't span multiple lines of source code. In other words, this doesn't work:
131 |
132 | ```
133 | "This
134 | is
135 | not
136 | valid"
137 | ```
138 |
139 | ### Arrays
140 |
141 | Arrays represent an ordered sequence of values which may have different types from each other. They are defined using square brackets and commas as separators.
142 |
143 | ```
144 | [1, 2.3, none]
145 | ```
146 |
147 | Trailing commas are supported
148 |
149 | ```
150 | [1, 2, 3,]
151 | ```
152 |
153 | To insert new values into an array you use the shovel operator
154 |
155 | ```
156 | [1, 2, 3] << 4
157 | ```
158 |
159 | When evaluated into the global scope, arrays are output as the concatenation of their elements, which means they are useful to perform lazy concatenation of strings.
160 |
161 | To select an element by its index (indices start at zero) you use the []-style selection. For instance the following returns `2`:
162 |
163 | ```
164 | [1, 2, 3][1]
165 | ```
166 |
167 | ### Maps
168 |
169 | Maps are the equivalent of dicts in Python and use a similar syntax:
170 |
171 | ```
172 | +{ 'name': 'Alice', 'color': 'red' }
173 | ```
174 |
175 | They are defined within curly braces and contain a list of zero or more key-value pairs separated by colons and commas. The `+` at the start is not part of the map, it's only used in the global scope to disambiguate with curly braces used for creating scopes and maps. By using an unary `+` we make explicit that we are writing an expression. Map objects are generally not considered as printable, and therefore defining them as we are would just output the string `