I understand that an algebraic expression can be described by a context free grammar and not by a regular grammar (I thought due to the recursive requirement). However, i'm only referring to the validation of the next symbol. All I want to express within ragel is that within the buffer, "2 3" shouldn't match since it doesn't make sense for a number to be directly followed by another number whereas "2 +" or "2 )" would make sense. I can see doing this via the lookahead strategy you talk about in the manual, but that seems to be a little excessive. It just seems like all I am making use of to implement this portion is a next-state table so it can't be so off the wall. Am I still totally off the mark?
~pramukta also, is the dragon book still the best place to look for this stuff? On Apr 20, 2009, at 7:16 PM, Adrian Thurston wrote: > 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 >> [email protected] >> http://www.complang.org/mailman/listinfo/ragel-users > > _______________________________________________ > ragel-users mailing list > [email protected] > http://www.complang.org/mailman/listinfo/ragel-users _______________________________________________ ragel-users mailing list [email protected] http://www.complang.org/mailman/listinfo/ragel-users
