Pattern 8Parse Tree


A parse tree describes how a parser recognized an input sentence.

A parse tree is sometimes called a syntax tree (as opposed to an abstract syntax tree). Despite not being that useful for building interpreters and translators, I’m including this pattern because parse trees are heavily used by development environments and text rewriting systems.


Parse trees record the sequence of rules a parser applies as well as the tokens it matches. Interior parse tree nodes represent rule applications, and leaf nodes represent token matches. Parse trees describe sentence structure by grouping input symbols into subtrees. Subtrees represent the structure of phrases (sentence fragments). For example, the following parse ...

Get Language Implementation Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.