esseks/monicelli — pull request #9 by alessandropellegrini (2014-12-03 10:00:37+00:00)
Title: Numbers can be written as strings

I think that in a supercazzola is useful to write number as strings.
This patch add supports for stringified numbers in both variables assignments and shifts. Numbers from zero to novemilanovecentonovantanove are recognized so far.
I have tried to alter as little as possible the existing lexer and parser, so something could be made better.
For example, the syntax of numbers is not checked for, and a number like millemilleundicidieci is mapped to 2021. This could be fixed by using more complex rules in the parser.
Furthermore, the rule to sum up numbers in the parser uses right recursion. This consumes a bit more stack, but it was done since this allows to modify as little as possible the existing grammar, and considering that numbers wont't be so long.

As for the lexer, to avoid reducing the space of possible names, numbers live in a separate starting condition. This means that a sentence like: `voglio mille, Necchi come se fosse mille` is correctly interpreted (first `mille` is the variable name, secon `mille` is recognized as 1000).
Note that this implies that writing later `voglio antani, Necchi come se fosse mille` is not mapped to the previously-declared variable, but this is a design choice.

To avoid clashes with future tokens, whenever a character which is not recognized as a possible string number is found, the lexer falls back to the INITIAL starting condition (the shift starting condition should be perfectly compatible with this behviour).

To allow for the recognition of string numbers, the appropriate starting condition should be explicitly set in the lexer. This means that, e.g., in `mille a posterati`, the string `mille` is not currently mapped to a number.