From: Darmac
Subject: cl-yacc
Date: 
Message-ID: <1113485673.385931.303780@z14g2000cwz.googlegroups.com>
Is there anybody that had work with cl-yacc. Because I have to put a
null derivation in a grammar and I don't know how.
Example:
s --> A
A --> B
A -->

For tha last derivation, if I say thi (), when I run my parser, it
return NIL...

Thanks in advance...

From: Juliusz Chroboczek
Subject: Re: cl-yacc
Date: 
Message-ID: <7ioechfgpf.fsf@lanthane.pps.jussieu.fr>
> Is there anybody that had work with cl-yacc.

> Because I have to put a null derivation in a grammar and I don't
> know how.

> Example:
> s --> A
> A --> B
> A -->

> For tha last derivation, if I say thi (), when I run my parser, it
> return NIL...

This is the expected result.  The production

  (A ())

is shorthand for

  (A (  #'list))

(See the second form of ``rhs'' in the description of DEFINE-GRAMMAR
in the CL-Yacc manual.)

In other words, the default action associated to the last production
is #'LIST.  As the right hand side is the empty list, LIST gets called
with no arguments, which yields NIL.

If nil is not the expected value for the last production, you can
override CL-Yacc's choice of action.  For example,

  (A (  #'(lambda () 42)))

or equivalently, in pointless style,

  (A (  (constantly 42)))

(Please let me know if the above answered your question, and what it
is that you find confusing, so that I may improve CL-Yacc's manual.)

                                        Juliusz
From: Darmac
Subject: Re: cl-yacc
Date: 
Message-ID: <1113570515.534055.117120@f14g2000cwb.googlegroups.com>
Thanks !!!!. This is the answer that I need.
I read the manual, but I didn't find if "nil" was the correct response
or if I was making some mistake.

Thanks again.