9 [repeat ruby_lang_stmt]
16 | [EX] 'do [IN] [NL] [ruby_statements] [EX] 'end [IN] [NL]
29 [ruby_term] [repeat ruby_expr_extend]
32 define ruby_expr_extend
33 [al_expr_op] [ruby_term]
39 | [id] [repeat ruby_dot_id]
40 | [SPOFF] [id] [repeat ruby_dot_id] '( [SPON] [ruby_args] ')
57 'if [ruby_expr] [NL] [IN]
58 [ruby_statements] [EX]
65 [ruby_statements] [EX]
80 redefine al_host_block
81 '{ [NL] [IN] [al_statements] [EX] '} [NL]
82 | '{ [NL] [IN] [ruby_statements] [EX] '} [NL]
85 redefine cond_action_stmt
86 'action [id] '{ [al_expr] '} [NL]
87 | 'action [id] '{ [ruby_expr] '} [NL]
90 function initDecl1 VarDecl [al_variable_decl]
93 replace [repeat ruby_lang_stmt]
98 function initDecl2 VarDecl [al_variable_decl]
101 replace [repeat ruby_lang_stmt]
106 function initDecl3 VarDecl [al_variable_decl]
109 replace [repeat ruby_lang_stmt]
114 function initDecl4 VarDecl [al_variable_decl]
117 replace [repeat ruby_lang_stmt]
122 function initDecl5 VarDecl [al_variable_decl]
124 Type [al_type_decl] Id [id] Union [union] ';
125 replace [repeat ruby_lang_stmt]
127 Id '= '[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] ';
131 function alStmtToRuby1 AlStmt [action_lang_stmt]
133 VarDecl [al_variable_decl]
135 Type [al_type_decl] Id [id] OptUnion [opt union] ';
136 replace [repeat ruby_lang_stmt]
138 _ [initDecl1 VarDecl] [initDecl2 VarDecl]
139 [initDecl3 VarDecl] [initDecl4 VarDecl]
143 function alTermToRuby
150 function alExprExtendToRuby AlExprExtend [repeat al_expr_extend]
151 deconstruct AlExprExtend
152 Op [al_expr_op] Term [al_term] Rest [repeat al_expr_extend]
153 construct RubyRest [repeat ruby_expr_extend]
154 _ [alExprExtendToRuby Rest]
155 replace [repeat ruby_expr_extend]
157 Op Term [alTermToRuby] RubyRest
160 % Note: this doesn't go into the ( al_expr ) form of al_term.
161 function alExprToRuby AlExpr [al_expr]
163 ALTerm [al_term] AlExprExtend [repeat al_expr_extend]
164 construct RubyExprExtend [repeat ruby_expr_extend]
165 _ [alExprExtendToRuby AlExprExtend]
166 construct Result [opt ruby_expr]
167 ALTerm [alTermToRuby] RubyExprExtend
168 replace [opt ruby_expr]
173 function alStmtToRuby2 AlStmt [action_lang_stmt]
176 construct OptRubyExpr [opt ruby_expr]
177 _ [alExprToRuby AlExpr]
178 deconstruct OptRubyExpr
180 replace [repeat ruby_lang_stmt]
186 replace [repeat ruby_lang_stmt]
187 'do Block [repeat ruby_lang_stmt] 'end
192 function alOptElseRuby AlOptElse [opt al_else]
193 deconstruct AlOptElse
195 AlSubStmt [action_lang_stmt]
196 construct AlSubStmts [repeat action_lang_stmt]
198 construct RubySubStmts [repeat ruby_lang_stmt]
199 _ [alToRuby AlSubStmts]
200 deconstruct RubySubStmts
201 RubySubStmt [ruby_lang_stmt]
202 replace [opt ruby_else]
205 RubySubStmts [liftBlock]
208 function alStmtToRuby3 AlStmt [action_lang_stmt]
210 'if '( AlExpr [al_expr] ')
211 AlSubStmt [action_lang_stmt]
212 AlOptElse [opt al_else]
213 construct OptRubyExpr [opt ruby_expr]
214 _ [alExprToRuby AlExpr]
215 deconstruct OptRubyExpr
217 construct AlSubStmts [repeat action_lang_stmt]
219 construct RubySubStmts [repeat ruby_lang_stmt]
220 _ [alToRuby AlSubStmts]
221 construct OptRubyElse [opt ruby_else]
222 _ [alOptElseRuby AlOptElse]
223 replace [repeat ruby_lang_stmt]
226 RubySubStmts [liftBlock]
231 function alStmtToRuby4a AlStmt [action_lang_stmt]
234 replace [repeat ruby_lang_stmt]
239 function alStmtToRuby4b AlStmt [action_lang_stmt]
241 'prints String [stringlit] ';
242 replace [repeat ruby_lang_stmt]
244 'print '( String ') ';
247 function alStmtToRuby4c AlStmt [action_lang_stmt]
250 replace [repeat ruby_lang_stmt]
252 '_a = Id '[0..pos-1] ';
253 'print '( '_a '. 'pack '( '"c*" ') ') ';
256 function alStmtToRuby4d AlStmt [action_lang_stmt]
259 replace [repeat ruby_lang_stmt]
261 '_m = 'data '[ts..te-1] ';
262 'print '( '_m '. 'pack '( '"c*" ') ') ';
265 function alStmtToRuby5 AlStmt [action_lang_stmt]
267 '{ AlSubStmts [repeat action_lang_stmt] '}
268 construct RubySubStmts [repeat ruby_lang_stmt]
269 _ [alToRuby AlSubStmts]
270 replace [repeat ruby_lang_stmt]
272 'do RubySubStmts 'end
275 function alStmtToRuby6 AlStmt [action_lang_stmt]
277 RagelStmt [al_ragel_stmt]
278 replace [repeat ruby_lang_stmt]
286 construct BaseId [id]
289 BaseId [unquote CharLit]
290 construct EmptyString [stringlit]
292 construct Repl [stringlit]
293 EmptyString [quote Id]
299 function alToRuby AlStmts [repeat action_lang_stmt]
301 FirstStmt [action_lang_stmt] Rest [repeat action_lang_stmt]
302 construct RubyFirst [repeat ruby_lang_stmt]
304 [alStmtToRuby1 FirstStmt]
305 [alStmtToRuby2 FirstStmt]
306 [alStmtToRuby3 FirstStmt]
307 [alStmtToRuby4a FirstStmt]
308 [alStmtToRuby4b FirstStmt]
309 [alStmtToRuby4c FirstStmt]
310 [alStmtToRuby4d FirstStmt]
311 [alStmtToRuby5 FirstStmt]
312 [alStmtToRuby6 FirstStmt]
314 construct RubyRest [repeat ruby_lang_stmt]
316 replace [repeat ruby_lang_stmt]
318 RubyFirst [. RubyRest]
322 replace [al_host_block]
323 '{ AlStmts [repeat action_lang_stmt] '}
324 construct RubyStmts [repeat ruby_lang_stmt]
331 replace [cond_action_stmt]
332 'action Id [id] '{ AlExpr [al_expr] '}
333 construct OptRubyExpr [opt ruby_expr]
334 _ [alExprToRuby AlExpr]
335 deconstruct OptRubyExpr
338 'action Id '{ RubyExpr '}
341 rule lowercaseMachine
342 replace $ [machine_stmt]
345 'machine Id [tolower] ';
348 function langTransRuby
350 Definitions [repeat action_lang_stmt]
352 Initializations [repeat action_lang_stmt]
354 construct RubyDefinitions [repeat ruby_lang_stmt]
355 _ [alToRuby Definitions]
356 construct RubyInitializations [repeat ruby_lang_stmt]
357 _ [alToRuby Initializations]
358 construct NewRagelDef [ragel_def]
359 RagelDef [actionTransRuby] [condTransRuby] [lowercaseMachine]
360 import ArrayInits [ruby_statements]
361 ArrayInitStmts [repeat ruby_lang_stmt]
365 ArrayInitStmts [. RubyInitializations]
372 export ArrayInits [ruby_statements]