function calls in the DSL grammar

This commit is contained in:
John Kerl 2020-09-10 23:19:23 -04:00
parent 983f740012
commit 084dd624bc
11 changed files with 121632 additions and 81556 deletions

View file

@ -42,6 +42,8 @@ const (
NodeTypeOperator = "Operator"
NodeTypeContextVariable = "ContextVariable"
NodeTypeFunctionCallsite = "FunctionCallsite"
// A special token which causes a panic when evaluated. This is for
// testing that AND/OR short-circuiting is implemented correctly: output =
// input1 || panic should NOT panic the process when input1 is true.

View file

@ -18,7 +18,7 @@ type RecordWriterCSV struct {
func NewRecordWriterCSV(writerOptions *clitypes.TWriterOptions) *RecordWriterCSV {
return &RecordWriterCSV{
csvWriter: csv.NewWriter(os.Stdout),
csvWriter: csv.NewWriter(os.Stdout),
lastJoinedHeader: nil,
}
}

View file

@ -117,95 +117,95 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S24
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S25
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S26
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S27
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S28
Accept: 9,
Accept: 88,
Ignore: "",
},
ActionRow{ // S29
Accept: 10,
Accept: 9,
Ignore: "",
},
ActionRow{ // S30
Accept: 49,
Accept: 10,
Ignore: "",
},
ActionRow{ // S31
Accept: 0,
Accept: 49,
Ignore: "",
},
ActionRow{ // S32
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S33
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S34
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S35
Accept: 5,
Accept: 88,
Ignore: "",
},
ActionRow{ // S36
Accept: 48,
Accept: 88,
Ignore: "",
},
ActionRow{ // S37
Accept: 6,
Accept: 88,
Ignore: "",
},
ActionRow{ // S38
Accept: 67,
Accept: 5,
Ignore: "",
},
ActionRow{ // S39
Accept: 43,
Accept: 48,
Ignore: "",
},
ActionRow{ // S40
Accept: 0,
Accept: 6,
Ignore: "",
},
ActionRow{ // S41
Accept: 71,
Accept: 67,
Ignore: "",
},
ActionRow{ // S42
Accept: 0,
Accept: 43,
Ignore: "",
},
ActionRow{ // S43
Accept: 14,
Accept: 0,
Ignore: "",
},
ActionRow{ // S44
Accept: 11,
Accept: 71,
Ignore: "",
},
ActionRow{ // S45
Accept: 11,
Accept: 0,
Ignore: "",
},
ActionRow{ // S46
Accept: 12,
Accept: 14,
Ignore: "",
},
ActionRow{ // S47
@ -213,123 +213,123 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S48
Accept: 0,
Accept: 11,
Ignore: "",
},
ActionRow{ // S49
Accept: 0,
Accept: 12,
Ignore: "",
},
ActionRow{ // S50
Accept: 33,
Accept: 11,
Ignore: "",
},
ActionRow{ // S51
Accept: 39,
Accept: 0,
Ignore: "",
},
ActionRow{ // S52
Accept: 68,
Accept: 0,
Ignore: "",
},
ActionRow{ // S53
Accept: 30,
Accept: 33,
Ignore: "",
},
ActionRow{ // S54
Accept: 27,
Accept: 39,
Ignore: "",
},
ActionRow{ // S55
Accept: 29,
Accept: 68,
Ignore: "",
},
ActionRow{ // S56
Accept: 63,
Accept: 30,
Ignore: "",
},
ActionRow{ // S57
Accept: 56,
Accept: 27,
Ignore: "",
},
ActionRow{ // S58
Accept: 57,
Accept: 29,
Ignore: "",
},
ActionRow{ // S59
Accept: 64,
Accept: 63,
Ignore: "",
},
ActionRow{ // S60
Accept: 0,
Accept: 56,
Ignore: "",
},
ActionRow{ // S61
Accept: 28,
Accept: 57,
Ignore: "",
},
ActionRow{ // S62
Accept: 61,
Accept: 64,
Ignore: "",
},
ActionRow{ // S63
Accept: 31,
Accept: 0,
Ignore: "",
},
ActionRow{ // S64
Accept: 73,
Accept: 28,
Ignore: "",
},
ActionRow{ // S65
Accept: 0,
Accept: 61,
Ignore: "",
},
ActionRow{ // S66
Accept: 0,
Accept: 31,
Ignore: "",
},
ActionRow{ // S67
Accept: 0,
Accept: 73,
Ignore: "",
},
ActionRow{ // S68
Accept: 51,
Accept: 88,
Ignore: "",
},
ActionRow{ // S69
Accept: 47,
Accept: 88,
Ignore: "",
},
ActionRow{ // S70
Accept: 42,
Accept: 88,
Ignore: "",
},
ActionRow{ // S71
Accept: 40,
Accept: 51,
Ignore: "",
},
ActionRow{ // S72
Accept: 45,
Accept: 47,
Ignore: "",
},
ActionRow{ // S73
Accept: 52,
Accept: 42,
Ignore: "",
},
ActionRow{ // S74
Accept: 18,
Accept: 40,
Ignore: "",
},
ActionRow{ // S75
Accept: 15,
Accept: 45,
Ignore: "",
},
ActionRow{ // S76
Accept: 15,
Accept: 52,
Ignore: "",
},
ActionRow{ // S77
Accept: 16,
Accept: 18,
Ignore: "",
},
ActionRow{ // S78
@ -337,15 +337,15 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S79
Accept: 0,
Accept: 15,
Ignore: "",
},
ActionRow{ // S80
Accept: 0,
Accept: 16,
Ignore: "",
},
ActionRow{ // S81
Accept: 0,
Accept: 15,
Ignore: "",
},
ActionRow{ // S82
@ -353,95 +353,95 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S83
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S84
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S85
Accept: 83,
Accept: 88,
Ignore: "",
},
ActionRow{ // S86
Accept: 84,
Accept: 88,
Ignore: "",
},
ActionRow{ // S87
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S88
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S89
Accept: 0,
Accept: 83,
Ignore: "",
},
ActionRow{ // S90
Accept: 23,
Accept: 84,
Ignore: "",
},
ActionRow{ // S91
Accept: 38,
Accept: 88,
Ignore: "",
},
ActionRow{ // S92
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S93
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S94
Accept: 0,
Accept: 23,
Ignore: "",
},
ActionRow{ // S95
Accept: 0,
Accept: 38,
Ignore: "",
},
ActionRow{ // S96
Accept: 22,
Accept: 88,
Ignore: "",
},
ActionRow{ // S97
Accept: 37,
Accept: 88,
Ignore: "",
},
ActionRow{ // S98
Accept: 41,
Accept: 88,
Ignore: "",
},
ActionRow{ // S99
Accept: 71,
Accept: 88,
Ignore: "",
},
ActionRow{ // S100
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S101
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S102
Accept: 0,
Accept: 22,
Ignore: "",
},
ActionRow{ // S103
Accept: 21,
Accept: 37,
Ignore: "",
},
ActionRow{ // S104
Accept: 34,
Accept: 41,
Ignore: "",
},
ActionRow{ // S105
Accept: 65,
Accept: 71,
Ignore: "",
},
ActionRow{ // S106
@ -449,167 +449,167 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S107
Accept: 32,
Accept: 0,
Ignore: "",
},
ActionRow{ // S108
Accept: 73,
Accept: 0,
Ignore: "",
},
ActionRow{ // S109
Accept: 0,
Accept: 21,
Ignore: "",
},
ActionRow{ // S110
Accept: 0,
Accept: 34,
Ignore: "",
},
ActionRow{ // S111
Accept: 73,
Accept: 65,
Ignore: "",
},
ActionRow{ // S112
Accept: 72,
Accept: 0,
Ignore: "",
},
ActionRow{ // S113
Accept: 72,
Accept: 32,
Ignore: "",
},
ActionRow{ // S114
Accept: 24,
Accept: 73,
Ignore: "",
},
ActionRow{ // S115
Accept: 25,
Accept: 0,
Ignore: "",
},
ActionRow{ // S116
Accept: 53,
Accept: 0,
Ignore: "",
},
ActionRow{ // S117
Accept: 0,
Accept: 73,
Ignore: "",
},
ActionRow{ // S118
Accept: 0,
Accept: 72,
Ignore: "",
},
ActionRow{ // S119
Accept: 0,
Accept: 72,
Ignore: "",
},
ActionRow{ // S120
Accept: 85,
Accept: 72,
Ignore: "",
},
ActionRow{ // S121
Accept: 78,
Accept: 24,
Ignore: "",
},
ActionRow{ // S122
Accept: 77,
Accept: 25,
Ignore: "",
},
ActionRow{ // S123
Accept: 79,
Accept: 53,
Ignore: "",
},
ActionRow{ // S124
Accept: 81,
Accept: 0,
Ignore: "",
},
ActionRow{ // S125
Accept: 80,
Accept: 0,
Ignore: "",
},
ActionRow{ // S126
Accept: 82,
Accept: 88,
Ignore: "",
},
ActionRow{ // S127
Accept: 20,
Accept: 85,
Ignore: "",
},
ActionRow{ // S128
Accept: 0,
Accept: 78,
Ignore: "",
},
ActionRow{ // S129
Accept: 7,
Accept: 77,
Ignore: "",
},
ActionRow{ // S130
Accept: 0,
Accept: 79,
Ignore: "",
},
ActionRow{ // S131
Accept: 0,
Accept: 81,
Ignore: "",
},
ActionRow{ // S132
Accept: 19,
Accept: 80,
Ignore: "",
},
ActionRow{ // S133
Accept: 0,
Accept: 82,
Ignore: "",
},
ActionRow{ // S134
Accept: 13,
Accept: 20,
Ignore: "",
},
ActionRow{ // S135
Accept: 13,
Accept: 88,
Ignore: "",
},
ActionRow{ // S136
Accept: 0,
Accept: 7,
Ignore: "",
},
ActionRow{ // S137
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S138
Accept: 73,
Accept: 88,
Ignore: "",
},
ActionRow{ // S139
Accept: 0,
Accept: 89,
Ignore: "",
},
ActionRow{ // S140
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S141
Accept: 73,
Accept: 19,
Ignore: "",
},
ActionRow{ // S142
Accept: 73,
Accept: 0,
Ignore: "",
},
ActionRow{ // S143
Accept: 26,
Accept: 13,
Ignore: "",
},
ActionRow{ // S144
Accept: 0,
Accept: 13,
Ignore: "",
},
ActionRow{ // S145
Accept: 17,
Accept: 0,
Ignore: "",
},
ActionRow{ // S146
Accept: 17,
Accept: 0,
Ignore: "",
},
ActionRow{ // S147
Accept: 0,
Accept: 73,
Ignore: "",
},
ActionRow{ // S148
@ -621,15 +621,15 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S150
Accept: 74,
Accept: 73,
Ignore: "",
},
ActionRow{ // S151
Accept: 0,
Accept: 73,
Ignore: "",
},
ActionRow{ // S152
Accept: 73,
Accept: 26,
Ignore: "",
},
ActionRow{ // S153
@ -637,31 +637,31 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S154
Accept: 73,
Accept: 17,
Ignore: "",
},
ActionRow{ // S155
Accept: 73,
Accept: 17,
Ignore: "",
},
ActionRow{ // S156
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S157
Accept: 4,
Accept: 88,
Ignore: "",
},
ActionRow{ // S158
Accept: 74,
Accept: 88,
Ignore: "",
},
ActionRow{ // S159
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S160
Accept: 73,
Accept: 74,
Ignore: "",
},
ActionRow{ // S161
@ -669,7 +669,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S162
Accept: 0,
Accept: 73,
Ignore: "",
},
ActionRow{ // S163
@ -677,30 +677,74 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S164
Accept: 0,
Accept: 73,
Ignore: "",
},
ActionRow{ // S165
Accept: 87,
Accept: 73,
Ignore: "",
},
ActionRow{ // S166
Accept: 0,
Accept: 88,
Ignore: "",
},
ActionRow{ // S167
Accept: 86,
Accept: 4,
Ignore: "",
},
ActionRow{ // S168
Accept: 0,
Accept: 74,
Ignore: "",
},
ActionRow{ // S169
Accept: 0,
Accept: 90,
Ignore: "",
},
ActionRow{ // S170
Accept: 0,
Ignore: "",
},
ActionRow{ // S171
Accept: 73,
Ignore: "",
},
ActionRow{ // S172
Accept: 88,
Ignore: "",
},
ActionRow{ // S173
Accept: 88,
Ignore: "",
},
ActionRow{ // S174
Accept: 0,
Ignore: "",
},
ActionRow{ // S175
Accept: 88,
Ignore: "",
},
ActionRow{ // S176
Accept: 87,
Ignore: "",
},
ActionRow{ // S177
Accept: 0,
Ignore: "",
},
ActionRow{ // S178
Accept: 86,
Ignore: "",
},
ActionRow{ // S179
Accept: 0,
Ignore: "",
},
ActionRow{ // S180
Accept: 0,
Ignore: "",
},
ActionRow{ // S181
Accept: 75,
Ignore: "",
},

View file

@ -11,8 +11,8 @@ import (
const (
NoState = -1
NumStates = 171
NumSymbols = 295
NumStates = 182
NumSymbols = 303
)
type Lexer struct {
@ -175,237 +175,245 @@ Lexer symbols:
59: 'e'
60: 'n'
61: 'd'
62: '$'
63: '$'
64: '{'
65: '}'
66: '$'
67: '*'
68: '@'
69: '@'
70: '{'
71: '}'
72: '@'
73: '*'
74: '%'
75: '%'
76: '%'
77: 'p'
78: 'a'
79: 'n'
80: 'i'
81: 'c'
62: 'i'
63: 'n'
64: 't'
65: 'f'
66: 'l'
67: 'o'
68: 'a'
69: 't'
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: '='
85: 'p'
86: 'a'
87: 'n'
88: 'i'
89: 'c'
90: '%'
91: '%'
92: '%'
93: ';'
94: '{'
95: '}'
96: '='
97: '['
98: ']'
99: '$'
100: '['
101: '@'
102: '['
103: '|'
104: '|'
105: '='
106: '^'
107: '='
108: '<'
109: '<'
110: '='
111: '>'
112: '>'
107: '^'
108: '='
109: '&'
110: '&'
111: '='
112: '|'
113: '='
114: '>'
115: '>'
116: '>'
117: '='
118: '+'
119: '='
120: '.'
114: '^'
115: '='
116: '<'
117: '<'
118: '='
119: '>'
120: '>'
121: '='
122: '-'
123: '='
124: '*'
122: '>'
123: '>'
124: '>'
125: '='
126: '/'
126: '+'
127: '='
128: '/'
129: '/'
130: '='
131: '%'
132: '='
133: '*'
134: '*'
128: '.'
129: '='
130: '-'
131: '='
132: '*'
133: '='
134: '/'
135: '='
136: '?'
137: ':'
138: '|'
139: '|'
140: '^'
141: '^'
142: '&'
143: '&'
144: '='
145: '~'
146: '!'
147: '='
148: '~'
149: '='
150: '='
151: '!'
136: '/'
137: '/'
138: '='
139: '%'
140: '='
141: '*'
142: '*'
143: '='
144: '?'
145: ':'
146: '|'
147: '|'
148: '^'
149: '^'
150: '&'
151: '&'
152: '='
153: '>'
154: '>'
153: '~'
154: '!'
155: '='
156: '<'
157: '<'
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: '%'
159: '!'
160: '='
161: '>'
162: '>'
163: '='
164: '<'
165: '<'
166: '='
167: '|'
168: '^'
169: '&'
170: '<'
171: '<'
172: '>'
173: '>'
174: '>'
175: '>'
176: '>'
177: '+'
178: '-'
179: '.'
180: '+'
181: '.'
182: '*'
182: '-'
183: '.'
184: '/'
185: '.'
184: '*'
185: '/'
186: '/'
187: '/'
188: '!'
189: '~'
188: '%'
189: '.'
190: '*'
191: '*'
192: '('
193: ')'
194: ','
195: '_'
196: ' '
197: '!'
198: '#'
199: '$'
200: '%'
201: '&'
202: '''
203: '\'
204: '('
205: ')'
206: '*'
207: '+'
208: ','
209: '-'
210: '.'
211: '/'
212: ':'
213: ';'
214: '<'
215: '='
216: '>'
217: '?'
218: '@'
219: '['
220: ']'
221: '^'
222: '_'
223: '`'
224: '{'
225: '|'
226: '}'
227: '~'
228: '\'
229: '"'
230: 'e'
231: 'E'
232: 't'
233: 'r'
234: 'u'
235: 'e'
236: 'f'
237: 'a'
238: 'l'
239: 's'
240: 'e'
241: ' '
242: '!'
243: '#'
244: '$'
245: '%'
246: '&'
247: '''
248: '\'
249: '('
250: ')'
251: '*'
252: '+'
253: ','
254: '-'
255: '.'
256: '/'
257: ':'
258: ';'
259: '<'
260: '='
261: '>'
262: '?'
263: '@'
264: '['
265: ']'
266: '^'
267: '_'
268: '`'
269: '|'
270: '~'
271: '\'
272: '{'
273: '\'
274: '}'
275: ' '
276: '\t'
277: '\n'
278: '\r'
279: 'a'-'z'
280: 'A'-'Z'
281: '0'-'9'
282: '0'-'9'
283: 'a'-'f'
284: 'A'-'F'
285: '0'-'1'
286: 'A'-'Z'
191: '.'
192: '/'
193: '.'
194: '/'
195: '/'
196: '!'
197: '~'
198: '*'
199: '*'
200: '('
201: ')'
202: ','
203: '_'
204: ' '
205: '!'
206: '#'
207: '$'
208: '%'
209: '&'
210: '''
211: '\'
212: '('
213: ')'
214: '*'
215: '+'
216: ','
217: '-'
218: '.'
219: '/'
220: ':'
221: ';'
222: '<'
223: '='
224: '>'
225: '?'
226: '@'
227: '['
228: ']'
229: '^'
230: '_'
231: '`'
232: '{'
233: '|'
234: '}'
235: '~'
236: '\'
237: '"'
238: 'e'
239: 'E'
240: 't'
241: 'r'
242: 'u'
243: 'e'
244: 'f'
245: 'a'
246: 'l'
247: 's'
248: 'e'
249: ' '
250: '!'
251: '#'
252: '$'
253: '%'
254: '&'
255: '''
256: '\'
257: '('
258: ')'
259: '*'
260: '+'
261: ','
262: '-'
263: '.'
264: '/'
265: ':'
266: ';'
267: '<'
268: '='
269: '>'
270: '?'
271: '@'
272: '['
273: ']'
274: '^'
275: '_'
276: '`'
277: '|'
278: '~'
279: '\'
280: '{'
281: '\'
282: '}'
283: ' '
284: '\t'
285: '\n'
286: '\r'
287: 'a'-'z'
288: '0'-'9'
289: \u0100-\U0010ffff
290: 'A'-'Z'
291: 'a'-'z'
292: '0'-'9'
293: \u0100-\U0010ffff
294: .
288: 'A'-'Z'
289: '0'-'9'
290: '0'-'9'
291: 'a'-'f'
292: 'A'-'F'
293: '0'-'1'
294: 'A'-'Z'
295: 'a'-'z'
296: '0'-'9'
297: \u0100-\U0010ffff
298: 'A'-'Z'
299: 'a'-'z'
300: '0'-'9'
301: \u0100-\U0010ffff
302: .
*/

File diff suppressed because it is too large Load diff

View file

@ -182,8 +182,8 @@ md_token_end : 'e' 'n' 'd' ;
//md_token_map_type : 'm' 'a' 'p' ;
//md_token_num_type : 'n' 'u' 'm' ;
//md_token_int_type : 'i' 'n' 't' ;
//md_token_float_type : 'f' 'l' 'o' 'a' 't' ;
md_token_int_type : 'i' 'n' 't' ;
md_token_float_type : 'f' 'l' 'o' 'a' 't' ;
//md_token_bool_type : 'b' 'o' 'o' 'l' ;
//md_token_str_type : 's' 't' 'r' ;
@ -222,6 +222,11 @@ md_token_braced_oosvar_name: '@' '{' _braced_char { _braced_char } '}' ;
md_token_full_oosvar : '@' '*' ;
// ----------------------------------------------------------------
// FUNCTIONS AND LOCAL VARIABLES
md_token_non_sigil_name : _idchar { _idchar } ;
// ----------------------------------------------------------------
// PANIC TOKEN
// ----------------------------------------------------------------
@ -823,23 +828,23 @@ ArrayLiteral
// ----------------------------------------------------------------
ArrayLiteralElements
: ArrayLiteralElement
: Rvalue
<< dsl.NewASTNodeUnary(
nil,
$0,
dsl.NodeTypeArrayLiteral,
) >>
// Allow trailing final comma, especially for multiline map literals
| ArrayLiteralElement ","
// Allow trailing final comma, especially for multiline statements
| Rvalue ","
<< dsl.NewASTNodeUnary(
nil,
$0,
dsl.NodeTypeArrayLiteral,
) >>
// Allow trailing final comma, especially for multiline map literals
| ArrayLiteralElement "," ArrayLiteralElements
// Allow trailing final comma, especially for multiline statements
| Rvalue "," ArrayLiteralElements
<< dsl.PrependChild(
$2,
$0,
@ -847,11 +852,6 @@ ArrayLiteralElements
;
// ----------------------------------------------------------------
ArrayLiteralElement
: Rvalue
;
// ================================================================
// Map literals in Miller are JSON-ish.
@ -907,7 +907,7 @@ MapLiteralKeyValuePairs
dsl.NodeTypeMapLiteral,
) >>
// Allow trailing final comma, especially for multiline map literals
// Allow trailing final comma, especially for multiline statements
| MapLiteralKeyValuePair ","
<< dsl.NewASTNodeUnary(
nil,
@ -915,7 +915,7 @@ MapLiteralKeyValuePairs
dsl.NodeTypeMapLiteral,
) >>
// Allow trailing final comma, especially for multiline map literals
// Allow trailing final comma, especially for multiline statements
| MapLiteralKeyValuePair "," MapLiteralKeyValuePairs
<< dsl.PrependChild(
$2,
@ -1039,54 +1039,78 @@ ArraySliceAccess
// ================================================================
// FUNCTION/SUBROUTINE CALLS
//MlrvalOrFunction(A) ::= FcnOrSubrCall(B). {
// A = B;
//}
MlrvalOrFunction
: FcnOrSubrCall
;
//// Given "f(a,b,c)": since this is a bottom-up parser, we get first the "a",
//// then "a,b", then "a,b,c", then finally "f(a,b,c)". So:
//// * On the "a" we make a function sub-AST called "anon(a)".
//// * On the "b" we append the next argument to get "anon(a,b)".
//// * On the "c" we append the next argument to get "anon(a,b,c)".
//// * On the "f" we change the function name to get "f(a,b,c)".
FcnOrSubrCall
//FcnOrSubrCall(A) ::= md_token_non_sigil_name(O) "(" FcnArgList(B) ")". {
// A = mlr_dsl_ast_node_set_function_name(B, O->text);
// A->type = MD_AST_NODE_TYPE_FUNCTION_CALLSITE;
//}
: FunctionName "(" ")"
<< dsl.NewASTNodeZary(
$0,
dsl.NodeTypeFunctionCallsite,
) >>
//// For most functions it suffices to use the md_token_non_sigil_name pattern. But
//// int and float are keywords in the lexer so we need to spell those out explicitly.
//// (They're type-decl keywords but they're also the names of type-conversion functions.)
//FcnOrSubrCall(A) ::= md_token_int(O) "(" FcnArgList(B) ")". {
// A = mlr_dsl_ast_node_set_function_name(B, O->text);
// A->type = MD_AST_NODE_TYPE_FUNCTION_CALLSITE;
//}
//FcnOrSubrCall(A) ::= md_token_float(O) "(" FcnArgList(B) ")". {
// A = mlr_dsl_ast_node_set_function_name(B, O->text);
// A->type = MD_AST_NODE_TYPE_FUNCTION_CALLSITE;
//}
| FunctionName "(" FcnArgs ")"
// As parsed there's an intermediate node between FcnOrSubrCall
// and the children. Now we can remove it.
//
// Before:
// * FcnOrSubrCall "[]"
// * FcnOrSubrCall
// * StringLiteral "a"
// * StringLiteral "b"
//
// After:
// * FcnOrSubrCall "[]"
// * StringLiteral "a"
// * StringLiteral "b"
<< dsl.AdoptChildren(
dsl.NewASTNodeNestable(
$0,
dsl.NodeTypeFunctionCallsite,
),
$2,
) >>
//FcnArgList(A) ::= . {
// A = mlr_dsl_ast_node_alloc_zary("anon", MD_AST_NODE_TYPE_NON_SIGIL_NAME);
//}
//FcnArgList(A) ::= FcnNonEmptyArgList(B). {
// A = B;
//}
;
//FcnNonEmptyArgList(A) ::= md_fcn_arg(B). {
// A = mlr_dsl_ast_node_alloc_unary("anon", MD_AST_NODE_TYPE_NON_SIGIL_NAME, B);
//}
//FcnNonEmptyArgList(A) ::= md_fcn_arg(B) ",". {
// A = mlr_dsl_ast_node_alloc_unary("anon", MD_AST_NODE_TYPE_NON_SIGIL_NAME, B);
//}
//FcnNonEmptyArgList(A) ::= md_fcn_arg(B) "," FcnNonEmptyArgList(C). {
// A = mlr_dsl_ast_node_prepend_arg(C, B);
//}
// For most functions it suffices to use the md_token_non_sigil_name pattern.
// But int and float are keywords in the lexer so we need to spell those out
// explicitly. (They're type-decl keywords but they're also the names of
// type-conversion functions.)
FunctionName
: md_token_non_sigil_name
| md_token_int_type
| md_token_float_type
;
//md_fcn_arg(A) ::= Rvalue(B). {
// A = B;
//}
// ----------------------------------------------------------------
FcnArgs
: Rvalue
<< dsl.NewASTNodeUnary(
nil,
$0,
dsl.NodeTypeFunctionCallsite,
) >>
// Allow trailing final comma, especially for multiline statements
| Rvalue ","
<< dsl.NewASTNodeUnary(
nil,
$0,
dsl.NodeTypeFunctionCallsite,
) >>
// Allow trailing final comma, especially for multiline statements
| Rvalue "," FcnArgs
<< dsl.PrependChild(
$2,
$0,
) >>
;
// ================================================================
// ================================================================

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -11,9 +11,9 @@ import (
)
const (
numProductions = 152
numStates = 1410
numSymbols = 136
numProductions = 160
numStates = 1627
numSymbols = 141
)
// Stack

View file

@ -1445,7 +1445,7 @@ var productionsTable = ProdTab{
},
},
ProdTabEntry{
String: `ArrayLiteralElements : ArrayLiteralElement << dsl.NewASTNodeUnary(
String: `ArrayLiteralElements : Rvalue << dsl.NewASTNodeUnary(
nil,
X[0],
dsl.NodeTypeArrayLiteral,
@ -1463,7 +1463,7 @@ var productionsTable = ProdTab{
},
},
ProdTabEntry{
String: `ArrayLiteralElements : ArrayLiteralElement "," << dsl.NewASTNodeUnary(
String: `ArrayLiteralElements : Rvalue "," << dsl.NewASTNodeUnary(
nil,
X[0],
dsl.NodeTypeArrayLiteral,
@ -1481,7 +1481,7 @@ var productionsTable = ProdTab{
},
},
ProdTabEntry{
String: `ArrayLiteralElements : ArrayLiteralElement "," ArrayLiteralElements << dsl.PrependChild(
String: `ArrayLiteralElements : Rvalue "," ArrayLiteralElements << dsl.PrependChild(
X[2],
X[0],
) >>`,
@ -1496,21 +1496,11 @@ var productionsTable = ProdTab{
)
},
},
ProdTabEntry{
String: `ArrayLiteralElement : Rvalue << >>`,
Id: "ArrayLiteralElement",
NTType: 41,
Index: 125,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
},
},
ProdTabEntry{
String: `MlrvalOrFunction : MapLiteral << >>`,
Id: "MlrvalOrFunction",
NTType: 38,
Index: 126,
Index: 125,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
@ -1522,8 +1512,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeMapLiteral,
) >>`,
Id: "MapLiteral",
NTType: 42,
Index: 127,
NTType: 41,
Index: 126,
NumSymbols: 2,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeZary(
@ -1541,8 +1531,8 @@ var productionsTable = ProdTab{
X[1],
) >>`,
Id: "MapLiteral",
NTType: 42,
Index: 128,
NTType: 41,
Index: 127,
NumSymbols: 3,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.AdoptChildren(
@ -1561,8 +1551,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeMapLiteral,
) >>`,
Id: "MapLiteralKeyValuePairs",
NTType: 43,
Index: 129,
NTType: 42,
Index: 128,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeUnary(
@ -1579,8 +1569,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeMapLiteral,
) >>`,
Id: "MapLiteralKeyValuePairs",
NTType: 43,
Index: 130,
NTType: 42,
Index: 129,
NumSymbols: 2,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeUnary(
@ -1596,8 +1586,8 @@ var productionsTable = ProdTab{
X[0],
) >>`,
Id: "MapLiteralKeyValuePairs",
NTType: 43,
Index: 131,
NTType: 42,
Index: 130,
NumSymbols: 3,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.PrependChild(
@ -1614,8 +1604,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeMapLiteralKeyValuePair,
) >>`,
Id: "MapLiteralKeyValuePair",
NTType: 44,
Index: 132,
NTType: 43,
Index: 131,
NumSymbols: 3,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeBinary(
@ -1630,7 +1620,7 @@ var productionsTable = ProdTab{
String: `MlrvalOrFunction : ContextVariable << >>`,
Id: "MlrvalOrFunction",
NTType: 38,
Index: 133,
Index: 132,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
@ -1639,8 +1629,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_IPS << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 134,
NTType: 44,
Index: 133,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1649,8 +1639,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_IFS << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 135,
NTType: 44,
Index: 134,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1659,8 +1649,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_IRS << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 136,
NTType: 44,
Index: 135,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1669,8 +1659,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_OPS << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 137,
NTType: 44,
Index: 136,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1679,8 +1669,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_OFS << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 138,
NTType: 44,
Index: 137,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1689,8 +1679,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_ORS << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 139,
NTType: 44,
Index: 138,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1699,8 +1689,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_NF << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 140,
NTType: 44,
Index: 139,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1709,8 +1699,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_NR << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 141,
NTType: 44,
Index: 140,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1719,8 +1709,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_FNR << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 142,
NTType: 44,
Index: 141,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1729,8 +1719,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_FILENAME << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 143,
NTType: 44,
Index: 142,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1739,8 +1729,8 @@ var productionsTable = ProdTab{
ProdTabEntry{
String: `ContextVariable : md_token_FILENUM << dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable) >>`,
Id: "ContextVariable",
NTType: 45,
Index: 144,
NTType: 44,
Index: 143,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNode(X[0], dsl.NodeTypeContextVariable)
@ -1750,7 +1740,7 @@ var productionsTable = ProdTab{
String: `MlrvalOrFunction : ArrayOrMapIndexAccess << >>`,
Id: "MlrvalOrFunction",
NTType: 38,
Index: 145,
Index: 144,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
@ -1764,8 +1754,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeArrayOrMapIndexAccess,
) >>`,
Id: "ArrayOrMapIndexAccess",
NTType: 46,
Index: 146,
NTType: 45,
Index: 145,
NumSymbols: 4,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeBinary(
@ -1780,7 +1770,7 @@ var productionsTable = ProdTab{
String: `MlrvalOrFunction : ArraySliceAccess << >>`,
Id: "MlrvalOrFunction",
NTType: 38,
Index: 147,
Index: 146,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
@ -1795,8 +1785,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeArraySliceAccess,
) >>`,
Id: "ArraySliceAccess",
NTType: 47,
Index: 148,
NTType: 46,
Index: 147,
NumSymbols: 6,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeTernary(
@ -1820,8 +1810,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeArraySliceAccess,
) >>`,
Id: "ArraySliceAccess",
NTType: 47,
Index: 149,
NTType: 46,
Index: 148,
NumSymbols: 5,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeTernary(
@ -1848,8 +1838,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeArraySliceAccess,
) >>`,
Id: "ArraySliceAccess",
NTType: 47,
Index: 150,
NTType: 46,
Index: 149,
NumSymbols: 5,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeTernary(
@ -1879,8 +1869,8 @@ var productionsTable = ProdTab{
dsl.NodeTypeArraySliceAccess,
) >>`,
Id: "ArraySliceAccess",
NTType: 47,
Index: 151,
NTType: 46,
Index: 150,
NumSymbols: 4,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeTernary(
@ -1898,4 +1888,134 @@ var productionsTable = ProdTab{
)
},
},
ProdTabEntry{
String: `MlrvalOrFunction : FcnOrSubrCall << >>`,
Id: "MlrvalOrFunction",
NTType: 38,
Index: 151,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
},
},
ProdTabEntry{
String: `FcnOrSubrCall : FunctionName "(" ")" << dsl.NewASTNodeZary(
X[0],
dsl.NodeTypeFunctionCallsite,
) >>`,
Id: "FcnOrSubrCall",
NTType: 47,
Index: 152,
NumSymbols: 3,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeZary(
X[0],
dsl.NodeTypeFunctionCallsite,
)
},
},
ProdTabEntry{
String: `FcnOrSubrCall : FunctionName "(" FcnArgs ")" << dsl.AdoptChildren(
dsl.NewASTNodeNestable(
X[0],
dsl.NodeTypeFunctionCallsite,
),
X[2],
) >>`,
Id: "FcnOrSubrCall",
NTType: 47,
Index: 153,
NumSymbols: 4,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.AdoptChildren(
dsl.NewASTNodeNestable(
X[0],
dsl.NodeTypeFunctionCallsite,
),
X[2],
)
},
},
ProdTabEntry{
String: `FunctionName : md_token_non_sigil_name << >>`,
Id: "FunctionName",
NTType: 48,
Index: 154,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
},
},
ProdTabEntry{
String: `FunctionName : md_token_int_type << >>`,
Id: "FunctionName",
NTType: 48,
Index: 155,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
},
},
ProdTabEntry{
String: `FunctionName : md_token_float_type << >>`,
Id: "FunctionName",
NTType: 48,
Index: 156,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return X[0], nil
},
},
ProdTabEntry{
String: `FcnArgs : Rvalue << dsl.NewASTNodeUnary(
nil,
X[0],
dsl.NodeTypeFunctionCallsite,
) >>`,
Id: "FcnArgs",
NTType: 49,
Index: 157,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeUnary(
nil,
X[0],
dsl.NodeTypeFunctionCallsite,
)
},
},
ProdTabEntry{
String: `FcnArgs : Rvalue "," << dsl.NewASTNodeUnary(
nil,
X[0],
dsl.NodeTypeFunctionCallsite,
) >>`,
Id: "FcnArgs",
NTType: 49,
Index: 158,
NumSymbols: 2,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.NewASTNodeUnary(
nil,
X[0],
dsl.NodeTypeFunctionCallsite,
)
},
},
ProdTabEntry{
String: `FcnArgs : Rvalue "," FcnArgs << dsl.PrependChild(
X[2],
X[0],
) >>`,
Id: "FcnArgs",
NTType: 49,
Index: 159,
NumSymbols: 3,
ReduceFunc: func(X []Attrib) (Attrib, error) {
return dsl.PrependChild(
X[2],
X[0],
)
},
},
}

View file

@ -207,6 +207,9 @@ var TokMap = TokenMap{
"md_token_FNR",
"md_token_FILENAME",
"md_token_FILENUM",
"md_token_non_sigil_name",
"md_token_int_type",
"md_token_float_type",
},
idMap: map[string]Type{
@ -298,5 +301,8 @@ var TokMap = TokenMap{
"md_token_FNR": 85,
"md_token_FILENAME": 86,
"md_token_FILENUM": 87,
"md_token_non_sigil_name": 88,
"md_token_int_type": 89,
"md_token_float_type": 90,
},
}