diff options
author | 2010-05-19 15:29:44 +0000 | |
---|---|---|
committer | 2010-05-19 15:29:44 +0000 | |
commit | 259dde7928696593c2d3c6de474f5cf50fa4417d (patch) | |
tree | 7fe225a0731c13b30cb10ae7098e096f38903366 /toplevel/metasyntax.ml | |
parent | e1feff1215562d8f99fedf73c87011e6d7edca19 (diff) |
Nicer representation of tokens, more independant of camlp*
Cf tok.ml, token isn't anymore string*string where first
string encodes the kind of the token, but rather a nice
sum type. Unfortunately, string*string (a.k.a Plexing.pattern)
is still used in some places of Camlp5, so there's a few
conversions back and forth. But the penalty should be quite low,
and having nicer tokens helps in the forthcoming integration
of support for camlp4 post 3.10
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@13018 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'toplevel/metasyntax.ml')
-rw-r--r-- | toplevel/metasyntax.ml | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/toplevel/metasyntax.ml b/toplevel/metasyntax.ml index 65aac9769..b99078106 100644 --- a/toplevel/metasyntax.ml +++ b/toplevel/metasyntax.ml @@ -20,6 +20,7 @@ open Vernacexpr open Pcoq open Rawterm open Libnames +open Tok open Lexer open Egrammar open Notation @@ -28,7 +29,7 @@ open Nameops (**********************************************************************) (* Tokens *) -let cache_token (_,s) = add_token ("", s) +let cache_token (_,s) = add_keyword s let (inToken, outToken) = declare_object {(default_object "TOKEN") with @@ -581,20 +582,20 @@ let is_not_small_constr = function | _ -> false let rec define_keywords_aux = function - | GramConstrNonTerminal(e,Some _) as n1 :: GramConstrTerminal("IDENT",k) :: l + | GramConstrNonTerminal(e,Some _) as n1 :: GramConstrTerminal(IDENT k) :: l when is_not_small_constr e -> message ("Defining '"^k^"' as keyword"); - Lexer.add_token("",k); - n1 :: GramConstrTerminal("",k) :: define_keywords_aux l + Lexer.add_keyword k; + n1 :: GramConstrTerminal(KEYWORD k) :: define_keywords_aux l | n :: l -> n :: define_keywords_aux l | [] -> [] (* Ensure that IDENT articulation terminal symbols are keywords *) let define_keywords = function - | GramConstrTerminal("IDENT",k)::l -> + | GramConstrTerminal(IDENT k)::l -> message ("Defining '"^k^"' as keyword"); - Lexer.add_token("",k); - GramConstrTerminal("",k) :: define_keywords_aux l + Lexer.add_keyword k; + GramConstrTerminal(KEYWORD k) :: define_keywords_aux l | l -> define_keywords_aux l let distribute a ll = List.map (fun l -> a @ l) ll |