summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-09 22:24:07 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-09 22:24:07 +0000
commit0b8bd8e88f2620992310c7ba41283f5d9120e371 (patch)
tree428cdf822378a59fc5e5e9b9eb040cd91f64bdbc /lexer.c
parent325cfd6354dcccaa095767e0419760a3f9462fed (diff)
Add rule for monadic function application
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lexer.c b/lexer.c
index 21a5da8..40c7f35 100644
--- a/lexer.c
+++ b/lexer.c
@@ -4,7 +4,6 @@
#include "apl9.h"
-Rune primfuncnames[] = L"+-×÷*⍟⌹○!?|⌈⌊⊥⊤⊣⊢=≠≤<>≥≡≢∨∧⍲⍱↑↓⊂⊃⊆⌷⍋⍒⍳⍸∊⍷∪∩~,⍪⍴⌽⊖⍉⍎⍕";
Rune primmonopnames[] = L"¨⍨⌸⌶&";
Rune primdyadopnames[] = L"⍣.∘⍤⍥@⍠⌺";
Rune primhybridnames[] = L"/\⌿⍀";
@@ -17,6 +16,7 @@ lexline(Rune *line, int *ntoks)
Datum *tokens = mallocz(sizeof(Datum) * MAX_LINE_TOKENS, 1);
*ntoks = 0;
while(offset < len){
+ Rune *p;
if(isspacerune(line[offset])){
offset++;
continue;
@@ -30,14 +30,17 @@ lexline(Rune *line, int *ntoks)
case ']': tokens[*ntoks].tag = RBracketTag; break;
}
offset++;
- }else if(runestrchr(primfuncnames, line[offset])){
+ }else if(p = runestrchr(primfuncnames, line[offset])){
tokens[*ntoks].tag = FunctionTag;
+ tokens[*ntoks].code = p-primfuncnames;
offset++;
- }else if(runestrchr(primmonopnames, line[offset])){
+ }else if(p = runestrchr(primmonopnames, line[offset])){
tokens[*ntoks].tag = MonadicOpTag;
+ tokens[*ntoks].code = p-primmonopnames;
offset++;
- }else if(runestrchr(primdyadopnames, line[offset])){
+ }else if(p = runestrchr(primdyadopnames, line[offset])){
tokens[*ntoks].tag = DyadicOpTag;
+ tokens[*ntoks].code = p-primdyadopnames;
offset++;
}else if(isdigitrune(line[offset])){
char buf[64];