[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling scomments after "."



Here's an updated BNF to deal with scomments after period.  I've ended up
adding a whole new production rule to deal with it.  This makes "head" and "rest"
consistent, it simplifies the other rules, and it'll also make the Scheme implementation easier too.

We need to do this whether or not we allow the ". $" sequence; we can remove "SUBLIST"
from the post_period production if we want to remove that.

Comments?  Any errors here?  If this seems okay, I'll change the Scheme implementation
to match, but I'd rather have the BNF right in the first place :-).

(The BNF below is in Java syntax; when it goes into the SRFI it'll get changed to Scheme syntax.)

--- David A. Wheeler


==============================================

// Process line after ". hspace+" sequence.  Does not go past current line.
post_period returns [Object v]
  : (scomment hspace*)*
    // NOTE: The SUBLIST and empty branch (alternatives 3 and 4) are
    // technically ambiguous (SUBLIST is first, so it's resolved first).
    (pn=n_expr hspace* (scomment hspace*)* (n_expr error)? {$v = $pn.v;}
     | COLLECTING hspace* pc=collecting_tail hspace*
       (scomment hspace*)* (n_expr error)? {$v = $pc.v;}
     | SUBLIST hspace* ps=rest {$v = $ps.v;}
     | /*empty*/ {$v = list(".");} ) ;


head returns [Object v]
  : PERIOD /* Leading ".": escape following datum like an n-expression. */
      (hspace+ pp=post_period {$v = list($pp.v);}
       | /*empty*/    {$v = list(".");} )
...

rest returns [Object v]
  : PERIOD /* Improper list */
      (hspace+  pp=post_period {$v = $pp.v;}
       | /*empty*/   {$v = list(".");})
  | scomment hspace* (sr=rest {$v = $sr.v;} | /*empty*/ {$v = null;} )
...