[ragel-users] access variable in expression?

Adrian Thurston thurston at complang.org
Fri Oct 31 06:17:31 UTC 2008

Hi Larry,

Two options: you can use a separate machine instantiation to count items 
and jump back to the main machine when the number of items has been 
consumed like you suggest. The alternative is to use conditions if you 
need the counting to be done in a reusable machine definition. These are 
semantic tests that can be used to check a count. See section 6.5.


Larry Edelstein wrote:
> Am I able to use the value of a variable as an expression, and if so, how?
> I am trying to parse a language like this:
> number = digit+ >start_capture_number_of_names 
> %end_capture_number_of_names '\n';
> name = ^[\n]* '\n';
> main := number name{number_of_names}
> where number_of_names is the number I captured earlier.  
> Can I do it this way, or do I need to iterate using actions and the 
> statements defined in 3.4 of the manual?
> Larry Edelstein
> San Francisco, CA
> ------------------------------------------------------------------------
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users

More information about the ragel-users mailing list