[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Getting bison to ignore tokens... sometimes!
From: |
Paulo J. Matos |
Subject: |
Getting bison to ignore tokens... sometimes! |
Date: |
Tue, 31 May 2011 14:37:52 +0000 (UTC) |
User-agent: |
Pan/0.133 (House of Butterflies) |
Hi,
I am pretty sure bison cannot simply ignore tokens. However, I don't know
what's the usual flex/bison pattern to solve this issue.
I am implementing a parser for a language that terminates statements with
a newline, however, the newline doesn't always terminate statements...
only after a statement.
-----
x = x + 1
y = x + 2
-----
This should parse ok, since each statement is terminated by a new line.
If I tell lexer to lex '\n' as a EOS (end of statement) then something
like this won't parse:
-----
def myfunc {
x = x + 1
y = x + 2
}
-----
The reason for this is that it gets the tokens '{', '\n', 'x' (whitespace
ignored) and says : "hey, I am not expecting a EOS there". Now, I could
fill my parser with EOS between every two tokens, however, that's crazy
and there must be a better way.
Any suggestions?
Cheers,
--
PMatos
- Getting bison to ignore tokens... sometimes!,
Paulo J. Matos <=