English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Ocamlyacc questions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-06 (01:07)
From: cjohnson@w...
Subject: Ocamlyacc questions
I'm evaluating ocamlyacc for a compiler implementation, and I was
hoping to get help with two questions.  Here is a very simple ocamlyacc
grammar file:

  (* A simple ocamlyacc file for demonstration. *)

%token <unit> PROGRAM 
%token <string> IDENTIFIER

%start program


This has two errors:

1. The action {} after the first identifier causes an error.  Does
ocamlyacc not support actions before the last token?  How would I work
around this?

2. When the action from #1 is removed, I get an error message, 
    "no type has been declared for the start symbol"
    but changing '%start program' to '%start <type> program' where type
    is int, unit, etc. causes a syntax error.  Any ideas?

Thanks in advance!

Chris Johnson
The man who sets out to carry a cat by its tail learns something that
will always be useful and which never will grow dim or doubtful.
       -- Mark Twain