PDA

View Full Version : QLALR examples



dennis
2nd October 2010, 20:39
Hi everyone,

Is there any good tutorials/online books I can read about QLALR? I think its quite odd that the only thing I can find is this one article called "QLALR Adventures" which didn't explain as much as I hoped.

I want to set up some patterns and priorities to parse code like the one below and put it in a hierarchy QHash:

foo
{
bar
{
...
}
}

I know this is possible with plain old regular expression but I heard LALR is better when it comes to more complex things.

wysota
3rd October 2010, 14:01
There is no documentation and no tutorials on QLALR. If you want, I can try to help you with your task, I have a bit of experience with QLALR.

What did you manage to do so far? Where are you stuck?

dennis
3rd October 2010, 18:59
Actually I don't even know where to begin, I don't get the syntax used because I never used LALR before.

wysota
3rd October 2010, 20:07
Don't worry about the syntax, you'll learn it along the way. First have a parser class ready. You can take the one (I think it is called QParser) from one of examples that accompany qlalr. You can test it (to accomodate it in your own project) with the provided scanner and grammar files. When that's done you should start by implementing a rudimentary scanner to return the basic tokens (aka terminal symbols -- symbols that can't be decoposed to simpler symbols) from your area of use. Then you can study a bit about BNF (Bachus-Naur Form) if you want. That should get you going with implementing the grammar. At this point don't worry about actions associated with the grammar - just make your input parse properly with the scanner/parser pair.

dennis
9th October 2010, 14:28
I finally got some time over to play around with qt so I checked out the QParser but I get this error message when I try to run it:


:: error: No rule to make target `calc_grammar.cpp', needed by `debug/calc_grammar.o'. Stop.

wysota
9th October 2010, 14:57
Run qlalr on the provided .g file.