aboutsummaryrefslogtreecommitdiffhomepage
path: root/parsing
diff options
context:
space:
mode:
Diffstat (limited to 'parsing')
-rw-r--r--parsing/lexer.mli7
-rw-r--r--parsing/lexer.mll14
2 files changed, 13 insertions, 8 deletions
diff --git a/parsing/lexer.mli b/parsing/lexer.mli
index 982e29436..721afa2d1 100644
--- a/parsing/lexer.mli
+++ b/parsing/lexer.mli
@@ -1,7 +1,12 @@
(* $Id$ *)
-exception BadToken of string
+type error =
+ | Illegal_character
+ | Unterminated_comment
+ | Unterminated_string
+
+exception Error of error
val add_keyword : string -> unit
val is_keyword : string -> bool
diff --git a/parsing/lexer.mll b/parsing/lexer.mll
index 680835499..410bcc4fa 100644
--- a/parsing/lexer.mll
+++ b/parsing/lexer.mll
@@ -9,9 +9,7 @@ type error =
| Unterminated_comment
| Unterminated_string
-exception BadToken of string
-
-exception Error of error * int * int
+exception Error of error
(* token trees *)
@@ -157,6 +155,8 @@ rule token = parse
token lexbuf }
| eof
{ ("EOI","") }
+ | _ { let loc = (Lexing.lexeme_start lexbuf, Lexing.lexeme_end lexbuf) in
+ raise (Stdpp.Exc_located (loc, Error Illegal_character)) }
and comment = parse
| "(*"
@@ -178,8 +178,8 @@ and comment = parse
| "'\\" ['0'-'9'] ['0'-'9'] ['0'-'9'] "'"
{ comment lexbuf }
| eof
- { raise (Error (Unterminated_comment,
- !comment_start_pos, !comment_start_pos+2)) }
+ { let loc = (!comment_start_pos, !comment_start_pos+2) in
+ raise (Stdpp.Exc_located (loc, Error Unterminated_comment)) }
| _
{ comment lexbuf }
@@ -196,8 +196,8 @@ and string = parse
{ Buffer.add_char string_buffer (char_for_decimal_code lexbuf 1);
string lexbuf }
| eof
- { raise (Error (Unterminated_string,
- !string_start_pos, !string_start_pos+1)) }
+ { let loc = (!string_start_pos, !string_start_pos+1) in
+ raise (Stdpp.Exc_located (loc, Error Unterminated_string)) }
| _
{ Buffer.add_char string_buffer (Lexing.lexeme_char lexbuf 0);
string lexbuf }