Version française
Home     About     Download     Resources     Contact us    
Browse thread
How can I have a string matched my custom type?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jean-Christophe Filliatre <filliatr@l...>
Subject: Re: [Caml-list] How can I have a string matched my custom type?

Mehdi writes:
 > There a little problem when you try to compute
 > 
 > > let e = parse "1*3-2";;
 > 
 > 
 > I get :
 > 
 > >  val e : expr = Times (Value "1", Value "3")

This is a Genlex limitation. "-2" is recognized as an integer
constant. Thus you need to add extra space:

======================================================================
# parse "1*3 - 2";;
- : expr = Minus (Times (Value "1", Value "3"), Value "2")
======================================================================

 > I also didn't understand why there is this in "term" :
 > 
 > >    | _ -> f
 > >    | _ -> failwith "syntax error"

Simply because I wrote this code in a rush :-) Forget about the last
line.

-- 
Jean-Christophe