Hi Doug,

> And I notice that some of the non-terminals there have arguments, for example:

Yes, I had already suspected so, because the clauses produced by 'dcg'
had only the self-generated arguments.

Currently, 'dcg' simply generates the lists of arguments. If we also
want to have user-defined arguments, then 'dcg' would need to append its
own arguments to the user's.

However, this is a problem of how we define the syntax of 'dcg'.

Currently, we have

   (dcg sentence  nounPhrase verbPhrase)  # [A]

this expands to

   (be sentence ("@In" "@Out")
      (nounPhrase "@In" "@1")
      (verbPhrase "@1" "@Out") )


Now, if we want additional arguments, I see two possibilities:


1. We _always_ supply a list of arguments, then we would need
   to write

   (dcg sentence ()  (nounPhrase) (verbPhrase))  # [B]

   This is not the intended style, right?


2. We rewrite 'dcg' to inspect each term. As long as each element is
   atomic (as in [A]), it behaves as it does now. If there are lists (as
   in [B]), then it appends its self-generated arguments.

   Then

      (dcg foo (@A) mumble (bar @A))

   would expand to

      (be foo (@A "@In" "@Out")
         (mumble "@In" "@1")
         (bar @A "@1" "@Out") )

   Would this make sense?

   BTW, because I expected someting like that, I chose to implement all
   self-generated arguments as transient symbols, so that they can't
   conflict with user-supplied arguments. :)

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to