Hi,
I am trying to write a parser for basic regular expressions using elm-tools/parser version 2.0.1 but I cannot. By saying “basic” I mean that I only need alternation, concatenation, iteration and groups.
I want to parse those regular expressions into the following type
type Regexp
= Alternation (List Regexp)
| Concatenation (List Regexp)
| Iteration Regexp
| Group Regexp
| Leaf Char
So, for example, what I want to get after parsing the expression
(ab)*|(c)d*
is
Alternation
[ Iteration
Group
Concatenation
[ Leaf `a`
, Leaf `b`
]
, Concatenation
[ Group
Leaf `c`
, Iteration
Leaf `d`
]
]
Here is what I did https://ellie-app.com/ZN3Kx4Wka1/1 which only partially works.
Maybe somebody can help me.
PS: In case you are curious, this is for a web-app that visualizes regex-matching algorithms step-by-step (using finite automata). I do it for my students and will make it open-source. The rest of the app is almost ready, I just need the parser.