parsingif-statementcontext-free-grammarparse-treeregexp-grammars

How to Draw a Parse tree contains multiple statements in if condition?


I want to draw a parse tree have multiple statements if the condition is true, and multiple statements if the condition is false.

I know how to draw for 1 statement.


Solution

  • You are missing the syntactic element of a block or statement-listthat may consist of multiple statements but also may be used as a statement.

    In your diagram statement would expand to a block and that then contains the statements.