Home

parsergenerator

Parser generators, also known as parser generators, are software tools that produce parsers from formal grammar specifications. A user writes a grammar describing tokens and the syntactic rules of a language or data format. The generator processes the specification and emits source code for a parser in a target programming language. The resulting parser analyzes input streams, builds parse trees or abstract syntax trees, and reports syntax errors with location information.

Most practical parsers are generated for deterministic grammars and commonly implement LR, LALR, or LL parsing

Generated code often includes hooks or semantic actions to build an AST or perform semantic checks as

Common examples of parser generators are Yacc, Bison, ANTLR, and JavaCC. They are used in compilers, interpreters,

strategies.
Yacc
and
Bison
produce
LALR
parsers,
while
ANTLR
targets
LL-type
parsing
with
adaptive
lookahead.
Grammar
designers
may
need
to
resolve
ambiguities,
specify
operator
precedence
and
associativity,
and
sometimes
rewrite
left-recursive
rules
for
LL
parsers.
Tokenization
is
usually
performed
by
a
separate
lexer,
though
some
tools
integrate
scanning
and
parsing.
the
parse
proceeds.
The
tool
may
rely
on
a
runtime
library
for
token
streams,
error
reporting,
and
parse-tree
facilities.
Users
typically
supply
the
grammar
plus
a
small
amount
of
host-language
code
for
actions;
the
generator
then
emits
compilable
code
that
uses
that
runtime.
configuration
file
parsers,
data
validators,
and
data-interchange
processors.
The
main
trade-offs
involve
expressiveness
versus
complexity,
handling
of
ambiguity,
and
the
quality
of
error
messages.