-
Notifications
You must be signed in to change notification settings - Fork 3
/
Syntax
77 lines (60 loc) · 1.26 KB
/
Syntax
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
# pyLRp grammar
# for the shellfish language
# the next line comes directly from the future ...
# import SyntaxTree
%lexer
"(.|\s)*" %restart
\s+ %restart
self SELF
thisContext THISCONTEXT
super SUPER
[a-zA-Z][a-zA-Z0-9]* SYM
[a-zA-Z][a-zA-Z0-9]*: KEY
\#([a-zA-Z][a-zA-Z0-9:]*|[\+\-\*\/\\@:,\.\|\&]+) SYMLIT
[\+\-\*\/\\@:,\.\|\&]+ BIN
# well the current grammar parser is not very nice, a pyLRp parser for pyLRp grammars,
# which uses only the current, limited command-set would solve the problem.
# probably such beauties will be possible in the self parsed, bootstrapped version:
# nearly full lex-capability
# \" %begin(COMMENT), %restart
# <COMMENT> \" %end, %restart
# <COMMENT> .* %restart
# \"\"\" %begin(MLSTRING), %restart
# <MLSTRING> .* %append, %restart
# <MLSTRING> \"\"\" %collect, %end, MLSTRING
%parser
%left KEY
%left BIN
%left SYM
doc:
%empty
doc statement
statement:
exp
"^" exp
SYM ":=" exp
statement "."
exp:
SELF
THISCONTEXT
SUPER
SYM:
print "Symbol"
SYMLIT
"(" exp ")"
exp SYM
exp BIN exp
exp KEY exp
"[" optparams optlocals doc "]"
optparams:
params "|"
%empty
params:
params ":" SYM
":" SYM
optlocals:
%empty
"|" locals "|"
locals:
%empty
locals SYM