[Aldor-l] Semicolon after single statement in if?

Ralf Hemmecke ralf at hemmecke.de
Thu May 7 10:22:39 EDT 2009


> Lexing a float, for instance:
> 
>   float: integer '.' [ integer ]
>        | '.' integer
> 
> now notice the operator '.' and the operator '..' in:


>   2..3
> 
> this could be either of:
> 
>   2. . 3
>   2. .3
>   2 . .3
>   2 .. 3
> 
> so there is code that takes care of this.

See AUG Section 22.2. "Tokens"

   The sequence of source characters is partitioned into tokens.
   The longest possible match is always used.

So '2..3' must mean '2 .. 3'.

Anyway, from the regular expressions for float appearing on page 243

[0-9]*`.'[0-9]+{[eE]{[+-]}[0-9]+}
[0-9]+`.'[0-9]*{[eE]{[+-]}[0-9]+}
[0-9]+[eE]{[+-]}[0-9]+
[0-9]+`r'[0-9A-Z]*`.'[0-9A-Z]+{e{[+-]}[0-9]+}
[0-9]+`r'[0-9A-Z]+`.'[0-9A-Z]*{e{[+-]}[0-9]+}
[0-9]+`r'[0-9A-Z]+`e'{[+-]}[0-9]+

I would happily remove the first line. Why would someone want .1 to be a 
floating point number. It's much more readable if one writes 0.1, no?

BTW, the AUG also says

A  floating point literal may not
- begin with ".", unless the preceding token is a keyword other
   than ")", "|)", "]" or "}",
- contain ".", if the preceding token is ".",
- end with ".", if the following character is ".".

So your case is explicitly ruled out.

Ralf



More information about the Aldor-l mailing list