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 'print '( 'data '[tokstart..tokend-1] ') ';
264 function alStmtToRuby5 AlStmt [action_lang_stmt]
266 '{ AlSubStmts [repeat action_lang_stmt] '}
267 construct RubySubStmts [repeat ruby_lang_stmt]
268 _ [alToRuby AlSubStmts]
269 replace [repeat ruby_lang_stmt]
271 'do RubySubStmts 'end
274 function alStmtToRuby6 AlStmt [action_lang_stmt]
276 RagelStmt [al_ragel_stmt]
277 replace [repeat ruby_lang_stmt]
285 construct BaseId [id]
288 BaseId [unquote CharLit]
289 construct EmptyString [stringlit]
291 construct Repl [stringlit]
292 EmptyString [quote Id]
298 function alToRuby AlStmts [repeat action_lang_stmt]
300 FirstStmt [action_lang_stmt] Rest [repeat action_lang_stmt]
301 construct RubyFirst [repeat ruby_lang_stmt]
303 [alStmtToRuby1 FirstStmt]
304 [alStmtToRuby2 FirstStmt]
305 [alStmtToRuby3 FirstStmt]
306 [alStmtToRuby4a FirstStmt]
307 [alStmtToRuby4b FirstStmt]
308 [alStmtToRuby4c FirstStmt]
309 [alStmtToRuby4d FirstStmt]
310 [alStmtToRuby5 FirstStmt]
311 [alStmtToRuby6 FirstStmt]
313 construct RubyRest [repeat ruby_lang_stmt]
315 replace [repeat ruby_lang_stmt]
317 RubyFirst [. RubyRest]
321 replace [al_host_block]
322 '{ AlStmts [repeat action_lang_stmt] '}
323 construct RubyStmts [repeat ruby_lang_stmt]
330 replace [cond_action_stmt]
331 'action Id [id] '{ AlExpr [al_expr] '}
332 construct OptRubyExpr [opt ruby_expr]
333 _ [alExprToRuby AlExpr]
334 deconstruct OptRubyExpr
337 'action Id '{ RubyExpr '}
340 rule lowercaseMachine
341 replace $ [machine_stmt]
344 'machine Id [tolower] ';
347 function langTransRuby
349 Definitions [repeat action_lang_stmt]
351 Initializations [repeat action_lang_stmt]
353 construct RubyDefinitions [repeat ruby_lang_stmt]
354 _ [alToRuby Definitions]
355 construct RubyInitializations [repeat ruby_lang_stmt]
356 _ [alToRuby Initializations]
357 construct NewRagelDef [ragel_def]
358 RagelDef [actionTransRuby] [condTransRuby] [lowercaseMachine]
359 import ArrayInits [ruby_statements]
360 ArrayInitStmts [repeat ruby_lang_stmt]
364 ArrayInitStmts [. RubyInitializations]
371 export ArrayInits [ruby_statements]