[ragel-users] ragel scanner construct question

Adrian Thurston thurston at complang.org
Mon Apr 20 23:16:32 UTC 2009


You can't do that in Ragel. To understand why you'll have to do some 
reading on context-free VS regular languages. Pick up a compiler book. 
It's a big topic.

-Adrian

Pramukta Kumar wrote:
> I am experimenting with ragel to validate and tokenize an algebraic  
> expression in one step.  Basically convert something like "3 + A * 2 /  
> ( 1 - 5 )" to "[3.0, 'A' , 2.0, :*, 1.0, 5.0, :-, :/, :+]" if it's  
> valid, and throw an error otherwise. I'm using the ruby target, and  
> the standard "shunting yard" algorithm or whatever.
> 
> I have the thing working (I think, still testing) by using the scanner  
> construct and making an "allowed transition" table by hand.  Each of  
> the tokenizing actions validates against this table to see whether it  
> should continue.  It seems to me that there is probably a nice way to  
> do this within ragel itself but I can't seem to figure it out.  Can  
> somebody point me in the right direction?
> 
> the files are up on github: http://github.com/prakatmac/expression-parser/tree/master
> 
> Sorry if this is a dumb question.  I'm pretty new at this stuff.   
> Thanks.
> 
> ~pramukta
> 
> _______________________________________________
> 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