I have the following regex that I'm trying to convert to a CFG:
e representing the empty state). Basically I want to match a comma-separated list (without a leading or trailing comma) or nothing at all. Here are some of my attempts:
S = A A = e | a | a , A
This doesn't work, it matches
,a (leading comma).
S = A | B A = e B = a C C = , C | a | e
This doesn't work either, it matches
aa (trailing and missing comma).
Is my regex even representable as a CFG?
Thanks in advance