summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-24 18:58:45 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-24 18:58:45 +0000
commit07fe0f96352967457d64ff349f4383c5568bcd42 (patch)
treeca598c01a412c9af15e530b9ec22de8adbaab48c /lexer.c
parent65bae1869f1451253276e51fea5b808b38685bf9 (diff)
Implement Dop's
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lexer.c b/lexer.c
index 4ba0a30..54e6e9b 100644
--- a/lexer.c
+++ b/lexer.c
@@ -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;