diff options
Diffstat (limited to 'lexer.c')
-rw-r--r-- | lexer.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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]; |