summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-12 20:09:05 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-12 20:09:05 +0000
commit55ca6248ffff6d9e1669fc49fe9de8489adeb7f9 (patch)
tree1bd23b6c91cb0c792ac1072cfe005cf2f5581551 /lexer.c
parentd152639e4495089cabbbf7a16e5bc5129af78bfa (diff)
Add dfn evaluation, and localized ⎕IO
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lexer.c b/lexer.c
index eb5a3c4..1c35f91 100644
--- a/lexer.c
+++ b/lexer.c
@@ -9,7 +9,7 @@ Rune primdyadopnames[] = L"⍣.∘⍤⍥@⍠⌺";
Rune primhybridnames[] = L"/\⌿⍀";
Statement *
-lexline(Rune *line, Symtab *symtab)
+lexline(Rune *line)
{
int offset = 0;
int len = runestrlen(line);
@@ -30,7 +30,7 @@ lexline(Rune *line, Symtab *symtab)
case '[': stmt->toks[stmt->ntoks].tag = LBracketTag; break;
case ']': stmt->toks[stmt->ntoks].tag = RBracketTag; break;
case L'←': stmt->toks[stmt->ntoks].tag = ArrowTag; break;
- case L'⋄': stmt->next = lexline(&line[offset+1], symtab); goto end;
+ case L'⋄': stmt->next = lexline(&line[offset+1]); goto end;
case L'⍝': goto end;
}
offset++;
@@ -73,6 +73,12 @@ lexline(Rune *line, Symtab *symtab)
*p = 0;
stmt->toks[stmt->ntoks].tag = ArrayTag;
stmt->toks[stmt->ntoks].array = mkscalarint(atoll(buf));
+ }else if(runestrchr(L"⍺⍵", line[offset])){
+ Rune *name = L"?";
+ name[0] = line[offset];
+ stmt->toks[stmt->ntoks].tag = NameTag;
+ stmt->toks[stmt->ntoks].symbol = getsym(currentsymtab, name);
+ offset++;
}else if(isalpharune(line[offset]) || line[offset] == L'⎕'){
int quadname = L'⎕' == line[offset];
Rune buf[64];
@@ -87,7 +93,7 @@ lexline(Rune *line, Symtab *symtab)
}
*p = 0;
stmt->toks[stmt->ntoks].tag = NameTag;
- stmt->toks[stmt->ntoks].symbol = getsym(symtab, buf);
+ stmt->toks[stmt->ntoks].symbol = getsym(currentsymtab, buf);
}else{
syntax_error:
print("Can't lex: %S\n", &line[offset]);