Kernel.SpecSourceSpecification interface
This module exports the data structures that represent the user's error specification after parsing and resolution.
Type definitions:
shortest: Is the clause in a %shortest groupnew_group: Is the clause the first of the group? If true, it starts a new priority group.definitions: The clause definition for each clausecaptures: The captured variables for each clauseclause, pattern, expr: Branch properties. Pattern is the abstract syntax of the pattern being recognized, while expr is a lower-level representation of the pattern as a regular expression.of_clause: Mapping from clauses to their brancheslookaheads: Optional lookahead constraints per branchbr_captures: Captured variables per branchis_total, is_partial: Whether branches are total/partialpriority: Priorities determine which branch should match when multiple branches succeed. Text order is used most of the time (first branch matches first), except for a %shortest group, in which case the branch that matches the first has the priority.Main functions:
branch_count: Return the number of branchesimport_rule: Compile a Syntax.rule into the internal specificationImplementation details:
is_total / is_partial distinction matters for coverage analysis: partial clauses only accept specific lookaheads, total clauses accept any lookahead.import_rule function handles various clause types:TODO: "Unreachable" clauses are not implemented at the moment.
type ('g, 'r) clauses = {definitions : (('g, 'r) clause, clause_def) Fix.Indexing.vector;captures : (('g, 'r) clause,
(Regexp.Capture.n, Syntax.capture_kind * string)
Utils.Misc.indexmap)
Fix.Indexing.vector;}type ('g, 'r) branches = {clause : (('g, 'r) branch, ('g, 'r) clause Fix.Indexing.index)
Fix.Indexing.vector;pattern : (('g, 'r) branch, Syntax.pattern) Fix.Indexing.vector;expr : (('g, 'r) branch, 'g Regexp.Expr.t) Fix.Indexing.vector;of_clause : (('g, 'r) clause, ('g, 'r) branch Utils.Misc.indexset)
Fix.Indexing.vector;lookaheads : (('g, 'r) branch, 'g Info.terminal Utils.Misc.indexset option)
Fix.Indexing.vector;br_captures : (('g, 'r) branch, Regexp.Capture.n Utils.Misc.indexset)
Fix.Indexing.vector;is_total : ('g, 'r) branch Utils.Boolvector.t;is_partial : ('g, 'r) branch Utils.Boolvector.t;priority : (('g, 'r) branch,
('g, 'r) branch Fix.Indexing.opt Fix.Indexing.index)
Fix.Indexing.vector;}val import_rule :
'g Info.grammar ->
'g Redgraph.graph ->
'g Transl.Indices.t ->
'g Redgraph.target_trie ->
Syntax.rule ->
'g _rule