Piacenti
Piacenti

Reputation: 1218

Does ANTLR provide these features?

I have a generic parser that I created that is fairly small in terms of lines of code but that I have been able to successfully use for my purposes. It can handle recursive grammars, performs well, supports regex, allow for both normal tokenization mode or context specific tokenization which in turn allows for otherwise conflicting tokens to work just fine in grammars and so on.

Due to the overall popularity of ANTLR I decided it may be worth learning more about it (maybe I've been reinventing the wheel) but before making the time investment I'd like to know if it could do some of the same things my parser currently provides to me. Unfortunately, I wasn't able to find a comprehensive enough list of its features, at least not one that answered the questions I pose below.

Does ANTRL provides the features below?

Upvotes: 0

Views: 211

Answers (1)

CoronA
CoronA

Reputation: 8075

  1. ANTLR reports the possible tokens at mismatch, so you could use it for autocompletion
  2. The ANTLR visitor pattern is very generic. ANTLR generates the interface, you have to implement it, so you could give in features you want
  3. ANTLR strictly separates lexing and parsing. So assigning different token types to the same token is not possible
  4. You probably may implement a search mode with ANTLR, but it would not be rather efficient (unless you add a separate efficient search besides)

I think that a PEG-Parser would be more suitable for your requirements. Yet keep in mind that the strict separation of parsing and lexing is more performant.

If you do not already use DFA-regexes for lexing and if performance is an issue, than switching technology (either to ANTLR or to PEG-Parsers) could be a good next step.

Upvotes: 1

Related Questions