[antlr-interest] Ambiguous lexer rules
Sam Barnett-Cormack
s.barnett-cormack at lancaster.ac.uk
Mon Jul 4 04:21:30 PDT 2011
On 04/07/2011 06:56, Fs Cc wrote:
> Hi Stephen,
>
> Thank you! Semantic predicates work for me. In fact, the lexer::xstrMode
> and lexer::inArray in following code are used to mimic the parser logic. We need
> them because lexer is run before parser. Is it possible for ANTLR to merge the
> parser and the lexer into a single run? For example: when a parser rule is
> selected to run, ANTLR deduces the selected rule and select the correct lexer
> rule(just like how it select sub parser rules) to parse the raw string, so that
> we can avoid introducing parser logic into lexer.
If you really want to do it that way, then you might want to consider
using some other parser generator than ANTLR; AIUI, ANTLR is quite
closely wedded to the philosophy of separation of lexical and
grammatical structure. I've seen very few instances where a language
actually needs smudging between the steps - usually it can be acheived
by refactoring, reframing the idea of what lexical elements are used.
Sam
More information about the antlr-interest
mailing list