Organizing input into a hierarchy

Tokens identify basic units; parsing determines how they form expressions, statements, or declarations. An operator sequence needs grammatical grouping before later stages can interpret its structure.

A parser may construct an abstract syntax tree, retain a fuller parse tree, or maintain other internal state. Recognizing membership in a grammar and preserving every derivation detail are different requirements chosen for the tool’s purpose.

References: [1] [2]

Expanding downward or reducing upward

Top-down approaches predict smaller components from an expected larger construct. Predictive recursive descent can associate procedures with rules, while table-driven LL parsing can use an explicit stack instead.

Bottom-up methods recognize input fragments and reduce them into larger constructs. LR parsing organizes this through states and shift-reduce actions. Strategies differ in grammar restrictions and lookahead requirements even when they produce comparable trees.

References: [3] [4]

Syntactic structure is only one check

A grammar can assign several trees to one string. Precedence, associativity, or explicit disambiguation rules select an interpretation. A reported conflict can arise from ambiguity or from limitations of the selected parsing method.

Accepted syntax can still contain undefined names or invalid type uses, which require semantic checks. Successful static checking likewise does not establish that the program fulfills its intended business behavior.

References: [2] [5]