I have essentially the same question as PEG for Python style indentation, but I'd like to get a little more direction regarding this answer.
The answer successfully generates an array of strings that are each line of input with 'INDENT' and 'DEDENT' between lines. It seems like he's pretty much used PEG.js to tokenize, but no real parsing is happening.
So how can I extend his example to do some actual parsing?
As an example, how can I change this grammar:
start = obj
obj = id:id children:(indent obj* outdent)?
{
var o = {};
o[id] = children[1];
return (children[1] ? o : id);
}
id = [a-z]
indent = '{'
outdent = '}'
to use indentation instead of braces to delineate blocks, and still get the same output?
(Use http://pegjs.majda.cz/online to test that grammar with the following input: a{bcd{zyx{}}}
)