diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-24 18:58:45 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-24 18:58:45 +0000 |
commit | 07fe0f96352967457d64ff349f4383c5568bcd42 (patch) | |
tree | ca598c01a412c9af15e530b9ec22de8adbaab48c /lexer.c | |
parent | 65bae1869f1451253276e51fea5b808b38685bf9 (diff) |
Implement Dop's
Diffstat (limited to 'lexer.c')
-rw-r--r-- | lexer.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -113,8 +113,12 @@ lexline(InputStream *input, int toplevel) stmt->toks[stmt->ntoks].tag = FunctionTag; stmt->toks[stmt->ntoks].func.type = FunctypeDfn; stmt->toks[stmt->ntoks].func.dfn = runestrdup(buf); - }else - throwerror(L"Dops not implemented yet", ESyntax); + }else{ + stmt->toks[stmt->ntoks].tag = oplevel == 1 ? MonadicOpTag : DyadicOpTag; + stmt->toks[stmt->ntoks].operator.type = OperatortypeDop; + stmt->toks[stmt->ntoks].operator.dyadic = oplevel == 2; + stmt->toks[stmt->ntoks].operator.dop = runestrdup(buf); + } }else if(peek == '('){ int unclosed = 1; Rune buf[MAX_LINE_LENGTH]; @@ -173,7 +177,7 @@ get_digits: ungetrune(input); stmt->toks[stmt->ntoks].tag = ArrayTag; stmt->toks[stmt->ntoks].array = floating ? mkscalarfloat(atof(buf)) : mkscalarint(atoll(buf)); - }else if(runestrchr(L"⍺⍵", peek)){ + }else if(runestrchr(L"⍺⍵⍶⍹", peek)){ Rune name[2] = {peek, 0}; stmt->toks[stmt->ntoks].tag = NameTag; stmt->toks[stmt->ntoks].symbol = getsym(name, 1); @@ -245,7 +249,7 @@ syntax_error: free(stmt); throwerror(err, ESyntax); } - /*print("Got token: %S\n", ppdatum(stmt->toks[stmt->ntoks]));*/ + /* print("Got token: %S\n", ppdatum(stmt->toks[stmt->ntoks])); */ stmt->ntoks++; peek = getrune(input); } @@ -278,7 +282,7 @@ getrune(InputStream *i) else r = i->string[i->offset++]; } - /*print("Get rune: '%C' (%d)\n", r, r);*/ + /* print("Get rune: '%C' (%d)\n", r, r); */ i->last = r; return r; } @@ -286,7 +290,7 @@ getrune(InputStream *i) void ungetrune(InputStream *i) { - /*print("Unget rune: '%C' (%d)\n", i->last, i->last);*/ + /* print("Unget rune: '%C' (%d)\n", i->last, i->last); */ if(inputEOF(i)) return; |