open Ast

exception ParserTypeError of Lexing.position * Lexing.position

let stringToComp = function
| ">=" -> Ge
| "<=" -> Le
| ">"  -> Gt
| "<"  -> Lt
| "<>" -> Neq
| "="  -> Eq (* normally not used *)
| _    -> failwith "Parser : internal error"

let rec stringToTyp sp ep = function
| ["unit"] -> Tunit
| ["bool"] -> Tbool
| ["int"]  -> Tint
| "ref"::s -> Tref (stringToTyp sp ep s)
| "list"::s -> Tlist (stringToTyp sp ep s)
| _ -> raise (ParserTypeError (sp,ep))

