summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c14
1 files changed, 11 insertions, 3 deletions
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];