TC-1/2-Parser Recurring Bugs
- Assertion
map_.empty()
failed. A
TWEAST
added an AST node to theMetavarMap
’smap_
, but it was never retrieved.Check that you handle the scanning of metavariables correctly, and that you create the corresponding metavariable when you match the metavar grammar rules.
- Precondition
the_program
failed. the_program
corresponds to the root of your AST, and you are supposed to set it to the result of the parsing. Have you looked at every FIXME?- Pretty Printer prints nothing yet does not crash
Your code is wrapped into a
ChunkList
containing theprimitive
declarations as well as themain
function. You need to complete the methods forChunkList
andFunctionDec
in all of your visitors to be able to visit any other node.- When to print parenthesis?
Printing parenthesis around every node is not necessary. Printing in fewer occasions than it should, however, will result in problems now or later. Here is a good example that showcases some of those occasions to reward you for reading this far:
(if 1 then (x:=1)+2)+3
. In general, every AST node whose rightmost component is anexp
should be wrapped. Simple as that.