Commit d513db04 authored by POTTIER Francois's avatar POTTIER Francois

Moved the inspection API in a sub-module Inspection.

This guarantees the absence of name clashes.
parent 2135285b
......@@ -32,9 +32,8 @@ let height env =
let print_element e : string =
match e with
| I.Element (s, v, _, _) ->
let sy = Parser.symbol s in
let open Parser in
match sy with
let open Parser.Inspection in
match symbol s with
| T T_TIMES ->
"*"
| T T_RPAREN ->
......
......@@ -53,6 +53,13 @@ let entrytypescheme_incremental grammar symbol =
(* -------------------------------------------------------------------------- *)
(* The name of the sub-module that contains the inspection API. *)
let inspection =
"Inspection"
(* -------------------------------------------------------------------------- *)
(* The monolithic (traditional) API: the type [token], the exception [Error],
and the parser's entry points. *)
......@@ -106,20 +113,26 @@ let incremental_api grammar () =
let inspection_api grammar () =
TokenType.tokengadtdef grammar @
NonterminalType.nonterminalgadtdef grammar @
SymbolType.symbolgadtdef() @
IIComment "The inspection API." ::
IIModule (inspection, MTSigEnd (
TokenType.tokengadtdef grammar @
NonterminalType.nonterminalgadtdef grammar @
SymbolType.symbolgadtdef() @
IIComment "This function maps a state to its incoming symbol." ::
IIValDecls [
let ty =
arrow (TypApp (interpreter ^ ".lr1state", [ TypVar "a" ]))
(TypApp ("symbol", [ TypVar "a" ]))
in
(* TEMPORARY code sharing with tableBackend *)
"symbol", type2scheme ty
] ::
(* TEMPORARY emit a comment *)
IIValDecls [
let ty =
arrow (TypApp (interpreter ^ ".lr1state", [ TypVar "a" ]))
(TypApp ("symbol", [ TypVar "a" ]))
in
(* TEMPORARY code sharing with tableBackend *)
"symbol", type2scheme ty
] ::
[]
)) ::
[]
(* -------------------------------------------------------------------------- *)
......
......@@ -23,6 +23,10 @@ val result: IL.typ -> IL.typ
val incremental: string
(* The name of the sub-module that contains the inspection API. *)
val inspection: string
(* This writes the interface of the generated parser to the [.mli] file. *)
val write: UnparameterizedSyntax.grammar -> unit -> unit
......
......@@ -876,19 +876,21 @@ let program =
SIValDefs (false, incremental_api)
]) ::
listiflazy Settings.inspection (fun () ->
listiflazy Settings.inspection (fun () -> [
SIModuleDef (inspection, MStruct (
interface_to_structure (
tokengadtdef grammar @
nonterminalgadtdef grammar @
symbolgadtdef()
) @
interface_to_structure (
tokengadtdef grammar @
nonterminalgadtdef grammar @
symbolgadtdef()
) @
SIValDefs (false, [incoming_symbol_def]) ::
SIValDefs (false, [incoming_symbol_def]) ::
[]
[]
) @
))
]) @
SIStretch grammar.postludes ::
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment