[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: number parsing question
- From: spir ☣ <denis.spir@...>
- Date: Fri, 30 Apr 2010 18:51:29 +0200
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