File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ std::vector<Token> tokenize(const std::string &source)
144144 i = j;
145145 } else if (isdigit (c)) {
146146 t.type = NUMBER;
147- if (c == ' 0' && not isdigit (source.at (i+1 ))) {
147+ if (c == ' 0' && source. at (i+ 1 ) != ' . ' && tolower (source. at (i+ 1 )) != ' e ' && not isdigit (source.at (i+1 ))) {
148148 c = tolower (source.at (i+1 ));
149149 if (isalpha (c) || c == ' #' ) {
150150 long base;
@@ -195,10 +195,24 @@ std::vector<Token> tokenize(const std::string &source)
195195 }
196196 } else {
197197 auto j = i;
198- // TODO: decimal and exponent
199198 while (j < source.length () && isdigit (source.at (j))) {
200199 j++;
201200 }
201+ if (j < source.length () && source.at (j) == ' .' ) {
202+ j++;
203+ while (j < source.length () && isdigit (source.at (j))) {
204+ j++;
205+ }
206+ }
207+ if (j < source.length () && tolower (source.at (j)) == ' e' ) {
208+ j++;
209+ if (j < source.length () && (source.at (j) == ' +' || source.at (j) == ' -' )) {
210+ j++;
211+ }
212+ while (j < source.length () && isdigit (source.at (j))) {
213+ j++;
214+ }
215+ }
202216 t.value = number_from_string (source.substr (i, j-i));
203217 i = j;
204218 }
Original file line number Diff line number Diff line change 1- % TODO
2- VAR a: number
1+ print(str(0.3))
2+ %= 3E-1
33
4- a := 0.3
5- print(a)
6- %= 0.3
4+ print(str(3.3e33))
5+ %= 33E+32
76
8- a := 3.3e33
9- print(a)
10- %= 3.3e33
7+ print(str(3.3e-33))
8+ %= 33E-34
9+
10+ print(str(0e33))
11+ %= 0E+33
12+
13+ print(str(1.e33))
14+ %= 1E+33
You can’t perform that action at this time.
0 commit comments