diff options
Diffstat (limited to 'asm/asmlex.mll')
-rw-r--r-- | asm/asmlex.mll | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/asm/asmlex.mll b/asm/asmlex.mll index 873e32d..7be493e 100644 --- a/asm/asmlex.mll +++ b/asm/asmlex.mll @@ -54,8 +54,8 @@ let valh d = let c = Char.code d in if c >= Char.code '0' && c <= Char.code '9' then c - (Char.code '0') - else if c >= Char.code 'a' && c <= Char.code 'f' then c - (Char.code 'a') - else c - (Char.code 'A') + else if c >= Char.code 'a' && c <= Char.code 'f' then c - (Char.code 'a') + 10 + else c - (Char.code 'A') + 10 let read_16 n = let res = ref 0 in @@ -96,7 +96,7 @@ rule token = parse { INT (read_16 n) } | (digit)+ as n { INT (int_of_string n) } | "0b" (['0' '1']+ as n) { INT (read_2 n) } - | ['A'-'Z']+ as name { REG (List.assoc name regs) } + | ['A'-'Z']+ as name { try REG (List.assoc name regs) with Not_found -> raise (Asm_error ("no reg " ^ name))} | '$' (['0'-'7'] as n) { REG (Char.code n - (Char.code '0')) } | ".text" { TEXT } | ".data" { DATA } @@ -127,3 +127,4 @@ and comment = parse | eof { EOF } | '\n' { Lexing.new_line lexbuf; token lexbuf } | _ { comment lexbuf } + |