# How to build a parser for syntactic analysis of regular expressions?

Is it possible to build a parsing algorithm that build a parse tree using a top-down method that simulate a derivation process for regular expressions, like we do for type 2 languages?

My guess

Given a regular expression r, build its FSA, then obtain the grammar that generate r in order to build a parse tree

• It's not clear to me what your question is. A regular expression is not a grammar (and there is no obvious unique homomorphism between regular expressions and regular grammars), so I'm not sure what you expect to be the parse tree. I suppose you could try recursively mapping substrings to subpatterns in the regular expression, but in many cases there are multiple possible mappings. – rici Nov 3 '17 at 18:46