Open LemmingAvalanche opened 9 years ago
You need to tell the parser to parse start[P]
. You'll then get a parsetree with the root representing the start symbol, which has layout/comments to the left and right of it, and a top
field containing your actual tree.
From the tutor (http://tutor.rascal-mpl.org/Rascal/Declarations/SyntaxDefinition/SyntaxDefinition.html):
The start modifier identifies the start of a grammar. The effect of a start modifier is that Rascal will generate an extra syntax definition before generating a parser that allows layout to before and after the start non-terminal. For example: layout L = [\ ]; start Program = Statement; will produce syntax start[Program] = L Program top L;. Note that the start[Program] type is now available in your program, and ParseTrees assigned to variable of that type will allow access to the top field.
This works:
But not this:
Nor this (file/text starts with whitespace):