Re: [sqlite] using lemon
On Thu, May 10, 2012 at 4:59 PM, Baruch Burstein wrote: > Can anyone suggest a lexical scanner generator that: > a) Works well with Lemon? > b) Is also thread-safe (like Lemon)? > > Does Flex work well with Lemon? (I think it is not thread-safe, but it is > very popular and has plenty of examples around, which is also a plus for > me) > > I am trying to learn a little about writing tokenizers/parsers, and thought > a */Lemon combo would be better to learn if I don't have any previous > experience anyway than Flex/Bison. > In my experience, lexical scanner generator programs like Flex are more trouble than they are worth. I find it far easier to write the lexer by hand. And you get a much smaller and faster lexer if you do it that way too. Example hand-written lexer code: http://www.sqlite.org/src/artifact/1e86210d397?ln=107-378 > > -- > Programming today is a race between software engineers striving to build > bigger and better idiot-proof programs, and the Universe trying to produce > bigger and better idiots. So far, the Universe is winning. - Rich Cook > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] using lemon
> Can anyone suggest a lexical scanner generator that: > a) Works well with Lemon? > b) Is also thread-safe (like Lemon)? > > Does Flex work well with Lemon? (I think it is not thread-safe, but it is > very popular and has plenty of examples around, which is also a plus for me) > > I am trying to learn a little about writing tokenizers/parsers, and thought > a */Lemon combo would be better to learn if I don't have any previous > experience anyway than Flex/Bison. I've used re2c recently. It should meet your needs, and worked well in my case. There is a lack of documentation, but I've pot most issues I've ran into on my blog : http://www.palsenberg.com/development/working-with-re2c-lessons-learned If you live up to those rules, live should be pleasant :) Igmar ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] using lemon to create a c++ parser class
Wilson, Ron uttered: It has been a very long time since I have tinkered with lex/yacc but my current project requires a parser. I'm thinking of learning lemon. Frankly, the sqlite code base is far more complex than what I will implement. Is anyone willing to share a lemon parse.y code example for something less complex than SQL? There are tutorials on the net that might be worth looking at, for example: http://freshmeat.net/articles/view/1270/ Also, i'm looking for advice on using lemon to make a c++ parser class instead of a global c parser function. Is it as simple as declaring the following? %name MyParserClass::Parse I'm pretty sure I can create the right c++ preamble with %include. Also, is there a cheap way to make lemon output a .cpp file besides renaming the output file? Feel free to tell me I'm on a foolish quest if I am. The C++ quest might be unnecassary, but I wouldn't say foolish. There is no problem linking C and C++ code. I'd say just leave the Parse function as a C function. You might even be able to make it static, thus limiting it's scope, and wrapping that static function in a class, but why bother? RW Christian -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \ - To unsubscribe, send email to [EMAIL PROTECTED] -