You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.5 KiB
OCaml
34 lines
1.5 KiB
OCaml
(* ************************************************************************** *)
|
|
(* *)
|
|
(* ::: :::::::: *)
|
|
(* polynomial_lexer.mll :+: :+: :+: *)
|
|
(* +:+ +:+ +:+ *)
|
|
(* By: frdescam <marvin@42.fr> +#+ +:+ +#+ *)
|
|
(* +#+#+#+#+#+ +#+ *)
|
|
(* Created: 2023/02/16 19:09:56 by frdescam #+# #+# *)
|
|
(* Updated: 2023/02/24 11:24:52 by frdescam ### ########.fr *)
|
|
(* *)
|
|
(* ************************************************************************** *)
|
|
|
|
{
|
|
open Polynomial_parser
|
|
}
|
|
|
|
let digit = ['0'-'9']
|
|
let decimal = digit+
|
|
let floating = '-'? decimal '.' decimal
|
|
let integer = '-'? decimal
|
|
|
|
rule lex = parse
|
|
| [' ' '\t'] { lex lexbuf }
|
|
| integer as i { INT(int_of_string i) }
|
|
| floating as f { FLOAT(float_of_string f) }
|
|
| '+' { PLUS }
|
|
| '-' { MINUS }
|
|
| '*' { TIMES }
|
|
| '^' { POWER }
|
|
| '=' { EQUAL }
|
|
| ['x' 'X'] { VAR }
|
|
| '\n' { EOF }
|
|
| eof { EOF }
|