From 65bae1869f1451253276e51fea5b808b38685bf9 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Mon, 24 Jan 2022 01:19:26 +0000 Subject: Prepare for Dops later --- lexer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lexer.c') diff --git a/lexer.c b/lexer.c index 706db23..4ba0a30 100644 --- a/lexer.c +++ b/lexer.c @@ -92,9 +92,14 @@ lexline(InputStream *input, int toplevel) stmt->ntoks--; }else if(peek == '{'){ int unclosed = 1; + int oplevel = 0; /* 1 = monadic operator, 2 = dyadic operator */ Rune buf[MAX_LINE_LENGTH]; Rune *p = buf; while(((peek = getrune(input)) != '}' || unclosed > 1) && !inputEOF(input)){ + if(unclosed == 1 && peek == L'⍶' && oplevel == 0) + oplevel = 1; + else if(unclosed && peek == L'⍹') + oplevel = 2; if(peek == '{') unclosed++; else if(peek == '}') @@ -104,9 +109,12 @@ lexline(InputStream *input, int toplevel) if(peek != '}') goto syntax_error; *p = 0; - stmt->toks[stmt->ntoks].tag = FunctionTag; - stmt->toks[stmt->ntoks].func.type = FunctypeDfn; - stmt->toks[stmt->ntoks].func.dfn = runestrdup(buf); + if(oplevel == 0){ + 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 if(peek == '('){ int unclosed = 1; Rune buf[MAX_LINE_LENGTH]; -- cgit v1.2.3