Commit 31583d6e authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-12-01 20:46:51 by cvscast] Empty log message

Original author: cvscast
Date: 2002-12-01 20:46:51+00:00
parent 0bd7b185
......@@ -104,43 +104,43 @@ let lex_tables = {
\005\000\254\255\014\000\013\000\003\000\005\000\253\255\255\255\
\247\255\246\255\020\000\047\000\051\000\018\000\043\000\250\255\
\027\000\017\000\005\000\050\000\011\000\044\000\040\000\249\255\
\250\255\248\255\064\000\066\000\057\000\071\000\081\000\086\000\
\101\000\090\000\119\000\062\000";
\250\255\248\255\064\000\067\000\071\000\080\000\057\000\084\000\
\100\000\104\000\114\000\118\000\124\000\062\000";
Lexing.lex_backtrk =
"\255\255\255\255\255\255\255\255\255\255\255\255\004\000\255\255\
\002\000\255\255\004\000\002\000\004\000\004\000\255\255\255\255\
\255\255\255\255\000\000\001\000\002\000\003\000\005\000\255\255\
\005\000\005\000\005\000\005\000\005\000\005\000\005\000\255\255\
\255\255\255\255\255\255\004\000\003\000\002\000\255\255\002\000\
\001\000\255\255\001\000\000\000";
\255\255\255\255\255\255\004\000\255\255\004\000\003\000\002\000\
\255\255\002\000\001\000\255\255\001\000\000\000";
Lexing.lex_default =
"\023\000\005\000\005\000\005\000\000\000\000\000\255\255\000\000\
\255\255\000\000\255\255\255\255\255\255\255\255\000\000\000\000\
\000\000\000\000\255\255\255\255\255\255\255\255\255\255\000\000\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\000\
\000\000\000\000\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255";
\255\255\255\255\255\255\255\255\255\255\255\255";
Lexing.lex_trans =
"\016\000\017\000\017\000\018\000\019\000\020\000\021\000\019\000\
\022\000\004\000\008\000\008\000\004\000\024\000\025\000\026\000\
\027\000\026\000\004\000\011\000\011\000\028\000\015\000\043\000\
\036\000\029\000\012\000\030\000\026\000\009\000\031\000\032\000\
\027\000\026\000\004\000\011\000\011\000\028\000\015\000\045\000\
\038\000\029\000\012\000\030\000\026\000\009\000\031\000\032\000\
\031\000\032\000\013\000\009\000\009\000\032\000\032\000\014\000\
\032\000\014\000\007\000\010\000\009\000\009\000\034\000\035\000\
\035\000\006\000\007\000\040\000\040\000\040\000\040\000\037\000\
\037\000\037\000\037\000\032\000\041\000\033\000\032\000\036\000\
\038\000\043\000\032\000\034\000\035\000\035\000\035\000\035\000\
\035\000\035\000\000\000\037\000\037\000\037\000\037\000\040\000\
\000\000\000\000\000\000\037\000\038\000\039\000\039\000\039\000\
\039\000\000\000\039\000\039\000\039\000\039\000\042\000\042\000\
\042\000\042\000\035\000\038\000\000\000\000\000\000\000\037\000\
\000\000\040\000\040\000\040\000\040\000\000\000\000\000\000\000\
\000\000\039\000\041\000\000\000\000\000\000\000\039\000\000\000\
\000\000\000\000\042\000\042\000\042\000\042\000\042\000\000\000\
\000\000\000\000\000\000\000\000\041\000\040\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\042\000\
\000\000";
\035\000\006\000\007\000\042\000\042\000\042\000\042\000\039\000\
\039\000\039\000\039\000\032\000\043\000\033\000\032\000\038\000\
\040\000\045\000\032\000\034\000\035\000\035\000\000\000\035\000\
\035\000\035\000\035\000\037\000\037\000\037\000\037\000\042\000\
\036\000\000\000\000\000\039\000\037\000\037\000\037\000\037\000\
\039\000\039\000\039\000\039\000\000\000\036\000\000\000\000\000\
\000\000\040\000\000\000\035\000\000\000\000\000\000\000\037\000\
\041\000\041\000\041\000\041\000\041\000\041\000\041\000\041\000\
\037\000\000\000\000\000\000\000\039\000\040\000\042\000\042\000\
\042\000\042\000\044\000\044\000\044\000\044\000\000\000\043\000\
\044\000\044\000\044\000\044\000\041\000\000\000\000\000\000\000\
\041\000\043\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\042\000\000\000\000\000\000\000\044\000\000\000\
\000\000\000\000\000\000\000\000\044\000\000\000";
Lexing.lex_check =
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\001\000\006\000\008\000\002\000\000\000\000\000\000\000\
......@@ -149,49 +149,49 @@ let lex_tables = {
\000\000\026\000\001\000\006\000\006\000\024\000\028\000\001\000\
\024\000\001\000\002\000\002\000\010\000\010\000\022\000\022\000\
\022\000\003\000\003\000\019\000\019\000\019\000\019\000\020\000\
\020\000\020\000\020\000\027\000\019\000\029\000\030\000\036\000\
\020\000\043\000\027\000\034\000\034\000\034\000\035\000\035\000\
\035\000\035\000\255\255\037\000\037\000\037\000\037\000\019\000\
\255\255\255\255\255\255\020\000\037\000\038\000\038\000\038\000\
\038\000\255\255\039\000\039\000\039\000\039\000\041\000\041\000\
\041\000\041\000\035\000\039\000\255\255\255\255\255\255\037\000\
\255\255\040\000\040\000\040\000\040\000\255\255\255\255\255\255\
\255\255\038\000\040\000\255\255\255\255\255\255\039\000\255\255\
\255\255\255\255\041\000\042\000\042\000\042\000\042\000\255\255\
\255\255\255\255\255\255\255\255\042\000\040\000\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\042\000\
\255\255"
\020\000\020\000\020\000\027\000\019\000\029\000\030\000\038\000\
\020\000\045\000\027\000\034\000\034\000\034\000\255\255\035\000\
\035\000\035\000\035\000\036\000\036\000\036\000\036\000\019\000\
\035\000\255\255\255\255\020\000\037\000\037\000\037\000\037\000\
\039\000\039\000\039\000\039\000\255\255\037\000\255\255\255\255\
\255\255\039\000\255\255\035\000\255\255\255\255\255\255\036\000\
\040\000\040\000\040\000\040\000\041\000\041\000\041\000\041\000\
\037\000\255\255\255\255\255\255\039\000\041\000\042\000\042\000\
\042\000\042\000\043\000\043\000\043\000\043\000\255\255\042\000\
\044\000\044\000\044\000\044\000\040\000\255\255\255\255\255\255\
\041\000\044\000\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\042\000\255\255\255\255\255\255\043\000\255\255\
\255\255\255\255\255\255\255\255\044\000\255\255"
}
let rec token engine lexbuf =
match engine lex_tables 0 lexbuf with
0 -> (
# 50 "parser/wlexer.mll"
# 51 "parser/wlexer.mll"
token engine lexbuf )
| 1 -> (
# 51 "parser/wlexer.mll"
# 52 "parser/wlexer.mll"
let s = Lexing.lexeme lexbuf in
if Hashtbl.mem keywords s then "",s else "LIDENT",s
)
| 2 -> (
# 55 "parser/wlexer.mll"
"UIDENT",Lexing.lexeme lexbuf )
| 3 -> (
# 56 "parser/wlexer.mll"
"UIDENT",Lexing.lexeme lexbuf )
| 3 -> (
# 57 "parser/wlexer.mll"
"INT",Lexing.lexeme lexbuf )
| 4 -> (
# 57 "parser/wlexer.mll"
# 58 "parser/wlexer.mll"
let s = Lexing.lexeme lexbuf in
"TAG", tag_of_tag s 1
)
| 5 -> (
# 65 "parser/wlexer.mll"
# 66 "parser/wlexer.mll"
"",Lexing.lexeme lexbuf )
| 6 -> (
# 68 "parser/wlexer.mll"
# 69 "parser/wlexer.mll"
let string_start = Lexing.lexeme_start lexbuf in
string_start_pos := string_start;
let double_quote = Lexing.lexeme_char lexbuf 0 = '"' in
......@@ -201,15 +201,15 @@ let rec token engine lexbuf =
(if double_quote then "STRING2" else "STRING1"),
(get_stored_string()) )
| 7 -> (
# 78 "parser/wlexer.mll"
# 79 "parser/wlexer.mll"
comment_start_pos := [Lexing.lexeme_start lexbuf];
comment engine lexbuf;
token engine lexbuf )
| 8 -> (
# 83 "parser/wlexer.mll"
# 84 "parser/wlexer.mll"
"EOI","" )
| 9 -> (
# 85 "parser/wlexer.mll"
# 86 "parser/wlexer.mll"
error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf)
(Illegal_character ((Lexing.lexeme lexbuf).[0])) )
......@@ -218,17 +218,17 @@ let rec token engine lexbuf =
and comment engine lexbuf =
match engine lex_tables 1 lexbuf with
0 -> (
# 91 "parser/wlexer.mll"
# 92 "parser/wlexer.mll"
comment_start_pos := Lexing.lexeme_start lexbuf :: !comment_start_pos;
comment engine lexbuf;
)
| 1 -> (
# 95 "parser/wlexer.mll"
# 96 "parser/wlexer.mll"
comment_start_pos := List.tl !comment_start_pos;
if !comment_start_pos <> [] then comment engine lexbuf;
)
| 2 -> (
# 99 "parser/wlexer.mll"
# 100 "parser/wlexer.mll"
string_start_pos := Lexing.lexeme_start lexbuf;
let string =
if Lexing.lexeme_char lexbuf 0 = '"' then string2 else string1 in
......@@ -239,33 +239,33 @@ and comment engine lexbuf =
Buffer.clear string_buff;
comment engine lexbuf )
| 3 -> (
# 109 "parser/wlexer.mll"
# 110 "parser/wlexer.mll"
let st = List.hd !comment_start_pos in
error st (st+2) Unterminated_comment
)
| 4 -> (
# 113 "parser/wlexer.mll"
# 114 "parser/wlexer.mll"
comment engine lexbuf )
| _ -> failwith "lexing: empty token [comment]"
and string2 engine lexbuf =
match engine lex_tables 2 lexbuf with
0 -> (
# 117 "parser/wlexer.mll"
# 118 "parser/wlexer.mll"
() )
| 1 -> (
# 119 "parser/wlexer.mll"
# 120 "parser/wlexer.mll"
store_char (Lexing.lexeme_char lexbuf 1);
string2 engine lexbuf )
| 2 -> (
# 122 "parser/wlexer.mll"
# 123 "parser/wlexer.mll"
store_char (char_for_decimal_code (Lexing.lexeme lexbuf));
string2 engine lexbuf )
| 3 -> (
# 125 "parser/wlexer.mll"
# 126 "parser/wlexer.mll"
error !string_start_pos (!string_start_pos+1) Unterminated_string )
| 4 -> (
# 127 "parser/wlexer.mll"
# 128 "parser/wlexer.mll"
store_char (Lexing.lexeme_char lexbuf 0);
(* TODO: Unicode *)
string2 engine lexbuf )
......@@ -274,28 +274,28 @@ and string2 engine lexbuf =
and string1 engine lexbuf =
match engine lex_tables 3 lexbuf with
0 -> (
# 133 "parser/wlexer.mll"
# 134 "parser/wlexer.mll"
() )
| 1 -> (
# 135 "parser/wlexer.mll"
# 136 "parser/wlexer.mll"
store_char (Lexing.lexeme_char lexbuf 1);
string1 engine lexbuf )
| 2 -> (
# 138 "parser/wlexer.mll"
# 139 "parser/wlexer.mll"
store_char (char_for_decimal_code (Lexing.lexeme lexbuf));
string1 engine lexbuf )
| 3 -> (
# 141 "parser/wlexer.mll"
# 142 "parser/wlexer.mll"
error !string_start_pos (!string_start_pos+1) Unterminated_string )
| 4 -> (
# 143 "parser/wlexer.mll"
# 144 "parser/wlexer.mll"
store_char (Lexing.lexeme_char lexbuf 0);
string1 engine lexbuf )
| _ -> failwith "lexing: empty token [string1]"
;;
# 146 "parser/wlexer.mll"
# 147 "parser/wlexer.mll"
let lexer_func_of_wlex lexfun lexengine cs =
......
......@@ -45,16 +45,17 @@ classes
let identchar = lowercase | uppercase | ascii_digit | '_' | '\''
let ident = identchar* ( ':' identchar+)*
rule token = parse
blank+ { token engine lexbuf }
| (lowercase | '_') identchar* ( ':' identchar+)* {
| (lowercase | '_') ident {
let s = Lexing.lexeme lexbuf in
if Hashtbl.mem keywords s then "",s else "LIDENT",s
}
| uppercase identchar* ( ':' identchar+)* { "UIDENT",Lexing.lexeme lexbuf }
| uppercase ident { "UIDENT",Lexing.lexeme lexbuf }
| ascii_digit+ { "INT",Lexing.lexeme lexbuf }
| "<" blank* (lowercase | uppercase) identchar* {
| "<" blank* (lowercase | uppercase) ident {
let s = Lexing.lexeme lexbuf in
"TAG", tag_of_tag s 1
}
......
......@@ -30,7 +30,7 @@ let fun eval ( Expr -> Int )
| (`add,x,y) -> eval x + eval y
| (`mul,x,y) -> eval x * eval y
| (`sub,x,y) -> eval x - eval y
| (`div,x,y) -> eval x / eval y
| (`div,x,y) -> (eval x) div (eval y)
| n -> n
in
eval (`add, 10, (`add, 20, 5));;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment