AST Module
Types
| Type | Description |
|
Part of the output of CompilerLalrParserSpec |
|
|
|
|
|
|
|
|
Hold the results of cpmuting the LALR(1) closure of an LR(0) kernel |
|
|
|
|
|
|
|
Indexes into the memoizing table for the Goto computations Embed in a single integer, since these are faster keys for the dictionary hash tables Logically: type GotoItemIndex = GotoItemIdx of KernelIdx * SymbolIndex |
|
|
|
|
|
Represent (ProductionIndex,ProdictionDotIndex) as one integer |
|
|
LR(0) kernels |
|
|
Indexes of LR(0) kernels in the KernelTable |
|
Indexes in the LookaheadTable, SpontaneousTable, PropagateTable Embed in a single integer, since these are faster keys for the dictionary hash tables Logically: type KernelItemIndex = KernelItemIdx of KernelIdx * Item0 |
|
|
A mutable table giving an index to each LR(0) kernel. Kernels are referred to only by index. |
|
|
A mutable table maping kernels to sets of lookahead tokens |
|
|
|
|
|
|
|
|
Allocate indexes for each non-terminal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Allocate indexes for each production |
|
|
A mutable table giving a Set |
|
|
|
|
|
A mutable table giving a lookahead set Set |
|
|
|
|
Representation of Symbols.
Ideally would be declared as
type SymbolIndex = PTerminal of TerminalIndex | PNonTerminal of NonTerminalIndex
but for performance reasons we embed as a simple integer (saves ~10%)
We use an active pattern to reverse the embedding.
|
|
|
|
|
|
|
|
|
|
|
|
Indexes in the TerminalTable and NonTerminalTable |
|
|
Allocate indexes for each terminal |
Functions and values
| Function or value |
Description
|
Full Usage:
CompilerLalrParserSpec logf spec
Parameters:
('a -> unit) -> unit
spec : ProcessedParserSpec
Returns: CompiledSpec
Type parameters: 'a (requires :> System.IO.TextWriter) |
Compile a pre-processed LALR parser spec to tables following the Dragon book algorithm
|
Full Usage:
CreateDictionary xs
Parameters:
('a * 'b) seq
Returns: Dictionary<'a, 'b>
Type parameters: 'a, 'b (requires equality) |
A standard utility to create a dictionary from a list of pairs
|
|
|
|
|
|
|
Full Usage:
Memoize f
Parameters:
'a -> 'b
Returns: 'a -> 'b
Type parameters: 'a, 'b (requires equality) |
A general standard memoization utility. Be sure to apply to only one (function) argument to build the residue function!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Active patterns
| Active pattern |
Description
|
|
|
Full Usage:
(|KeyValue|) kvp
Parameters:
KeyValuePair<'a, 'b>
Returns: 'a * 'b
Type parameters: 'a, 'b |
An active pattern that should be in the F# standard library
|
|
|
FsLexYacc