Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

54 lines (49 sloc) 1.709 kb
{
(*
* (c) 2004-2010 Anastasia Gornostaeva
*)
open Pcalc
}
let digit = ['0'-'9']
rule token = parse
| [' ' '\t'] { token lexbuf }
| digit+
| "." digit+
| digit+ "." digit+
| digit+ ("." digit)* ("e"|"E")('-'|'+')? digit+ as num
{ NUM (float_of_string num) }
| '0' ('x'|'X') ['A'-'F' 'a'-'f' '0'-'9']+ as num
{ NUM (float_of_string num) }
| '0' ['b' 'B'] ['0' '1']+ as num
{ NUM (float_of_int (int_of_string num)) }
| '0' ['o' 'O'] ['0'-'8']+ as num
{ NUM (float_of_int (int_of_string num)) }
| '+' { PLUS }
| '-' { MINUS }
| '*' { MUL }
| '/' { DIVIDE }
| '%' { MOD }
| '^' { CARET }
| 'n' { UMINUS }
| "sqrt" { SQRT }
| "exp" { EXP }
| "log" { LOG }
| "log10" { LOG10 }
| "cos" { COS }
| "sin" { SIN }
| "tan" { TAN }
| "asoc" { ACOS }
| "asin" { ASIN }
| "atan" { ATAN }
| "atab2" { ATAN2 }
| "cosh" { COSH }
| "sinh" { SINH }
| "tanh" { TANH }
| "ceil" { CEIL }
| "floor" { FLOOR }
| "fact" { FACT }
| "fib" { FIB }
| "max_float" { MAX_FLOAT }
| ['p' 'P'] ['i' 'I'] { PI }
| _ { token lexbuf }
| eof { EOL }
Jump to Line
Something went wrong with that request. Please try again.