1 Porting Ragel Programs to Version 2
2 ===================================
5 1. Move all ?, +, and * operators to the right hand side of the operand.
7 float = *digit ?('.' +digit);
9 float = digit* ('.' digit+)?;
11 2. Change all assignments to main from a definition using the = operator to an
12 instantiation using the := operator.
18 3. Remove $0 %! operations for clearing priorities.
20 4. Anywhere implicit default priorities of zero are used to interact with
21 explicitly set non-zero transitions, set the priorities to zero explicitly.
23 main := any* 'FIN' :1;
25 main := ( any $0 )* 'FIN' :1;
27 5. If priorities need to interact across different machines, use a common name.
28 Note that priority names default to the name of the machine they are assigned
32 main := wild 'FIN' :1;
35 main := wild 'FIN' :wild,1;
37 6. If using clear keyword or operators modified with ^, duplicate the operand
38 machines and rewrite them such that the cleared actions and suppressed out
39 transitions and out priorities are removed.
41 7. Change func keyword to action.
43 8. Escape any - symbols and initial ^ symbol in or literals ([] outside of
50 9. In C output, lowercase init, execute and finish routines and put an
51 underscore in between the fsm name and the function name. Also qualify
52 references to the fsm structure with the struct keyword.
56 fsmExecute( &f, buf, len );
61 fsm_execute( &f, buf, len );
64 10. In C++ output, lowercase the init, execute and finish routines. Also make
65 sure that the init routine is explicitly called.
69 f.Execute( buf, len );
74 f.execute( buf, len );
77 11. Remove calls to the accept routine, instead examine the return value of the
78 finish routine. If the machine does not accept then finish returns -1 or 0, if
79 the machine accepts then finish returns 1.
83 cout << "ACCEPT" << endl;
86 cout << "ACCEPT" << endl;