-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheem-parser.pegjs
More file actions
50 lines (40 loc) · 1.02 KB
/
scheem-parser.pegjs
File metadata and controls
50 lines (40 loc) · 1.02 KB
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
start =
expression
expression =
atom
/ listatom
/ nestedlist
validchar
= [0-9a-zA-Z_?!+\-=@#$%^&*/.]
atom =
chars:validchar+
{ return chars.join(""); }
listatom =
"(" space* natom:atom satom:spaceatom* space* ")"
{ if (satom && satom.length) {
satom.unshift(natom);
return satom;
} else {
return [natom];
}
}
nestedlist =
"(" space* natom1:atom* satom1:spaceatom* space* latom1:listatom* space* ")"
{
var result = [];
if (natom1 && natom1.length) {
result = result.concat(natom1);
}
if (satom1 && satom1.length) {
result = result.concat(satom1);
}
if (latom1 && latom1.length) {
result = result.concat(latom1);
}
return result;
}
space =
" "
spaceatom =
space natom:atom
{ return natom; }