diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-24 01:19:26 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-24 01:19:26 +0000 |
commit | 65bae1869f1451253276e51fea5b808b38685bf9 (patch) | |
tree | 2f4f7382487cccbd47f6030e1999670ed044d646 /lexer.c | |
parent | eb8e19f2964a2b0803d644c4cc7e15a8201cd46f (diff) |
Prepare for Dops later
Diffstat (limited to 'lexer.c')
-rw-r--r-- | lexer.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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]; |