SyntaxSourceThis module defines the shallow abstract syntax for an error specification file (.lrgrep). It includes types for representing locations, symbols, regular expressions, semantic actions, and the overall structure of a lexer definition.
Kind of quantifier used in regular expressions.
This represents a piece of OCaml code, as appearing in semantic actions, as well as in the header and trailer.
type symbol = | Name of stringSymbols are usually simple names, like 'a' or 'X'.
*)| Apply of string * symbol listMenhir supports higher-order non-terminals. In this case, a symbol is the application of the higher-order non-terminal to some arguments. E.g separated_list(sep, X) is represented as: Apply ("separated_list", [Name "sep"; Name "X"])
A grammar symbol (a terminal or a non-terminal)
Symbols used in filter globbing expressions to specify matching criteria.
regular_desc describes the different cases of the regular expression syntax.
type regular_desc = | Atom of string option * wild_symbol * Utils.Usage.markAtom (capture, sym,_) represents the base cases (symbol and _).
| Alternative of regular_expr listA disjunction of multiple expressions. e1 | e2 | e3 is represented as Alternative [e1; e2; e3]
| Repetition of {expr : regular_expr;policy : quantifier_kind;}Repetition e represents e* and e**
| Reduce of {capture : string option;mark : Utils.Usage.mark;expr : regular_expr;policy : quantifier_kind;}Reduce {expr; _} represents [expr] and [[expr]].
| Concat of regular_expr listConcat [e1; e2; ..] is e1; e2; ...
| Filter of filterFilter f represents /foo: bar...
and regular_expr = {desc : regular_desc;position : position;the position where this term ends
*)}regular_expr adds position information to regular_desc for error reporting purposes.
type clause_action = | Total of ocaml_code... code , normal semantic action *
| Partial of ocaml_code... partial ... , a semantic action that can return None to continue matching
| Unreachable of position... { . } the pattern should never match
The semantic action associated to a pattern
type pattern = {expr : regular_expr;the pattern
*)lookaheads : (symbol * position) list;restrict matching to these lookahead terminals, or for all terminals
*)}A pattern is a combination of a regular expression and an optional list of lookahead constraints.
A clause is a pair of a pattern and an action, representing one rule.
type rule = {name : string;Name of the rule
*)error : bool * position;error is true if this entry only matches failing stacks. Syntactically, an error entry has the form: rule x ... = parse error | ...
startsymbols : (string * position) list;The list of entrypoints to support, or for all entrypoints.
*)args : string list;The list of OCaml arguments to abstract over, e.g the x y in rule foo x y = ...
clauses : clause_group list;The list of clauses to match
*)}A rule in .lrgrep file is represented by the rule type.
An .lrgrep file is an header containing some OCaml code, one or more entries, and a trailer with some other OCaml code.
Convert a location to a Cmon record.
Convert an OCaml code to a Cmon tuple.
Convert a function and a position to a Cmon pair.
Convert an option to a Cmon value.
Convert a capture to a Cmon value.
Convert a filter symbol to a Cmon value.
Convert a regular expression to a Cmon value.
Convert a clause action to a Cmon value.
Convert a lexer definition to a Cmon value.
The role of a captured value in a regular expression: captures only the start or end location, captures the value (and its location)
Print position for error or warning messages
val warn :
Stdlib.Lexing.position ->
('a, Stdlib.out_channel, unit, unit) Stdlib.format4 ->
'aReport a warning
Report an error
val nonfatal_error :
Stdlib.Lexing.position ->
('a, Stdlib.out_channel, unit, unit) Stdlib.format4 ->
'a