summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/lexer.c b/lexer.c
index 4c9e8f2..d72cdd7 100644
--- a/lexer.c
+++ b/lexer.c
@@ -101,21 +101,36 @@ lexline(Rune *line)
stmt->toks[stmt->ntoks].tag = NameTag;
stmt->toks[stmt->ntoks].symbol = getsym(currentsymtab, name);
offset++;
- }else if(isalpharune(line[offset]) || line[offset] == L'⎕'){
- int quadname = L'⎕' == line[offset];
+ }else if(isalpharune(line[offset])){
Rune buf[64];
Rune *p = buf;
- while(isalpharune(line[offset]) || (line[offset] == L'⎕' && p == buf)){
- if(quadname)
- *p = toupperrune(line[offset]);
- else
- *p = line[offset];
+ while(isalpharune(line[offset])){
+ *p = line[offset];
p++;
offset++;
}
*p = 0;
stmt->toks[stmt->ntoks].tag = NameTag;
stmt->toks[stmt->ntoks].symbol = getsym(currentsymtab, buf);
+ }else if(runestrchr(L"⎕⍞", line[offset])){
+ /* quad names */
+ Rune buf[64];
+ Rune *p = buf;
+ *p++ = line[offset++];
+ while(isalpharune(line[offset]))
+ *p++ = toupperrune(line[offset++]);
+ *p = 0;
+ int valid = 0;
+ for(int i = 0; quadnames[i].name != nil && !valid; i++){
+ if(runestrcmp(buf, quadnames[i].name) != 0)
+ continue;
+ valid = 1;
+ stmt->toks[stmt->ntoks] = quadnamedatum(quadnames[i]);
+ }
+ if(!valid){
+ offset -= runestrlen(buf);
+ goto syntax_error;
+ }
}else{
syntax_error:
print("Can't lex: %S\n", &line[offset]);