aboutsummaryrefslogtreecommitdiff
path: root/toplevel
diff options
context:
space:
mode:
authorletouzey2010-05-19 15:29:44 +0000
committerletouzey2010-05-19 15:29:44 +0000
commit259dde7928696593c2d3c6de474f5cf50fa4417d (patch)
tree7fe225a0731c13b30cb10ae7098e096f38903366 /toplevel
parente1feff1215562d8f99fedf73c87011e6d7edca19 (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')
-rw-r--r--toplevel/metasyntax.ml15
-rw-r--r--toplevel/toplevel.ml4
2 files changed, 10 insertions, 9 deletions
diff --git a/toplevel/metasyntax.ml b/toplevel/metasyntax.ml
index 65aac9769a..b990781069 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
diff --git a/toplevel/toplevel.ml b/toplevel/toplevel.ml
index 4535522734..b9d643540c 100644
--- a/toplevel/toplevel.ml
+++ b/toplevel/toplevel.ml
@@ -315,8 +315,8 @@ let print_toplevel_error exc =
(* Read the input stream until a dot is encountered *)
let parse_to_dot =
let rec dot st = match Stream.next st with
- | ("", ".") -> ()
- | ("EOI", "") -> raise End_of_input
+ | Tok.KEYWORD "." -> ()
+ | Tok.EOI -> raise End_of_input
| _ -> dot st
in
Gram.Entry.of_parser "Coqtoplevel.dot" dot