lua-users home
lua-l archive

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


On Fri, 30 Apr 2010 11:20:39 -0300
Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

> > > isn't '-' part of the Number terminal?
> > 
> > No.
> 
> In most languages '-' cannot be part of the number terminal, otherwise
> an expression like 'x-1' would be read as an identifier (x) followed by
> a number (-1).
> 
> -- Roberto

Just a note. At a higher --syntactic-- level, x <op> 1 can only be an operation. This allows treating +/-n as a signed number terminal directly without any ambiguity:
	-1 	without a valid operand before is a number
	x-1 	is an operation
	x--1 		"
But this approach applies only to global grammars; meaning without a separate lexer.

Denis
________________________________

vit esse estrany ☣

spir.wikidot.com