Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] yacc & lex: Does the contructor name matter?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andrzej M. Ostruszka <ostruszk@o...>
Subject: [Caml-list] Re: yacc & lex: Does the contructor name matter?
On Tue, Dec 03 (2002), Xavier Leroy wrote:
[...]

First of all thank you for an explanation

> The actual grammar that ocamlyacc compiles down to a PDA has some
> additional productions:
> 
> $accept: %entry EOF       { should not reduce }
> %entry:  '\001' line      { stop parsing with result $2 }
> line:    expr             { Some $1 }
>       | /*nothing*/       { None }

I've looked at the .ml and .mli but haven't found anything regarding EOF
so that's why I asked.

> The best way to avoid this difficulty is to make sure that all your
> grammar entry points are explicitly terminated by a token, as shown
> in the example in section 12.6 of the manual:
> 
>     %start line
> 
>     %%
>     line:
>       | expr EoL { Some $1 }
>       | /* nothing */ EoL { None }

:), I've read that section and knew the solution and just wanted to know
the cause of this behaviour.

> > - compile AST to list of functions which will take in arguments the
> >   operands and the "pointer" of the place where to store the result.
> >   I don't have now a clear idea how to do it (I still think in C :)) but
> >   the motivation is to remove pushing functions and stack management of
> >   the previous solution
> 
> I don't understand your third option.

Well I thought about having some list of records
{ double x, y; double* r; and maybe function pointer }
where the function would take x and y and store the result where
r points to and the job of the compiler would be to craft those pointers
(and x's in case of constants) appropriately.  As I've told I'm still
rather C than OCaml guy :).

						Best regards

PS. Doubling of the posts is not my fault it happens "somewhere" in
  France (one can check that by message ID).  Maybe this is because I'm
  sending from another address that I'm subscribed?
-- 
    ____   _  ___
   /  | \_/ |/ _ \		Andrzej Marek Ostruszka
  / _ |     | (_) | Instytut Fizyki, Uniwersytet Jagiellonski (Cracow)
 /_/ L|_|V|_|\___/	(PGP <-- finger ostruszk@order.if.uj.edu.pl)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners