summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lexer.c b/lexer.c
index d72cdd7..5318924 100644
--- a/lexer.c
+++ b/lexer.c
@@ -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];