Pelles C forum

C language => User contributions => Topic started by: frankie on April 07, 2012, 08:59:12 PM

Title: Lemon Juice - Parser Lexer suite
Post by: frankie on April 07, 2012, 08:59:12 PM
Recently I made intensive use of Lemon Parser (the one used in SQLight) and I have to say that it works very well.
The problem is that doesn't exist a lexer with the same characteristics: light and resource friendly. The hystorical LEX and FLEX and derivatives are very heavy, and if you need more than one lexer in a single program is absolutely not easy.
At beginning I wrote scanners using routines in C, but for each grammar you had to rewrite the whole scanne, debug it, and so on...
Following some experiments on using regex's I found them more a more friendly and fast way to write a lexer. When I got aware that the code remained almost unchanged between implementations I decided to write a simple lexer with its own grammar to define and create scanners.
So this is, in the sample you'll find an hacked version of Lemon (I modified it to generate prototypes in the generated header file), the Juice lexer source and a sample called Calc.
Calc is a calculatore that have almost all mathematical and logical operators of C. You can write complex expression with brackets to modify the precedence.
Keep in mind that this is an alpha release.
Improvements and comments are welcome.
Title: Re: Lemon Juice - Parser Lexer suite
Post by: Grincheux on February 13, 2021, 07:49:52 PM
If I want to use that project It is obliged to create Lex files ?
Title: Re: Lemon Juice - Parser Lexer suite
Post by: frankie on February 14, 2021, 01:24:12 AM
Not sure to understand.
If you want to use the parser you can use it alone.
The parser I wrote is a simple lexer, but you don't have to use it if you don't need it.
The lemon parser works as usual stand-alone.