-
Notifications
You must be signed in to change notification settings - Fork 1
/
syntax
191 lines (142 loc) · 3.95 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
- Object
- Class(Collection)
- Role(Collection)
- Package(Collection)
- Signature(Collection)
- Keyword
- Scope
- Declare
- Conditional
- Turnary
- WordQuote
- Quote
- Delimited
- Begin
- Operator
- Subroutine
- Function(Runnable)
- Method(Runnable)
- Builder(Runnable)
- IO
- Stream
- File
- Socket
- String
- Number
- Integer
- Decimal
- Rational
- List(Collection)
- Dict(Collection)
- Stack(Collection)
- Queue(Collection)
- Array(Collection)
- Scope(Collection)
- Undef
-----
*KEYWORD TYPES*
Scope:
Start a new scope, return on specific token (or subtoken)
- Replaces tokens with object
- symbol_table (symbols to inject)
Builder:
For things like declaring functions, or builders
- Code to run
- name: [required, optional, forbidden]
- name_type: [identifier, string, both]
- params: [required, optional, forbidden]
- param_type: [signature, statement, text]
- symbol_table (symbols to inject into the scope to follow)
key NAME(...) {...}
switch (...) {
case (...) {...}
case (...) {...}
default {...}
}
Declare:
For declaring variables, or similar keywords
- Has code to run against [type,name,nullable,value] sets
key NAME = ...;
key NAME? = ...;
key NAME, NAME;
key TYPE NAME = ...;
key TYPE NAME? = ...;
key TYPE NAME, TYPE NAME;
key (NAME, NAME?, NAME) = (...);
The question mark determines if the variable is allowed to have a
null/undef value. If the question mark is there then an initial value must
also be set.
Conditional:
Declare conditional structures like if/for/while/try
- Code to run that returns a runable object
- postfixable (can this be a statement postfix)
- branch: keyword-token for branch (elsif/catch)
- final: keyword-token for fallback (else/finally)
- validate: [statement, variable, combo]
- default_name: Default name of variable (in combo and variable only)
- default_type: Default type of variable (in combo and variable only)
try {
}
catch(Type name) {
}
catch(name) {
}
finally {
}
key (...) {
}
orkey (...) {
}
orkey (...) {
}
finalkey {
}
... key STATEMENT;
... key (TYPE NAME; STATEMENT);
for (STATEMENT) { }
for (TYPE NAME; STATEMENT) { }
Turnary:
For turnary like things:
- process: code that returns a runnable object (gets 3 blocks)
- divide: token that divides the 2 options
foo ? bar : baz
WordQuote:
For things like perl's => that have auto-quote, or Package::Name
- Process: Code to process the 3 tokens(with whitespace) should return
replacement tokens.
thing ~> thing
"thing" +> thing
thing -> "thing"
"thing" => "thing"
Quote:
Start a quote.
- process: code to munge the quoted string
- end_token: Slurp until this
- escapable: Can use \TOKEN to insert the token
Delimited:
Start a delimited "thing". Replaces "thing" with an executable object
- process: Code to process sections + flag, returns something executable
- sections: Number of sections (delimiters - 1)
- flags: Take in alpha-token following last delimiter (no whitespace)
- escapable: Can use \DELIM to insert the character
Begin:
Process the statement at BEGIN time.
- process: Code to execute the statement
-----
// Declare a keyword
key NAME(TYPE) {
PROP VAL;
process { ... }
}
-----
SIGNATURE:
( name, name, name )
( type name, name, name, type name )
( type name = default, type name )
( type name { ... }, name { ... } )
( name = default )
-----
Operator properties
- Process: Code to run
- Position: [Prefix, Postfix, Anyfix, Infix, Circumfix]
- Termination: (circumfix only) termination symbol