Files
2025-02-Compiler/notes/3.md
2025-09-25 10:58:48 +09:00

56 lines
755 B
Markdown

# Syntax Analysis
## Context-Free Grammars (CFG)
## Parse Tree
A tree representation of the derivation
parse tree has `terminals` at the leaves, `non-terminals` at the interior.
An in-order traversal of the leaves is the original input.
* leftmost derivation
* rightmost derivation
### Ambiguity
should be removed
for example: `A + B * C` should be resolved
**removing ambiguity**
### AST (Abstract Syntax Tree)
### Error Handling
One of the purposes of the compiler is error handling.
- to detect non-valid programs
- and to translate the non-valid to the valid
## Parsing
* Top-down Parsing
**Recursive Descent Parsing**
by using backtracking
* Predictive Parsing
Parsing Table: no need to backtrack.
### Parser Implement