4 Known problems: 1s gets parsed as (Int 1) + (Symbol s). We should probably introduce a rule for invalid numbers that throws an error.
\r
12 let incr_linenum lexbuf =
\r
13 let pos = lexbuf.Lexing.lex_curr_p in
\r
14 lexbuf.Lexing.lex_curr_p <- { pos with
\r
15 Lexing.pos_lnum = pos.Lexing.pos_lnum + 1;
\r
16 Lexing.pos_bol = pos.Lexing.pos_cnum;
\r
19 let make_string x = STRING (String.sub x 1 ((String.length x) - 2));;
\r
23 let newline = ['\n']
\r
24 let spaces = ['\r' '\t' ' ']
\r
25 let letter = ['a'-'z' 'A'-'Z']
\r
26 let digit = ['0'-'9']
\r
27 let arith_ops = ['*' '/' '+' '-' '=']
\r
28 let punctuation = ['!' '#' '$' '%' '&' '|' '*'
\r
29 '+' '-' '/' ':' '<' '=' '>' '?'
\r
30 '@' '^' '_' '~' '\"']
\r
32 let delimiter = "\n\r"|['[' ']' '(' ')' '"' ';' '#' '\r' '\n' '\t' ' ']
\r
34 let symbol = letter+ (digit|punctuation|letter)*
\r
35 let scheme_string = '"' (('\\' _ )|[^ '"'])* '"'
\r
40 incr_linenum lexbuf;
\r
43 | scheme_string as s { make_string s }
\r
44 | spaces+ { token lexbuf }
\r
47 INT (int_of_string inum)
\r
49 | arith_ops as op { SYMBOL (Char.escaped op) }
\r
50 | symbol as s { SYMBOL s }
\r
51 | ';' [^ '\n']* { token lexbuf } (* eat up one-line comments *)
\r