Yakker is a parser generator that supports semantic actions, lexical binding of semantic values, and speculative parsing techniques such as backtracking and context-free lookahead. To avoid executing semantic actions in speculative parses that will eventually be discarded, we divide parsing into two conceptually independent phases. In the first (early) phase, the parser explores multiple possible parse trees without executing semantic actions. The second (late) phase executes the delayed semantic actions once the first phase has determined they are necessary. Execution of the two phases can be overlapped.
We structure the early phase as a transducer which maps the input language to an output language of labels. A string in the output language is a history of the semantic actions that would have been executed in a parse of the input. The late phase is implemented as a deterministic, recursive descent parse of the history.
We formalize delayed semantic actions and discuss a number of practical issues involved in implementing them in Yakker, including our support for regular right part grammars and dependent parsing, the design of the data structures that support histories, and memory management techniques critical for efficient implementation.
[1]
George C. Necula,et al.
Elkhound: A Fast, Practical GLR Parser Generator
,
2003,
CC.
[2]
Eelco Visser,et al.
Syntax definition for language prototyping
,
1997
.
[3]
Trevor Jim,et al.
A New Method for Dependent Parsing
,
2011,
ESOP.
[4]
Jukka Paakki,et al.
Attribute grammar paradigms—a high-level methodology in language implementation
,
1995,
CSUR.
[5]
PaakkiJukka.
Attribute grammar paradigmsa high-level methodology in language implementation
,
1995
.
[6]
Murray Hill,et al.
Yacc: Yet Another Compiler-Compiler
,
1978
.
[7]
Adrian Johnstone,et al.
Tear-Insert-Fold grammars
,
2010,
LDTA.
[8]
David Walker,et al.
Semantics and algorithms for data-dependent grammars
,
2010,
POPL '10.
[9]
Elizabeth Scott,et al.
SPPF-Style Parsing From Earley Recognisers
,
2008,
LDTA@ETAPS.
[10]
Masaru Tomita,et al.
Efficient Parsing for Natural Language: A Fast Algorithm for Practical Systems
,
1985
.
[11]
Paul Klint,et al.
The Syntax Definition Formalism SDF
,
2007
.