8 define csharp_statements
9 [repeat csharp_lang_stmt]
12 define csharp_lang_stmt
14 | [csharp_variable_decl]
17 | [EX] '{ [IN] [NL] [csharp_statements] [EX] '} [IN] [NL]
20 define csharp_variable_decl
21 [csharp_type_decl] [opt union] [id] '; [NL]
24 define csharp_type_decl
30 define csharp_expr_stmt
35 [csharp_term] [repeat csharp_expr_extend]
38 define csharp_expr_extend
39 [al_expr_op] [csharp_term]
44 | [id] [repeat csharp_dot_id]
45 | [id] [repeat csharp_dot_id] '( [csharp_args] ')
46 | 'new [csharp_type_decl] [union]
47 | 'new [csharp_type_decl] '( [csharp_args] ')
63 'if '( [csharp_expr] ') [NL] [IN]
64 [csharp_lang_stmt] [EX]
70 [csharp_lang_stmt] [EX]
85 redefine al_host_block
86 '{ [NL] [IN] [al_statements] [EX] '} [NL]
87 | '{ [NL] [IN] [csharp_statements] [EX] '} [NL]
90 redefine cond_action_stmt
91 'action [id] '{ [al_expr] '} [NL]
92 | 'action [id] '{ [csharp_expr] '} [NL]
96 function clearUnion Type [csharp_type_decl] Id [id]
99 import ArrayInits [csharp_statements]
100 Stmts [repeat csharp_lang_stmt]
102 Id '= 'new Type Union '; Stmts
108 replace [al_type_decl]
114 function alStmtToCSharp1 AlStmt [action_lang_stmt]
116 VarDecl [al_variable_decl]
118 Type [al_type_decl] Id [id] OptUnion [opt union] ';
119 construct CSharpType [csharp_type_decl]
121 construct Result [csharp_variable_decl]
122 CSharpType [ptrTypes] OptUnion [clearUnion CSharpType Id] Id ';
123 replace [repeat csharp_lang_stmt]
128 function alTermToCSharp
135 function alExprExtendToCSharp AlExprExtend [repeat al_expr_extend]
136 deconstruct AlExprExtend
137 Op [al_expr_op] Term [al_term] Rest [repeat al_expr_extend]
138 construct CSharpRest [repeat csharp_expr_extend]
139 _ [alExprExtendToCSharp Rest]
140 replace [repeat csharp_expr_extend]
142 Op Term [alTermToCSharp] CSharpRest
145 function alExprToCSharp AlExpr [al_expr]
147 ALTerm [al_term] AlExprExtend [repeat al_expr_extend]
148 construct CSharpExprExtend [repeat csharp_expr_extend]
149 _ [alExprExtendToCSharp AlExprExtend]
150 construct Result [opt csharp_expr]
151 ALTerm [alTermToCSharp] CSharpExprExtend
152 replace [opt csharp_expr]
157 function alStmtToCSharp2 AlStmt [action_lang_stmt]
160 construct OptCSharpExpr [opt csharp_expr]
161 _ [alExprToCSharp AlExpr]
162 deconstruct OptCSharpExpr
163 CSharpExpr [csharp_expr]
164 replace [repeat csharp_lang_stmt]
169 function alOptElseCSharp AlOptElse [opt al_else]
170 deconstruct AlOptElse
172 AlSubStmt [action_lang_stmt]
173 construct AlSubStmts [repeat action_lang_stmt]
175 construct CSharpSubStmts [repeat csharp_lang_stmt]
176 _ [alToCSharp AlSubStmts]
177 deconstruct CSharpSubStmts
178 CSharpSubStmt [csharp_lang_stmt]
179 replace [opt csharp_else]
185 function alStmtToCSharp3 AlStmt [action_lang_stmt]
187 'if '( AlExpr [al_expr] ')
188 AlSubStmt [action_lang_stmt]
189 AlOptElse [opt al_else]
190 construct OptCSharpExpr [opt csharp_expr]
191 _ [alExprToCSharp AlExpr]
192 deconstruct OptCSharpExpr
193 CSharpExpr [csharp_expr]
194 construct AlSubStmts [repeat action_lang_stmt]
196 construct CSharpSubStmts [repeat csharp_lang_stmt]
197 _ [alToCSharp AlSubStmts]
198 deconstruct CSharpSubStmts
199 CSharpSubStmt [csharp_lang_stmt]
200 construct OptCSharpElse [opt csharp_else]
201 _ [alOptElseCSharp AlOptElse]
202 replace [repeat csharp_lang_stmt]
209 function alStmtToCSharp4a AlStmt [action_lang_stmt]
212 replace [repeat csharp_lang_stmt]
214 'Console '. 'Write '( Id ');
217 function alStmtToCSharp4b AlStmt [action_lang_stmt]
219 'prints String [stringlit] ';
220 replace [repeat csharp_lang_stmt]
222 'Console '. 'Write '( String ');
225 function alStmtToCSharp4c AlStmt [action_lang_stmt]
228 replace [repeat csharp_lang_stmt]
230 '_s '= 'new 'String '( Id ', '0 ', 'pos ') ';
231 'Console '. 'Write '( '_s ');
234 function alStmtToCSharp4d AlStmt [action_lang_stmt]
237 replace [repeat csharp_lang_stmt]
239 '_s '= 'new 'String '( 'data ', 'ts ', 'te '- 'ts ') ';
240 'Console '. 'Write '( '_s ');
243 function alStmtToCSharp5 AlStmt [action_lang_stmt]
245 '{ AlSubStmts [repeat action_lang_stmt] '}
246 construct CSharpSubStmts [repeat csharp_lang_stmt]
247 _ [alToCSharp AlSubStmts]
248 replace [repeat csharp_lang_stmt]
253 function alStmtToCSharp6 AlStmt [action_lang_stmt]
255 RagelStmt [al_ragel_stmt]
256 replace [repeat csharp_lang_stmt]
262 function alToCSharp AlStmts [repeat action_lang_stmt]
264 FirstStmt [action_lang_stmt] Rest [repeat action_lang_stmt]
265 construct CSharpFirst [repeat csharp_lang_stmt]
267 [alStmtToCSharp1 FirstStmt]
268 [alStmtToCSharp2 FirstStmt]
269 [alStmtToCSharp3 FirstStmt]
270 [alStmtToCSharp4a FirstStmt]
271 [alStmtToCSharp4b FirstStmt]
272 [alStmtToCSharp4c FirstStmt]
273 [alStmtToCSharp4d FirstStmt]
274 [alStmtToCSharp5 FirstStmt]
275 [alStmtToCSharp6 FirstStmt]
276 construct CSharpRest [repeat csharp_lang_stmt]
278 replace [repeat csharp_lang_stmt]
280 CSharpFirst [. CSharpRest]
283 rule actionTransCSharp
284 replace [al_host_block]
285 '{ AlStmts [repeat action_lang_stmt] '}
286 construct CSharpStmts [repeat csharp_lang_stmt]
287 _ [alToCSharp AlStmts]
293 replace [cond_action_stmt]
294 'action Id [id] '{ AlExpr [al_expr] '}
295 construct OptCSharpExpr [opt csharp_expr]
296 _ [alExprToCSharp AlExpr]
297 deconstruct OptCSharpExpr
298 CSharpExpr [csharp_expr]
300 'action Id '{ CSharpExpr '}
304 replace $ [machine_stmt]
306 import TXLargs [repeat stringlit]
307 Arg1 [stringlit] _ [repeat stringlit]
308 construct ClassName [id]
311 'machine ClassName ';
314 function langTransCSharp
316 Definitions [repeat action_lang_stmt]
318 Initializations [repeat action_lang_stmt]
320 construct CSharpDefinitions [repeat csharp_lang_stmt]
321 _ [alToCSharp Definitions]
322 construct CSharpInitializations [repeat csharp_lang_stmt]
323 _ [alToCSharp Initializations]
324 construct NewRagelDef [ragel_def]
325 RagelDef [actionTransCSharp] [condTransCSharp] [machineName]
326 import ArrayInits [csharp_statements]
327 ArrayInitStmts [repeat csharp_lang_stmt]
331 ArrayInitStmts [. CSharpInitializations]
338 export ArrayInits [csharp_statements]