1
(***********************************************************************)
5
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7
(* Copyright 1996 Institut National de Recherche en Informatique et *)
8
(* en Automatique. All rights reserved. This file is distributed *)
9
(* under the terms of the Q Public License version 1.0. *)
11
(***********************************************************************)
13
(* $Id: scanner.mll,v 1.5 1999/11/17 18:58:39 xleroy Exp $ *)
15
(* The lexical analyzer for lexer definitions. *)
24
[' ' '\010' '\013' '\009' ] +
30
| (['A'-'Z' 'a'-'z'] | '_' ['A'-'Z' 'a'-'z' '\'' '0'-'9'])
31
( '_' ? ['A'-'Z' 'a'-'z' ''' '0'-'9'] ) *
32
{ match Lexing.lexeme lexbuf with
39
{ reset_string_buffer();
41
Tstring(get_stored_string()) }
43
{ Tchar(char lexbuf) }
45
{ let n1 = Lexing.lexeme_end lexbuf in
47
let n2 = action lexbuf in
48
Taction(Location(n1, n2)) }
64
{ raise(Lexical_error "unterminated lexer definition") }
66
{ raise(Lexical_error("illegal character " ^ Lexing.lexeme lexbuf)) }
74
if !brace_depth = 0 then Lexing.lexeme_start lexbuf else action lexbuf }
76
{ reset_string_buffer();
78
reset_string_buffer();
81
{ let _ = char lexbuf in action lexbuf }
87
{ raise (Lexical_error "unterminated action") }
94
| '\\' [' ' '\010' '\013' '\009' '\026' '\012'] +
96
| '\\' ['\\' '"' 'n' 't' 'b' 'r']
97
{ store_string_char(char_for_backslash(Lexing.lexeme_char lexbuf 1));
99
| '\\' ['0'-'9'] ['0'-'9'] ['0'-'9']
100
{ store_string_char(char_for_decimal_code lexbuf 1);
103
{ raise(Lexical_error "unterminated string") }
105
{ store_string_char(Lexing.lexeme_char lexbuf 0);
110
{ Lexing.lexeme_char lexbuf 0 }
111
| '\\' ['\\' '\'' 'n' 't' 'b' 'r'] "'"
112
{ char_for_backslash (Lexing.lexeme_char lexbuf 1) }
113
| '\\' ['0'-'9'] ['0'-'9'] ['0'-'9'] "'"
114
{ char_for_decimal_code lexbuf 1 }
116
{ raise(Lexical_error "bad character constant") }
120
{ incr comment_depth; comment lexbuf }
122
{ decr comment_depth;
123
if !comment_depth = 0 then () else comment lexbuf }
125
{ reset_string_buffer();
127
reset_string_buffer();
130
{ raise(Lexical_error "unterminated comment") }