Created
January 18, 2016 05:04
-
-
Save wbars/343df935ba8323c06dd4 to your computer and use it in GitHub Desktop.
factorial parse tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROGRAM program_name; | |
Function fac(n: integer;): Integer; | |
VAR | |
n: Integer; | |
BEGIN | |
IF n = 1 THEN fac = 1 ELSE fac = n * fac(n - 1); | |
END; | |
BEGIN | |
print(fac(10)); | |
END. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
├── Program | |
├── Identifier(program_name) | |
└── ProgramBody | |
├── Function | |
├── FunctionSignature | |
├── Identifier(fac) | |
├── Var | |
└── VarDeclaration | |
├── Identifier(n) | |
├── Separate(COLON) | |
└── Identifier(integer) | |
└── Type(INTEGER) | |
└── ProgramBody | |
├── Var | |
└── VarDeclaration | |
├── Identifier(n) | |
├── Separate(COLON) | |
└── Type(INTEGER) | |
└── CompoundStatement | |
├── Condition | |
├── Expression | |
├── Identifier(n) | |
├── Operator(EQUALS) | |
└── Int(1) | |
└── CompoundStatement | |
└── Expression | |
├── Identifier(fac) | |
├── Operator(EQUALS) | |
└── Int(1) | |
└── Expression | |
├── Identifier(fac) | |
├── Operator(EQUALS) | |
└── Expression | |
└── Term | |
├── Identifier(n) | |
├── Operator(MULTIPLY) | |
└── FunctionCall | |
├── Identifier(fac) | |
└── SimpleExpression | |
├── Identifier(n) | |
├── Operator(MINUS) | |
└── Int(1) | |
└── CompoundStatement | |
└── Expression | |
└── FunctionCall | |
├── Identifier(print) | |
└── FunctionCall | |
├── Identifier(fac) | |
└── Int(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment