Module Kernel.CodegenSource

Code generation for the LR matching machine

This module generates the OCaml code for the LR matching machine from the compiled specification and the generated automaton. The "machine" is translated to a sparse transition table, a bytecode program. An OCaml wrapper is generated to interpret the bytecode and invoke the appropriate semantic actions.

Main components:

Implementation details:

Sourcetype priority = int
Sourcetype spec = {
  1. parser_name : string;
  2. lexer_definition : Syntax.lexer_definition;
}
Sourceval print_literal_code : Utils.Code_printer.t -> (Stdlib.Lexing.position * string) -> unit
Sourceval output_table : Utils.Code_printer.t -> Syntax.rule -> ('g, 'r, 'a, 'b) Automata.Machine.t -> (string * Lrgrep_support_packer.table * int array) -> unit
Sourceval output_wrapper : Utils.Code_printer.t -> Syntax.rule -> unit
Sourcetype printer = Utils.Code_printer.t option -> unit
Sourceval grammar_parameters : 'a Info.grammar -> string list
Sourceval output_header : 'g Info.grammar -> spec -> printer
Sourceval output_trailer : 'g Info.grammar -> spec -> printer
Sourceval output_rule : 'g Info.grammar -> spec -> Syntax.rule -> ('g, 'r) Spec.clauses -> ('g, 'r) Spec.branches -> ('g, 'r, 'a, 'b) Automata.Machine.t -> printer