From 0b8bd8e88f2620992310c7ba41283f5d9120e371 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Sun, 9 Jan 2022 22:24:07 +0000 Subject: Add rule for monadic function application --- lexer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lexer.c') 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]; -- cgit v1.2.3