|
I actually do have a follow up question: I am now trying to wrap my head around the re module and tried making a simple grammar to parse something like this a = 'b' and put it into a dictionary style table a la: { a = 'b'} I tried to do so using table and named group capture, but I can’t for the life of me figure out how to dynamically set the name of the group capture. Will I have to write a custom helper function to achieve this or is there a pure re way? Here is the code: local attribute = re.compile([[ attr <- {| {:<identifier>: <attributeValue> :} |} identifier <- (!%nl [a-zA-Z][a-zA-Z0-9_]*)+ attributeValue <- (" "+ "=" " "+ "'" {<identifier>} "'") ]]) This is the line where I try to capture the first identifier as the name for the group capture: attribute <- {| {:<identifier>: <attributeValue> :} |} Which fails with: pattern error near ': <attributeValue> :}…' Any thoughts welcome! Thanks Matthias
|