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

Re: [GNU-COBOL] GNU-COBOL list reborn



Tim Josling wrote:
> What would happen if the "2" was instead a function call (which
> counts as an "identifier"), like
> 
> move a to b(function exponential(2):3).
> 
> or a complex identifier, like
> 
> move a to b(z of x of y of t of u of w:3).
> 
Thanks for keeping me honest, Tim.  I should have checked the standard, but
I must have been thinking about the restricted level 1 version.  Sorry.

> What I am getting at here is that the colon is not necessarily
> any particular finite number of tokens ahead. Without knowing
> anything about the parser generator, it concerns me that many
> parser have finite lookahead
>
The rules should have looked like this

	identifier : ident (qualifier)*
			   ( (OPAREN arith_exp COLON)? refmod
			   |	( (OPAREN)? subscripts { refmod }
				|
				)
			   )
		   ;

	refmod	: OPAREN arith_expr COLON { arith_expr } CPAREN
		;

Pccts is the exception, Tim. It _does_ have infinite look-ahead. That sounds
expensive, but it's only used when it's required so as a practical matter,
it isn't a problem.  In the "built by hand" parser that I last used, we did
have a rule that would accept either subscript or refmod, but I think that
must have left some cleaning up to do in the semantics pass. I have no idea
how other parsers handle it.
  



--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.