Commit 38a6e174 authored by POTTIER Francois's avatar POTTIER Francois

Moved a few functions to [UnparameterizedSyntax].

parent 6fb9250b
......@@ -40,6 +40,18 @@ let rec search (p : 'a -> bool) (i : int) (xs : 'a list) : (int * 'a) option =
(* -------------------------------------------------------------------------- *)
(* [find grammar symbol] looks up the definition of [symbol], which must be
a valid nonterminal symbol, in the grammar [grammar]. *)
let find grammar symbol : rule =
try
StringMap.find symbol grammar.rules
with Not_found ->
(* This cannot happen. *)
assert false
(* -------------------------------------------------------------------------- *)
(* [rename_sw_outer] transforms the keywords in the outer production (the
caller) during inlining. It replaces [$startpos(x)] and [$endpos(x)], where
[x] is the name of the callee, with [startpx] and [endpx], respectively. *)
......@@ -150,30 +162,6 @@ let rename (used : StringSet.t) producers: Action.subst * producers =
in
phi, List.rev producers'
(* [is_inline_nonterminal grammar symbol] tells whether [symbol] is a nonterminal
symbol (as opposed to a terminal symbol) and is marked %inline. *)
let is_inline_nonterminal grammar symbol : bool =
match StringMap.find symbol grammar.rules with
| rule ->
(* This is a nonterminal symbol. Test its %inline flag. *)
rule.inline_flag
| exception Not_found ->
(* This is a terminal symbol. *)
false
let is_inline_producer grammar producer =
is_inline_nonterminal grammar (producer_symbol producer)
(* [find grammar symbol] looks up the definition of [symbol], which must be
a valid nonterminal symbol. *)
let find grammar symbol : rule =
try
StringMap.find symbol grammar.rules
with Not_found ->
assert false
(* Inline the branch [callee] into the branch [caller] at the site
determined by [prefix, producer, suffix]. *)
......
......@@ -143,3 +143,21 @@ let ocamltype_of_start_symbol grammar symbol : Stretch.ocamltype =
with Not_found ->
(* Every start symbol should have a type. *)
assert false
(* [is_inline_symbol grammar symbol] tells whether [symbol] is a nonterminal
symbol (as opposed to a terminal symbol) and is marked %inline. *)
let is_inline_symbol grammar symbol : bool =
match StringMap.find symbol grammar.rules with
| rule ->
(* This is a nonterminal symbol. Test its %inline flag. *)
rule.inline_flag
| exception Not_found ->
(* This is a terminal symbol. *)
false
(* [is_inline_symbol grammar producer] tells whether [producer] represents a
nonterminal symbol (as opposed to a terminal) and is marked %inline. *)
let is_inline_producer grammar producer =
is_inline_symbol grammar (producer_symbol producer)
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