Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Q: What is a lexer?

A: A lexer turns a source code file into a linear sequence of tokens.

Q: What is a parser?

A: A parser turns the tokens into an abstract syntax tree.

Q: What is an abstract syntax tree?

A: A hierarchical representation of the source code as a tree of nodes. For example, the function call

No Format

trace(1, 2);

is represented by the AST

No Format

FunctionCallNode "trace"
  LiteralNode 1
  LiteralNode 2

where indentation indicates a parent-child relationship.

Q: What is a code generator?

...