Commit b67d60a3 authored by POTTIER Francois's avatar POTTIER Francois

Added [ocamltype_of_start_symbol].

parent ea451d48
...@@ -127,6 +127,14 @@ module Nonterminal = struct ...@@ -127,6 +127,14 @@ module Nonterminal = struct
with Not_found -> with Not_found ->
None None
let ocamltype_of_start_symbol nt =
match ocamltype nt with
| Some typ ->
typ
| None ->
(* Every start symbol has a type. *)
assert false
let tabulate f = let tabulate f =
Array.get (Array.init n f) Array.get (Array.init n f)
......
...@@ -46,6 +46,11 @@ module Nonterminal : sig ...@@ -46,6 +46,11 @@ module Nonterminal : sig
val ocamltype: t -> Stretch.ocamltype option val ocamltype: t -> Stretch.ocamltype option
(* A start symbol always has a type. This allows us to define
a simplified version of [ocamltype] for start symbols. *)
val ocamltype_of_start_symbol: t -> Stretch.ocamltype
(* Iteration over nonterminals. The order in which elements are (* Iteration over nonterminals. The order in which elements are
examined, and the order of [map]'s output list, correspond to the examined, and the order of [map]'s output list, correspond to the
numeric indices produced by [n2i] above. *) numeric indices produced by [n2i] above. *)
......
...@@ -1102,11 +1102,7 @@ let fold_entry f accu = ...@@ -1102,11 +1102,7 @@ let fold_entry f accu =
assert false (* this is a start production *) assert false (* this is a start production *)
in in
let t : Stretch.ocamltype = let t : Stretch.ocamltype =
match Nonterminal.ocamltype nt with Nonterminal.ocamltype_of_start_symbol nt
| Some t ->
t
| None ->
assert false (* every start symbol should carry a type *)
in in
f prod state nt t accu f prod state nt t accu
) entry accu ) entry accu
......
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