caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Ocamlyacc questions
  2005-02-06  2:24 Ocamlyacc questions cjohnson
@ 2005-02-06  1:26 ` Micha
  0 siblings, 0 replies; 2+ messages in thread
From: Micha @ 2005-02-06  1:26 UTC (permalink / raw)
  To: caml-list

Am Sonntag, 6. Februar 2005 03:24 schrieb cjohnson@wcug.wwu.edu:
> 1. The action {} after the first identifier causes an error.  Does
> ocamlyacc not support actions before the last token? 

no, as far as I know, not

> How would I work 
> around this?

declare extra nonterminals such as:

program: PROGRAM prg_ident IDENTIFIER PERIOD {};

prg_ident: IDENTIFIER {} 

but you can get conflicts...

> 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?

yes, it should be:

%start program
%type <type> program

the type is declared extra (as the docu says... :-)


 Micha


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Ocamlyacc questions
@ 2005-02-06  2:24 cjohnson
  2005-02-06  1:26 ` [Caml-list] " Micha
  0 siblings, 1 reply; 2+ messages in thread
From: cjohnson @ 2005-02-06  2:24 UTC (permalink / raw)
  To: caml-list

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

%%
program	: PROGRAM IDENTIFIER {} IDENTIFIER PERIOD {} ;
%%

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
cjohnson@wcug.wwu.edu
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-02-06  1:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-06  2:24 Ocamlyacc questions cjohnson
2005-02-06  1:26 ` [Caml-list] " Micha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).