From: David Given Date: Sun, 1 Jan 2017 17:40:06 +0000 (+0000) Subject: Add support for the ~ operator. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=374e7a1c57ec44a98ad1e9df2291b6638c54efa0;p=ack.git Add support for the ~ operator. --- diff --git a/lang/b/compiler/b.h b/lang/b/compiler/b.h index 3da667be6..f5a11fd2a 100644 --- a/lang/b/compiler/b.h +++ b/lang/b/compiler/b.h @@ -104,6 +104,7 @@ char* manglename(char* name, char prefix); #define AMPER 23 #define STAR 24 #define QUEST 25 +#define NOT 26 #define PLUS 30 #define MINUS 31 diff --git a/lang/b/compiler/b0.c b/lang/b/compiler/b0.c index e6845bea0..cb28a6a3c 100644 --- a/lang/b/compiler/b0.c +++ b/lang/b/compiler/b0.c @@ -1060,6 +1060,7 @@ tand: goto oponst; case EXCLA: + case NOT: if (andflg) goto syntax; goto oponst; @@ -1225,7 +1226,7 @@ int opdope[] = { 034200, /* &un */ 034200, /* *un */ 014201, /* ? */ - 000000, /* 26 */ + 034200, /* ~un */ 000000, /* 27 */ 000000, /* 28 */ 000000, /* 29 */ @@ -1290,7 +1291,7 @@ char ctab[128] = { UNKN, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LBRACE, OR, RBRACE, UNKN, UNKN + LETTER, LETTER, LETTER, LBRACE, OR, RBRACE, NOT, UNKN }; /* debug function */ @@ -1320,6 +1321,7 @@ void printtoken(int tok, FILE *out) strtab[23] = "AMPER"; strtab[24] = "STAR"; strtab[25] = "QUEST"; + strtab[26] = "NOT"; strtab[30] = "PLUS"; strtab[31] = "MINUS"; diff --git a/lang/b/compiler/b1.c b/lang/b/compiler/b1.c index 19dc17a68..cc08d21ca 100644 --- a/lang/b/compiler/b1.c +++ b/lang/b/compiler/b1.c @@ -305,6 +305,11 @@ rcexpr(struct tnode *tr) C_ngi(wordsize); return; + case NOT: + rcexpr(tr->tr1); + C_com(wordsize); + return; + case QUEST: cbranch(tr->tr1, o1=isn++); rcexpr(tr->tr2->tr1);