Header menu logo FsLexYacc

AST Module

Types

Type Description

Action

Part of the output of CompilerLalrParserSpec

ActionTable

Associativity

Closure1Table

Hold the results of cpmuting the LALR(1) closure of an LR(0) kernel

Code

CompiledSpec

GotoItemIndex

 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

Identifier

Item0

Represent (ProductionIndex,ProdictionDotIndex) as one integer

Kernel

LR(0) kernels

KernelIdx

Indexes of LR(0) kernels in the KernelTable

KernelItemIndex

 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

KernelTable

A mutable table giving an index to each LR(0) kernel. Kernels are referred to only by index.

LookaheadTable

A mutable table maping kernels to sets of lookahead tokens

NonTerminal

NonTerminalIndex

NonTerminalTable

Allocate indexes for each non-terminal

ParserSpec

PrecedenceInfo

ProcessedParserSpec

Prod

ProdictionDotIndex

Production

ProductionIndex

ProductionTable

Allocate indexes for each production

PropagateTable

A mutable table giving a Set for each kernel. The kernels represent the "propagate" items for the kernel. TODO: document this more w.r.t. the Dragon book.

Rule

SpontaneousTable

A mutable table giving a lookahead set Set for each kernel. The terminals represent the "spontaneous" items for the kernel. TODO: document this more w.r.t. the Dragon book.

Symbol

SymbolIndex

 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.

SymbolIndexes

Symbols

Terminal

TerminalIndex

Indexes in the TerminalTable and NonTerminalTable

TerminalTable

Allocate indexes for each terminal

Functions and values

Function or value Description

CompilerLalrParserSpec logf spec

Full Usage: CompilerLalrParserSpec logf spec

Parameters:
Returns: CompiledSpec

Compile a pre-processed LALR parser spec to tables following the Dragon book algorithm

logf : ('a -> unit) -> unit
spec : ProcessedParserSpec
Returns: CompiledSpec

CreateDictionary xs

Full Usage: CreateDictionary xs

Parameters:
    xs : ('a * 'b) seq

Returns: Dictionary<'a, 'b>

A standard utility to create a dictionary from a list of pairs

xs : ('a * 'b) seq
Returns: Dictionary<'a, 'b>

GotoItemIdx (i1, i2)

Full Usage: GotoItemIdx (i1, i2)

Parameters:
Returns: uint64
i1 : KernelIdx
i2 : SymbolIndex
Returns: uint64

KernelItemIdx (i1, i2)

Full Usage: KernelItemIdx (i1, i2)

Parameters:
Returns: int64
i1 : int
i2 : Item0
Returns: int64

LeastFixedPoint f set

Full Usage: LeastFixedPoint f set

Parameters:
    f : 'a -> 'a list
    set : Set<'a>

Returns: Set<'a>

A standard utility to compute a least fixed point of a set under a generative computation

f : 'a -> 'a list
set : Set<'a>
Returns: Set<'a>

Memoize f

Full Usage: Memoize f

Parameters:
    f : 'a -> 'b

Returns: 'a -> 'b

A general standard memoization utility. Be sure to apply to only one (function) argument to build the residue function!

f : 'a -> 'b
Returns: 'a -> 'b

OutputAssoc os p

Full Usage: OutputAssoc os p

Parameters:
os : TextWriter
p : Associativity

OutputSym os sym

Full Usage: OutputSym os sym

Parameters:
os : TextWriter
sym : Symbol

OutputSyms os syms

Full Usage: OutputSyms os syms

Parameters:
os : TextWriter
syms : Symbol[]

OutputTerminalSet os tset

Full Usage: OutputTerminalSet os tset

Parameters:
os : TextWriter
tset : string seq

PNonTerminal i

Full Usage: PNonTerminal i

Parameters:
Returns: SymbolIndex
i : NonTerminalIndex
Returns: SymbolIndex

PTerminal i

Full Usage: PTerminal i

Parameters:
Returns: SymbolIndex
i : TerminalIndex
Returns: SymbolIndex

ProcessParserSpecAst spec

Full Usage: ProcessParserSpecAst spec

Parameters:
Returns: ProcessedParserSpec
spec : ParserSpec
Returns: ProcessedParserSpec

ProcessWorkList start f

Full Usage: ProcessWorkList start f

Parameters:
    start : 'a list
    f : ('a -> unit) -> 'a -> unit

Create a work list and loop until it is exhausted, calling a worker function for each element. Pass a function to queue additional work on the work list to the worker function

start : 'a list
f : ('a -> unit) -> 'a -> unit

StringOfSym sym

Full Usage: StringOfSym sym

Parameters:
Returns: string
sym : Symbol
Returns: string

dotIdx_of_item0 item0

Full Usage: dotIdx_of_item0 item0

Parameters:
Returns: int32
item0 : Item0
Returns: int32

mkItem0 (prodIdx, dotIdx)

Full Usage: mkItem0 (prodIdx, dotIdx)

Parameters:
    prodIdx : int32
    dotIdx : int

Returns: Item0
prodIdx : int32
dotIdx : int
Returns: Item0

outputPrecInfo os p

Full Usage: outputPrecInfo os p

Parameters:
os : TextWriter
p : PrecedenceInfo

prodIdx_of_item0 item0

Full Usage: prodIdx_of_item0 item0

Parameters:
Returns: int32
item0 : Item0
Returns: int32

Active patterns

Active pattern Description

(|GotoItemIdx|) i64

Full Usage: (|GotoItemIdx|) i64

Parameters:
    i64 : uint64

Returns: int32 * int32
i64 : uint64
Returns: int32 * int32

(|KeyValue|) kvp

Full Usage: (|KeyValue|) kvp

Parameters:
Returns: 'a * 'b

An active pattern that should be in the F# standard library

kvp : KeyValuePair<'a, 'b>
Returns: 'a * 'b

(|PTerminal|PNonTerminal|) x

Full Usage: (|PTerminal|PNonTerminal|) x

Parameters:
    x : int

Returns: Choice<int, int>
x : int
Returns: Choice<int, int>

Type something to start searching.