[antlr-interest] how to implement a regular expression engine

Nicolas Hernandez nicolas.hernandez at gmail.com
Sat Aug 27 09:57:57 PDT 2011


Dear Everyone,

I ve got some questions. I am a newbie with ANTLR. I ve got the
feeling it can help me with my problem but I m not sure exactly how.

Roughly speaking I would like to design my own pattern matching
language (a bit like the perl character regex or XPath)...

I feel that ANTLR can help me to define the grammar of this language.
But my point is how to use expressions of this grammar after that. I'm
asking for advices or good practices.

Let's say I have written a grammar for defining some matching rules.
ANTLR offers me some way to recognize the syntax of some given rules as input.
But now I would like to apply my rules on a flow of structured data to
recognize the parts which match the defined patterns.
I understand there is the possibility to associate actions (either
directly in parsing the grammar or in a second phase by walking a tree
grammar built from the parsing stage).

Would the best way be to build a rule structure by parsing them and
use this structure for parsing my flow of structured data in a
dedicated way ? Can the AST tree be useful for that ? Or what ?

I am a bit confused because there is actually two levels of parsing...
the rule parsing and the data structure I aim to parse with the rules
(a kind of meta one).

Thanks in advance for any suggestion

Regards

/Nicolas


More information about the antlr-interest mailing list