-
Notifications
You must be signed in to change notification settings - Fork 0
/
my.peg
60 lines (54 loc) · 793 Bytes
/
my.peg
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
start =
expression
validchar =
[0-9a-zA-Z_?!+-=@#$%^&*/.]
spacechar =
" "
passthru: validchar
{ return " " + passthru; }
/
passthru: validchar
{ return passthru; }
quote =
first: validchar
second: spacechar*
{ return first + second.join(""); }
comment =
";;"
spacechar*
"\n"
{ return; }
atom =
chars:validchar+
{ return chars.join(""); }
expression =
comment
passthru: expression
{ return passthru; }
/
" "*
"("
passthru: expression*
")"
" "*
{ return passthru; }
/
" "
passthru: expression
{ return passthru; }
/
"\n"
passthru: expression
{ return passthru; }
/
"\t"
passthru: expression
{ return passthru; }
/
"'("
passthru: quote
")"
{ return "(quote (" + passthru + "))"; }
/
entity: atom
{ return entity; }