[antlr-interest] [C target] how to skip empty lines
Kevin J. Cummings
cummings at kjchome.homeip.net
Thu Oct 22 17:15:18 PDT 2009
On 10/22/2009 06:08 PM, Юрушкин Михаил wrote:
> Good evening.
> thanks for your support!
>
> Could u give me one tip.
> I user C target and want to parse such input
>
> "a = 3.14
> f(x) = 3x^2 - 4x + 2
>
> print "The value of f for " a " is " f(a)
> print "The derivative of " f() " is " f'()
>
>
> list variables
> list functions
>
> g(y) = 2y^3 + 6y - 5
> h = f + g
> print h()"
>
> I use this tutorial
> http://jnb.ociweb.com/jnb/jnbJun2008.html
>
> but parser fails.. when finds empty lines. It's correct, but how can i fix
> it? It's common problem for all languages. Programmer can input some empty
> lines between constructions to improve code readability...
Have your "whitespace" be "skipped" by your lexer? That's what I do in
almost every compiler I've written. Your lexer tokenizes, and tokens
can be seperated by whitespace, so, so long as you don't have lexer
rules where whitespace is significant, you should be OK.
--
Kevin J. Cummings
kjchome at rcn.com
cummings at kjchome.homeip.net
cummings at kjc386.framingham.ma.us
Registered Linux User #1232 (http://counter.li.org)
More information about the antlr-interest
mailing list