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 function initDecl1 VarDecl [al_variable_decl]
88 replace [repeat ruby_lang_stmt]
93 function initDecl2 VarDecl [al_variable_decl]
96 replace [repeat ruby_lang_stmt]
101 function initDecl3 VarDecl [al_variable_decl]
104 replace [repeat ruby_lang_stmt]
109 function initDecl4 VarDecl [al_variable_decl]
112 replace [repeat ruby_lang_stmt]
117 function initDecl5 VarDecl [al_variable_decl]
119 Type [al_type_decl] Id [id] Union [union] ';
120 replace [repeat ruby_lang_stmt]
122 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] ';
126 function alStmtToRuby1 AlStmt [action_lang_stmt]
128 VarDecl [al_variable_decl]
130 Type [al_type_decl] Id [id] OptUnion [opt union] ';
131 replace [repeat ruby_lang_stmt]
133 _ [initDecl1 VarDecl] [initDecl2 VarDecl]
134 [initDecl3 VarDecl] [initDecl4 VarDecl]
138 function alTermToRuby
145 function alExprExtendToRuby AlExprExtend [repeat al_expr_extend]
146 deconstruct AlExprExtend
147 Op [al_expr_op] Term [al_term] Rest [repeat al_expr_extend]
148 construct RubyRest [repeat ruby_expr_extend]
149 _ [alExprExtendToRuby Rest]
150 replace [repeat ruby_expr_extend]
152 Op Term [alTermToRuby] RubyRest
155 % Note: this doesn't go into the ( al_expr ) form of al_term.
156 function alExprToRuby AlExpr [al_expr]
158 ALTerm [al_term] AlExprExtend [repeat al_expr_extend]
159 construct RubyExprExtend [repeat ruby_expr_extend]
160 _ [alExprExtendToRuby AlExprExtend]
161 construct Result [opt ruby_expr]
162 ALTerm [alTermToRuby] RubyExprExtend
163 replace [opt ruby_expr]
168 function alStmtToRuby2 AlStmt [action_lang_stmt]
171 construct OptRubyExpr [opt ruby_expr]
172 _ [alExprToRuby AlExpr]
173 deconstruct OptRubyExpr
175 replace [repeat ruby_lang_stmt]
181 replace [repeat ruby_lang_stmt]
182 'do Block [repeat ruby_lang_stmt] 'end
187 function alOptElseRuby AlOptElse [opt al_else]
188 deconstruct AlOptElse
190 AlSubStmt [action_lang_stmt]
191 construct AlSubStmts [repeat action_lang_stmt]
193 construct RubySubStmts [repeat ruby_lang_stmt]
194 _ [alToRuby AlSubStmts]
195 deconstruct RubySubStmts
196 RubySubStmt [ruby_lang_stmt]
197 replace [opt ruby_else]
200 RubySubStmts [liftBlock]
203 function alStmtToRuby3 AlStmt [action_lang_stmt]
205 'if '( AlExpr [al_expr] ')
206 AlSubStmt [action_lang_stmt]
207 AlOptElse [opt al_else]
208 construct OptRubyExpr [opt ruby_expr]
209 _ [alExprToRuby AlExpr]
210 deconstruct OptRubyExpr
212 construct AlSubStmts [repeat action_lang_stmt]
214 construct RubySubStmts [repeat ruby_lang_stmt]
215 _ [alToRuby AlSubStmts]
216 construct OptRubyElse [opt ruby_else]
217 _ [alOptElseRuby AlOptElse]
218 replace [repeat ruby_lang_stmt]
221 RubySubStmts [liftBlock]
226 function alStmtToRuby4a AlStmt [action_lang_stmt]
229 replace [repeat ruby_lang_stmt]
234 function alStmtToRuby4b AlStmt [action_lang_stmt]
236 'prints String [stringlit] ';
237 replace [repeat ruby_lang_stmt]
239 'print '( String ') ';
242 function alStmtToRuby4c AlStmt [action_lang_stmt]
245 replace [repeat ruby_lang_stmt]
247 '_a = Id '[0..pos-1] ';
248 'print '( '_a '. 'pack '( '"c*" ') ') ';
251 function alStmtToRuby4d AlStmt [action_lang_stmt]
254 replace [repeat ruby_lang_stmt]
256 'print '( 'data '[tokstart..tokend-1] ') ';
259 function alStmtToRuby5 AlStmt [action_lang_stmt]
261 '{ AlSubStmts [repeat action_lang_stmt] '}
262 construct RubySubStmts [repeat ruby_lang_stmt]
263 _ [alToRuby AlSubStmts]
264 replace [repeat ruby_lang_stmt]
266 'do RubySubStmts 'end
269 function alStmtToRuby6 AlStmt [action_lang_stmt]
271 RagelStmt [al_ragel_stmt]
272 replace [repeat ruby_lang_stmt]
280 construct BaseId [id]
283 BaseId [unquote CharLit]
284 construct EmptyString [stringlit]
286 construct Repl [stringlit]
287 EmptyString [quote Id]
293 function alToRuby AlStmts [repeat action_lang_stmt]
295 FirstStmt [action_lang_stmt] Rest [repeat action_lang_stmt]
296 construct RubyFirst [repeat ruby_lang_stmt]
298 [alStmtToRuby1 FirstStmt]
299 [alStmtToRuby2 FirstStmt]
300 [alStmtToRuby3 FirstStmt]
301 [alStmtToRuby4a FirstStmt]
302 [alStmtToRuby4b FirstStmt]
303 [alStmtToRuby4c FirstStmt]
304 [alStmtToRuby4d FirstStmt]
305 [alStmtToRuby5 FirstStmt]
306 [alStmtToRuby6 FirstStmt]
308 construct RubyRest [repeat ruby_lang_stmt]
310 replace [repeat ruby_lang_stmt]
312 RubyFirst [. RubyRest]
316 replace [al_host_block]
317 '{ AlStmts [repeat action_lang_stmt] '}
318 construct RubyStmts [repeat ruby_lang_stmt]
324 rule lowercaseMachine
325 replace $ [machine_stmt]
328 'machine Id [tolower] ';
331 function langTransRuby
333 Definitions [repeat action_lang_stmt]
335 Initializations [repeat action_lang_stmt]
337 construct RubyDefinitions [repeat ruby_lang_stmt]
338 _ [alToRuby Definitions]
339 construct RubyInitializations [repeat ruby_lang_stmt]
340 _ [alToRuby Initializations]
341 construct NewRagelDef [ragel_def]
342 RagelDef [actionTransRuby] [lowercaseMachine]
343 import ArrayInits [ruby_statements]
344 ArrayInitStmts [repeat ruby_lang_stmt]
348 ArrayInitStmts [. RubyInitializations]
355 export ArrayInits [ruby_statements]