diff options
Diffstat (limited to 'lexer.c')
-rw-r--r-- | lexer.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -88,13 +88,18 @@ lexline(Rune *line) }else if(isdigitrune(line[offset])){ char buf[64]; char *p = buf; - while(isdigitrune(line[offset])){ - p += runetochar(p, &line[offset]); - offset++; + int floating = 0; +get_digits: + while(isdigitrune(line[offset])) + p += runetochar(p, &line[offset++]); + if(!floating && line[offset] == '.'){ + p += runetochar(p, &line[offset++]); + floating = 1; + goto get_digits; } *p = 0; stmt->toks[stmt->ntoks].tag = ArrayTag; - stmt->toks[stmt->ntoks].array = mkscalarint(atoll(buf)); + stmt->toks[stmt->ntoks].array = floating ? mkscalarfloat(atof(buf)) : mkscalarint(atoll(buf)); }else if(runestrchr(L"⍺⍵", line[offset])){ Rune *name = L"?"; name[0] = line[offset]; |