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 (***********************************************************************)
15 (* The lexical analyzer for lexer definitions. *)
24 _ * "qwertyuiopasdfghjklzxcvbnm0123456789!@#$%^&*()"
26 | [' ' '\010' '\013' '\009' ] +
32 | (['A'-'Z' 'a'-'z'] | '_' ['A'-'Z' 'a'-'z' '\'' '0'-'9'])
33 ( '_' ? ['A'-'Z' 'a'-'z' ''' '0'-'9'] ) *
34 { match lexing.lexeme lexbuf with
41 { reset_string_buffer();
43 Tstring(get_stored_string()) }
45 { Tchar(char lexbuf) }
47 { let n1 = lexing.lexeme_end lexbuf in
49 let n2 = action lexbuf in
50 Taction(Location(n1, n2)) }
66 { raise(Lexical_error "unterminated lexer definition") }
68 { raise(Lexical_error("illegal character " ^ lexing.lexeme lexbuf)) }
72 { brace_depth := brace_depth + 1;
75 { brace_depth := brace_depth - 1;
76 if brace_depth = 0 then lexing.lexeme_start lexbuf else action lexbuf }
78 { reset_string_buffer();
80 reset_string_buffer();
83 { char lexbuf; action lexbuf }
89 { raise (Lexical_error "unterminated action") }
96 | '\\' [' ' '\010' '\013' '\009' '\026' '\012'] +
98 | '\\' ['\\' '"' 'n' 't' 'b' 'r']
99 { store_string_char(char_for_backslash(lexing.lexeme_char lexbuf 1));
101 | '\\' ['0'-'9'] ['0'-'9'] ['0'-'9']
102 { store_string_char(char_for_decimal_code lexbuf 1);
105 { raise(Lexical_error "unterminated string") }
107 { store_string_char(lexing.lexeme_char lexbuf 0);
112 { lexing.lexeme_char lexbuf 0 }
113 | '\\' ['\\' '\'' 'n' 't' 'b' 'r'] "'"
114 { char_for_backslash (lexing.lexeme_char lexbuf 1) }
115 | '\\' ['0'-'9'] ['0'-'9'] ['0'-'9'] "'"
116 { char_for_decimal_code lexbuf 1 }
118 { raise(Lexical_error "bad character constant") }
122 { comment_depth := comment_depth + 1; comment lexbuf }
124 { comment_depth := comment_depth - 1;
125 if comment_depth = 0 then () else comment lexbuf }
127 { reset_string_buffer();
129 reset_string_buffer();
132 { raise(Lexical_error "unterminated comment") }