diff options
author | Michel Mauny <Michel.Mauny@ensta.fr> | 2003-07-15 09:14:00 +0000 |
---|---|---|
committer | Michel Mauny <Michel.Mauny@ensta.fr> | 2003-07-15 09:14:00 +0000 |
commit | 39ce1603c9d1976bafcd64afd31bff266c757280 (patch) | |
tree | 6eee69a1261e9a9972baa0982253c20bf348da67 /camlp4/ocaml_src/lib/plexer.ml | |
parent | 6973c396da152ad7a16ff97de9ea2b5ac4e5be57 (diff) |
Added Ints{32,64,native} and fixed an opt.opt install bug
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5693 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'camlp4/ocaml_src/lib/plexer.ml')
-rw-r--r-- | camlp4/ocaml_src/lib/plexer.ml | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/camlp4/ocaml_src/lib/plexer.ml b/camlp4/ocaml_src/lib/plexer.ml index 20471597e..acbd988e5 100644 --- a/camlp4/ocaml_src/lib/plexer.ml +++ b/camlp4/ocaml_src/lib/plexer.ml @@ -10,29 +10,27 @@ (* *) (***********************************************************************) -(* This file has been generated by program: do not edit! *) +(* $Id$ *) -open Stdpp;; -open Token;; +open Stdpp +open Token -let no_quotations = ref false;; +let no_quotations = ref false (* The string buffering machinery *) -let buff = ref (String.create 80);; +let buff = ref (String.create 80) let store len x = if len >= String.length !buff then buff := !buff ^ String.create (String.length !buff); !buff.[len] <- x; succ len -;; let mstore len s = let rec add_rec len i = if i == String.length s then len else add_rec (store len s.[i]) (succ i) in add_rec len 0 -;; -let get_buff len = String.sub !buff 0 len;; +let get_buff len = String.sub !buff 0 len (* The lexer *) @@ -44,7 +42,6 @@ let stream_peek_nth n strm = | _ :: l -> loop (n - 1) l in loop n (Stream.npeek n strm) -;; let rec ident len (strm__ : _ Stream.t) = match Stream.peek strm__ with @@ -112,6 +109,9 @@ and number len (strm__ : _ Stream.t) = | Some '.' -> Stream.junk strm__; decimal_part (store len '.') strm__ | Some ('e' | 'E') -> Stream.junk strm__; exponent_part (store len 'E') strm__ + | Some 'l' -> Stream.junk strm__; "INT32", get_buff len + | Some 'L' -> Stream.junk strm__; "INT64", get_buff len + | Some 'n' -> Stream.junk strm__; "NATIVEINT", get_buff len | _ -> "INT", get_buff len and decimal_part len (strm__ : _ Stream.t) = match Stream.peek strm__ with @@ -137,10 +137,9 @@ and end_exponent_part_under len (strm__ : _ Stream.t) = Stream.junk strm__; end_exponent_part_under (store len c) strm__ | Some '_' -> Stream.junk strm__; end_exponent_part_under len strm__ | _ -> "FLOAT", get_buff len -;; -let error_on_unknown_keywords = ref false;; -let err loc msg = raise_with_loc loc (Token.Error msg);; +let error_on_unknown_keywords = ref false +let err loc msg = raise_with_loc loc (Token.Error msg) (* value next_token_fun dfa find_kwd = @@ -955,11 +954,10 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = r with Stream.Error str -> err (Stream.count cstrm, Stream.count cstrm + 1) str -;; -let dollar_for_antiquotation = ref true;; -let specific_space_dot = ref false;; +let dollar_for_antiquotation = ref true +let specific_space_dot = ref false let func kwd_table glexr = let bolpos = ref 0 in @@ -967,7 +965,6 @@ let func kwd_table glexr = let dfa = !dollar_for_antiquotation in let ssd = !specific_space_dot in Token.lexer_func_of_parser (next_token_fun dfa ssd find bolpos glexr) -;; let rec check_keyword_stream (strm__ : _ Stream.t) = let _ = check strm__ in @@ -1053,12 +1050,10 @@ and check_ident2 (strm__ : _ Stream.t) = '.' | ':' | '<' | '>' | '|') -> Stream.junk strm__; check_ident2 strm__ | _ -> () -;; let check_keyword s = try check_keyword_stream (Stream.of_string s) with _ -> false -;; let error_no_respect_rules p_con p_prm = raise @@ -1068,14 +1063,12 @@ let error_no_respect_rules p_con p_prm = else if p_prm = "" then p_con else p_con ^ " \"" ^ p_prm ^ "\"") ^ " does not respect Plexer rules")) -;; let error_ident_and_keyword p_con p_prm = raise (Token.Error ("the token \"" ^ p_prm ^ "\" is used as " ^ p_con ^ " and as keyword")) -;; let using_token kwd_table ident_table (p_con, p_prm) = match p_con with @@ -1106,14 +1099,14 @@ let using_token kwd_table ident_table (p_con, p_prm) = error_ident_and_keyword p_con p_prm else Hashtbl.add ident_table p_prm p_con end - | "TILDEIDENT" | "QUESTIONIDENT" | "INT" | "FLOAT" | "CHAR" | "STRING" | - "QUOTATION" | "ANTIQUOT" | "LOCATE" | "EOI" -> + | "TILDEIDENT" | "QUESTIONIDENT" | "INT" | "INT32" | "INT64" | + "NATIVEINT" | "FLOAT" | "CHAR" | "STRING" | "QUOTATION" | "ANTIQUOT" | + "LOCATE" | "EOI" -> () | _ -> raise (Token.Error ("the constructor \"" ^ p_con ^ "\" is not recognized by Plexer")) -;; let removing_token kwd_table ident_table (p_con, p_prm) = match p_con with @@ -1121,7 +1114,6 @@ let removing_token kwd_table ident_table (p_con, p_prm) = | "LIDENT" | "UIDENT" -> if p_prm <> "" then Hashtbl.remove ident_table p_prm | _ -> () -;; let text = function @@ -1131,7 +1123,10 @@ let text = | "UIDENT", "" -> "uppercase identifier" | "UIDENT", t -> "'" ^ t ^ "'" | "INT", "" -> "integer" - | "INT", s -> "'" ^ s ^ "'" + | "INT32", "" -> "32 bits integer" + | "INT64", "" -> "64 bits integer" + | "NATIVEINT", "" -> "native integer" + | ("INT" | "INT32" | "NATIVEINT"), s -> "'" ^ s ^ "'" | "FLOAT", "" -> "float" | "STRING", "" -> "string" | "CHAR", "" -> "char" @@ -1141,7 +1136,6 @@ let text = | "EOI", "" -> "end of input" | con, "" -> con | con, prm -> con ^ " \"" ^ prm ^ "\"" -;; let eq_before_colon p e = let rec loop i = @@ -1152,7 +1146,6 @@ let eq_before_colon p e = else false in loop 0 -;; let after_colon e = try @@ -1160,7 +1153,6 @@ let after_colon e = String.sub e (i + 1) (String.length e - i - 1) with Not_found -> "" -;; let tok_match = function @@ -1170,18 +1162,22 @@ let tok_match = | _ -> raise Stream.Failure end | tok -> Token.default_match tok -;; let gmake () = let kwd_table = Hashtbl.create 301 in let id_table = Hashtbl.create 301 in let glexr = ref - {tok_func = (fun _ -> raise (Match_failure ("plexer.ml", 952, 17))); - tok_using = (fun _ -> raise (Match_failure ("plexer.ml", 952, 37))); - tok_removing = (fun _ -> raise (Match_failure ("plexer.ml", 952, 60))); - tok_match = (fun _ -> raise (Match_failure ("plexer.ml", 953, 18))); - tok_text = (fun _ -> raise (Match_failure ("plexer.ml", 953, 37))); + {tok_func = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 959, 17))); + tok_using = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 959, 37))); + tok_removing = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 959, 60))); + tok_match = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 960, 18))); + tok_text = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 960, 37))); tok_comm = None} in let glex = @@ -1191,7 +1187,6 @@ let gmake () = tok_text = text; tok_comm = None} in glexr := glex; glex -;; let tparse = function @@ -1204,20 +1199,23 @@ let tparse = in Some p | _ -> None -;; let make () = let kwd_table = Hashtbl.create 301 in let id_table = Hashtbl.create 301 in let glexr = ref - {tok_func = (fun _ -> raise (Match_failure ("plexer.ml", 981, 17))); - tok_using = (fun _ -> raise (Match_failure ("plexer.ml", 981, 37))); - tok_removing = (fun _ -> raise (Match_failure ("plexer.ml", 981, 60))); - tok_match = (fun _ -> raise (Match_failure ("plexer.ml", 982, 18))); - tok_text = (fun _ -> raise (Match_failure ("plexer.ml", 982, 37))); + {tok_func = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 988, 17))); + tok_using = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 988, 37))); + tok_removing = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 988, 60))); + tok_match = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 989, 18))); + tok_text = + (fun _ -> raise (Match_failure ("../../lib/plexer.ml", 989, 37))); tok_comm = None} in {func = func kwd_table glexr; using = using_token kwd_table id_table; removing = removing_token kwd_table id_table; tparse = tparse; text = text} -;; |