From 1dac644da31bb25dd4e36360e5eb3febd0d5e158 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Sun, 4 Nov 2018 19:18:54 +0100 Subject: Remove the Sflag constructor from Gramlib. It is just a wrapper around Sopt. I do not really understand why it is hardwired in the entry AST. --- gramlib/gramext.ml | 8 +------- gramlib/gramext.mli | 1 - gramlib/grammar.ml | 15 ++------------- gramlib/grammar.mli | 1 - 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/gramlib/gramext.ml b/gramlib/gramext.ml index de9b1e864c..159070b2f2 100644 --- a/gramlib/gramext.ml +++ b/gramlib/gramext.ml @@ -34,7 +34,6 @@ and 'te g_symbol = | Slist1 of 'te g_symbol | Slist1sep of 'te g_symbol * 'te g_symbol * bool | Sopt of 'te g_symbol - | Sflag of 'te g_symbol | Sself | Snext | Scut @@ -63,7 +62,7 @@ let rec derive_eps = function Slist0 _ -> true | Slist0sep (_, _, _) -> true - | Sopt _ | Sflag _ -> true + | Sopt _ -> true | Stree t -> tree_derive_eps t | Slist1 _ | Slist1sep (_, _, _) | Snterm _ | Snterml (_, _) | Snext | Sself | Scut | Stoken _ -> @@ -85,7 +84,6 @@ let rec eq_symbol s1 s2 = | Slist1 s1, Slist1 s2 -> eq_symbol s1 s2 | Slist1sep (s1, sep1, b1), Slist1sep (s2, sep2, b2) -> eq_symbol s1 s2 && eq_symbol sep1 sep2 && b1 = b2 - | Sflag s1, Sflag s2 -> eq_symbol s1 s2 | Sopt s1, Sopt s2 -> eq_symbol s1 s2 | Stree _, Stree _ -> false | _ -> s1 = s2 @@ -179,7 +177,6 @@ and token_exists_in_symbol f = | Slist1sep (sy, sep, _) -> token_exists_in_symbol f sy || token_exists_in_symbol f sep | Sopt sy -> token_exists_in_symbol f sy - | Sflag sy -> token_exists_in_symbol f sy | Stoken tok -> f tok | Stree t -> token_exists_in_tree f t | Snterm _ | Snterml (_, _) | Snext | Sself | Scut -> false @@ -312,7 +309,6 @@ Error: entries \"%s\" and \"%s\" do not belong to the same grammar.\n" | Slist0 s -> check_gram entry s | Slist1 s -> check_gram entry s | Sopt s -> check_gram entry s - | Sflag s -> check_gram entry s | Stree t -> tree_check_gram entry t | Snext | Sself | Scut | Stoken _ -> () and tree_check_gram entry = @@ -339,7 +335,6 @@ let insert_tokens gram symbols = | Slist0sep (s, t, _) -> insert s; insert t | Slist1sep (s, t, _) -> insert s; insert t | Sopt s -> insert s - | Sflag s -> insert s | Stree t -> tinsert t | Stoken ("ANY", _) -> () | Stoken tok -> @@ -472,7 +467,6 @@ let rec decr_keyw_use gram = | Slist0sep (s1, s2, _) -> decr_keyw_use gram s1; decr_keyw_use gram s2 | Slist1sep (s1, s2, _) -> decr_keyw_use gram s1; decr_keyw_use gram s2 | Sopt s -> decr_keyw_use gram s - | Sflag s -> decr_keyw_use gram s | Stree t -> decr_keyw_use_in_tree gram t | Sself | Snext | Scut | Snterm _ | Snterml (_, _) -> () and decr_keyw_use_in_tree gram = diff --git a/gramlib/gramext.mli b/gramlib/gramext.mli index ff59bae578..03b0c77bbe 100644 --- a/gramlib/gramext.mli +++ b/gramlib/gramext.mli @@ -32,7 +32,6 @@ and 'te g_symbol = | Slist1 of 'te g_symbol | Slist1sep of 'te g_symbol * 'te g_symbol * bool | Sopt of 'te g_symbol - | Sflag of 'te g_symbol | Sself | Snext | Scut diff --git a/gramlib/grammar.ml b/gramlib/grammar.ml index 6e99861423..0cf8eb5bbb 100644 --- a/gramlib/grammar.ml +++ b/gramlib/grammar.ml @@ -50,7 +50,6 @@ let rec print_symbol ppf = fprintf ppf "LIST1 %a SEP %a%s" print_symbol1 s print_symbol1 t (if osep then " OPT_SEP" else "") | Sopt s -> fprintf ppf "OPT %a" print_symbol1 s - | Sflag s -> fprintf ppf "FLAG %a" print_symbol1 s | Stoken (con, prm) when con <> "" && prm <> "" -> fprintf ppf "%s@ %a" con print_str prm | Snterml (e, l) -> @@ -68,7 +67,7 @@ and print_symbol1 ppf = | Stoken (con, "") -> pp_print_string ppf con | Stree t -> print_level ppf pp_print_space (flatten_tree t) | Snterml (_, _) | Slist0 _ | Slist0sep (_, _, _) | - Slist1 _ | Slist1sep (_, _, _) | Sopt _ | Sflag _ | Stoken _ as s -> + Slist1 _ | Slist1sep (_, _, _) | Sopt _ | Stoken _ as s -> fprintf ppf "(%a)" print_symbol s and print_rule ppf symbols = fprintf ppf "@["; @@ -153,7 +152,6 @@ let rec name_of_symbol_failed entry = | Slist1 s -> name_of_symbol_failed entry s | Slist1sep (s, _, _) -> name_of_symbol_failed entry s | Sopt s -> name_of_symbol_failed entry s - | Sflag s -> name_of_symbol_failed entry s | Stree t -> name_of_tree_failed entry t | s -> name_of_symbol entry s and name_of_tree_failed entry = @@ -293,7 +291,7 @@ let tree_failed entry prev_symb_result prev_symb tree = let txt1 = name_of_symbol_failed entry sep in txt1 ^ " or " ^ txt ^ " expected" end - | Sopt _ | Sflag _ | Stree _ -> txt ^ " expected" + | Sopt _ | Stree _ -> txt ^ " expected" | _ -> txt ^ " expected after " ^ name_of_symbol_failed entry prev_symb in if !error_verbose then @@ -641,12 +639,6 @@ and parser_of_symbol entry nlevn = match try Some (ps strm__) with Stream.Failure -> None with Some a -> Obj.repr (Some a) | _ -> Obj.repr None) - | Sflag s -> - let ps = parser_of_symbol entry nlevn s in - (fun (strm__ : _ Stream.t) -> - match try Some (ps strm__) with Stream.Failure -> None with - Some _ -> Obj.repr true - | _ -> Obj.repr false) | Stree t -> let pt = parser_of_tree entry 1 0 t in (fun (strm__ : _ Stream.t) -> @@ -876,7 +868,6 @@ let find_entry e s = | Slist1 s -> find_symbol s | Slist1sep (s, _, _) -> find_symbol s | Sopt s -> find_symbol s - | Sflag s -> find_symbol s | Stree t -> find_tree t | Sself | Snext | Scut | Stoken _ -> None and find_tree = @@ -997,7 +988,6 @@ module type S = ('self, 'a) ty_symbol -> ('self, 'b) ty_symbol -> bool -> ('self, 'a list) ty_symbol val s_opt : ('self, 'a) ty_symbol -> ('self, 'a option) ty_symbol - val s_flag : ('self, 'a) ty_symbol -> ('self, bool) ty_symbol val s_self : ('self, 'self) ty_symbol val s_next : ('self, 'self) ty_symbol val s_token : Plexing.pattern -> ('self, string) ty_symbol @@ -1082,7 +1072,6 @@ module GMake (L : GLexerType) = let s_list1 s = Slist1 s let s_list1sep s sep b = Slist1sep (s, sep, b) let s_opt s = Sopt s - let s_flag s = Sflag s let s_self = Sself let s_next = Snext let s_token tok = Stoken tok diff --git a/gramlib/grammar.mli b/gramlib/grammar.mli index e115b9df43..fe06d1fa81 100644 --- a/gramlib/grammar.mli +++ b/gramlib/grammar.mli @@ -123,7 +123,6 @@ module type S = ('self, 'a) ty_symbol -> ('self, 'b) ty_symbol -> bool -> ('self, 'a list) ty_symbol val s_opt : ('self, 'a) ty_symbol -> ('self, 'a option) ty_symbol - val s_flag : ('self, 'a) ty_symbol -> ('self, bool) ty_symbol val s_self : ('self, 'self) ty_symbol val s_next : ('self, 'self) ty_symbol val s_token : Plexing.pattern -> ('self, string) ty_symbol -- cgit v1.2.3