| '{ [NL] [IN] [ruby_statements] [EX] '} [NL]
end define
+redefine cond_action_stmt
+ 'action [id] '{ [al_expr] '} [NL]
+ | 'action [id] '{ [ruby_expr] '} [NL]
+end redefine
+
function initDecl1 VarDecl [al_variable_decl]
deconstruct VarDecl
'bool Id [id] ';
function initDecl5 VarDecl [al_variable_decl]
deconstruct VarDecl
- 'int Id [id] Union [union] ';
+ Type [al_type_decl] Id [id] Union [union] ';
replace [repeat ruby_lang_stmt]
by
- Id '= '[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] ';
+ 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] ';
end function
[initDecl5 VarDecl]
end function
+function alTermToRuby
+ replace [al_term]
+ 'first_token_char
+ by
+ 'data '[ts]
+end function
+
function alExprExtendToRuby AlExprExtend [repeat al_expr_extend]
deconstruct AlExprExtend
Op [al_expr_op] Term [al_term] Rest [repeat al_expr_extend]
_ [alExprExtendToRuby Rest]
replace [repeat ruby_expr_extend]
by
- Op Term RubyRest
+ Op Term [alTermToRuby] RubyRest
end function
% Note: this doesn't go into the ( al_expr ) form of al_term.
construct RubyExprExtend [repeat ruby_expr_extend]
_ [alExprExtendToRuby AlExprExtend]
construct Result [opt ruby_expr]
- ALTerm RubyExprExtend
+ ALTerm [alTermToRuby] RubyExprExtend
replace [opt ruby_expr]
by
Result
'print '( String ') ';
end function
+function alStmtToRuby4c AlStmt [action_lang_stmt]
+ deconstruct AlStmt
+ 'printb Id [id] ';
+ replace [repeat ruby_lang_stmt]
+ by
+ '_a = Id '[0..pos-1] ';
+ 'print '( '_a '. 'pack '( '"c*" ') ') ';
+end function
+
+function alStmtToRuby4d AlStmt [action_lang_stmt]
+ deconstruct AlStmt
+ 'print_token ';
+ replace [repeat ruby_lang_stmt]
+ by
+ '_m = 'data '[ts..te-1] ';
+ 'print '( '_m '. 'pack '( '"c*" ') ') ';
+end function
+
function alStmtToRuby5 AlStmt [action_lang_stmt]
deconstruct AlStmt
'{ AlSubStmts [repeat action_lang_stmt] '}
[alStmtToRuby3 FirstStmt]
[alStmtToRuby4a FirstStmt]
[alStmtToRuby4b FirstStmt]
+ [alStmtToRuby4c FirstStmt]
+ [alStmtToRuby4d FirstStmt]
[alStmtToRuby5 FirstStmt]
[alStmtToRuby6 FirstStmt]
[fixCharLit]
'{ RubyStmts '}
end rule
+rule condTransRuby
+ replace [cond_action_stmt]
+ 'action Id [id] '{ AlExpr [al_expr] '}
+ construct OptRubyExpr [opt ruby_expr]
+ _ [alExprToRuby AlExpr]
+ deconstruct OptRubyExpr
+ RubyExpr [ruby_expr]
+ by
+ 'action Id '{ RubyExpr '}
+end rule
+
rule lowercaseMachine
replace $ [machine_stmt]
'machine Id [id] ';
construct RubyInitializations [repeat ruby_lang_stmt]
_ [alToRuby Initializations]
construct NewRagelDef [ragel_def]
- RagelDef [actionTransRuby] [lowercaseMachine]
+ RagelDef [actionTransRuby] [condTransRuby] [lowercaseMachine]
import ArrayInits [ruby_statements]
ArrayInitStmts [repeat ruby_lang_stmt]
by