diff options
| author | 2022-08-16 05:32:02 +0200 | |
|---|---|---|
| committer | 2022-08-16 05:32:02 +0200 | |
| commit | 77b2ae9b24d07770fdd22530bf22061a275cc0f0 (patch) | |
| tree | 8012f9730b1a2e725b45a2255e7c7a0e6eefc40a | |
| parent | 73f68a9c5ed4c8139cc1c4f7695da29e5a3fb4c8 (diff) | |
change 'not' to '!'
it looks nicer
| -rw-r--r-- | bootstrap/all.h | 1 | ||||
| -rw-r--r-- | bootstrap/cgen.c | 1 | ||||
| -rw-r--r-- | bootstrap/parse.c | 4 | ||||
| -rw-r--r-- | src/cffc.hff | 4 | ||||
| -rw-r--r-- | src/common.hff | 2 | ||||
| -rw-r--r-- | src/parse.cff | 38 | ||||
| -rw-r--r-- | src/type.cff | 2 |
7 files changed, 25 insertions, 27 deletions
diff --git a/bootstrap/all.h b/bootstrap/all.h index 77f4577..932fbe0 100644 --- a/bootstrap/all.h +++ b/bootstrap/all.h @@ -47,7 +47,6 @@ struct span { _(if) \ _(import) \ _(let) \ - _(not) \ _(or) \ _(return) \ _(sizeof) \ diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c index 39cbba0..665bdc5 100644 --- a/bootstrap/cgen.c +++ b/bootstrap/cgen.c @@ -847,7 +847,6 @@ static void prelude() { pri("#include <stdint.h>\n" "#include <stddef.h>\n" - "#define not !\n" "#define and &&\n" "#define or ||\n"); } diff --git a/bootstrap/parse.c b/bootstrap/parse.c index b113618..08f83a8 100644 --- a/bootstrap/parse.c +++ b/bootstrap/parse.c @@ -1523,7 +1523,7 @@ pexprefix(struct parser *P) { tok.t, exprdup(ex) } }; - } else if (lexmatch(P, &tok, TKkw_not)) { + } else if (lexmatch(P, &tok, '!')) { struct expr ex = pexprefix(P); if (ex.ty->t != TYbool) @@ -1531,7 +1531,7 @@ pexprefix(struct parser *P) { ex.ty, tok); return (struct expr) { Eprefix, tok.span, ty_bool, .unop = { - 'not', exprdup(ex) + '!', exprdup(ex) } }; } else if (lexmatch(P, &tok, '*')) { diff --git a/src/cffc.hff b/src/cffc.hff index 3824a14..82c9081 100644 --- a/src/cffc.hff +++ b/src/cffc.hff @@ -22,7 +22,7 @@ enum TokT : i32 { kw_and, kw_as, kw_break, kw_case, kw_const, kw_continue, kw_def, kw_defmacro, kw_do, kw_else, kw_enum, kw_extern, kw_fn, - kw_for, kw_if, kw_import, kw_let, kw_not, + kw_for, kw_if, kw_import, kw_let, kw_or, kw_return, kw_sizeof, kw_static, kw_struct, kw_switch, kw_typedef, kw_typeof, kw_union, kw_while, @@ -225,7 +225,7 @@ fn constify(ty *const Type) *const Type { return interntype(ty2); } fn unconstify(ty *const Type) *const Type { - if not ty.konst { + if !ty.konst { return ty; } let ty2 = *ty; diff --git a/src/common.hff b/src/common.hff index 02859f8..3d90c55 100644 --- a/src/common.hff +++ b/src/common.hff @@ -5,7 +5,7 @@ import "libc.hff"; defmacro assert { (ex, s, ...args) [ (do - if not (ex) { + if !(ex) { fprintf(stderr, "%s:%d: assertion failed: ", #FILE, #LINE); fprintf(stderr, s, args); fprintf(stderr, "\n"); diff --git a/src/parse.cff b/src/parse.cff index 2aed2da..c331986 100644 --- a/src/parse.cff +++ b/src/parse.cff @@ -101,7 +101,7 @@ fn ishsep(c u8) bool { fn readtilsep(P *Parser, buf [#]u8, dot bool) int { let i = 0, c u8 #?; - while (not issep(c = chrpeek(P))) or (dot and c == '.') { + while (!issep(c = chrpeek(P))) or (dot and c == '.') { chr(P); if i >= buf.#len - 1 { return -1; @@ -116,9 +116,9 @@ fn readtilhsep(P *Parser, buf [#]u8, dot bool) int { let i = 0, c u8 #?, pred = &ishsep; - while (not pred(c = chrpeek(P))) or (dot and c == '.') { + while (!pred(c = chrpeek(P))) or (dot and c == '.') { chr(P); - if not issep(c) { + if !issep(c) { pred = &issep; } if i >= buf.#len - 1 { @@ -132,7 +132,7 @@ fn readtilhsep(P *Parser, buf [#]u8, dot bool) int { fn eatspaces(P *Parser) void { for ;;chr(P) { - if not isspace(chrpeek(P)) { + if !isspace(chrpeek(P)) { break; } } @@ -143,7 +143,7 @@ extern static keyword2str [NUM_KEYWORDS]*const u8 = { "and", "as", "break", "case", "const", "continue", "def", "defmacro", "do", "else", "enum", "extern", "fn", - "for", "if", "import", "let", "not", + "for", "if", "import", "let", "or", "return", "sizeof", "static", "struct", "switch", "typedef", "typeof", "union", "while", @@ -193,13 +193,13 @@ fn readnumber(s *const u8) Option<Tok> { base = 16; continue; } - if not flt and c == '.' and base == 10 { + if !flt and c == '.' and base == 10 { flt = #t; accf = acc; continue; } if nused > 0 and c == '_' { continue; } - if (base == 16 and not isxdigit(c)) + if (base == 16 and !isxdigit(c)) or (base != 16 and (c < '0' or c > ('0' + base) - 1)) { suffix = s + i; } @@ -518,7 +518,7 @@ fn lexmatch(P *Parser, tokp *Tok, t TokT) bool { fn lexexpects(P *Parser, t TokT, what *const u8) Tok { let tok = Tok {}; - if not lexmatch(P, &tok, t) { + if !lexmatch(P, &tok, t) { if what { fatal(P, tok.loc, "expected %s (near %qT)", what, tok); } else { @@ -648,17 +648,17 @@ fn pexpostfix(P *Parser) Expr { case lexmatch(P, &tok, '('); let lhs = exprdup(P.alloc, ex), ty = lhs.ty->is(:Ptr) ? lhs.ty.u.Ptr : lhs.ty; - if not ty->is(:Fn) { + if !ty->is(:Fn) { fatal(P, lhs.loc, "not callable (%t)", lhs.ty); } let Fn = &ty.u.Fn; let args Vec<Expr> = {}; - while not lexmatch(P, #null, ')') { + while !lexmatch(P, #null, ')') { args->push(parseexpr(P)); - if args.len > Fn.params.#len and not Fn.variadic { + if args.len > Fn.params.#len and !Fn.variadic { fatal(P, args->last().loc, "too many args (%z, expected %z)", args.len, Fn.params.#len); } - if not lexmatch(P, #null, ',') { + if !lexmatch(P, #null, ',') { lexexpect(P, ')'); break; } @@ -715,7 +715,7 @@ fn pexbitarith(P *Parser) Expr { ty = ty_isize; case okind == :Int and ty->is(:Flo); err(P, tok.loc, "invalid operands %t and %t to binary operator %k", ex.ty, rhs.ty, tokt); - case okind != :StrLit and not isnumtype(ty); + case okind != :StrLit and !isnumtype(ty); fatal(P, tok.loc, "invalid operands %t and %t to binary operator %k", ex.ty, rhs.ty, tokt); } ex = { tok.loc, ty, .u: :BinOp { tokt, exprdup(P.alloc, ex), exprdup(P.alloc, rhs) }}; @@ -767,10 +767,10 @@ fn pexassign(P *Parser) Expr { } let rhs = pexcond(P); switch { - case not islvalue(ex); + case !islvalue(ex); err(P, ex.loc, "left operand to assignment is not lvalue"); case (typeof2(ex.ty, rhs.ty) == #null) - and not ((ex.ty->is(:Ptr) and rhs.ty->is(:Int) + and !((ex.ty->is(:Ptr) and rhs.ty->is(:Int) and (tok.t == '+=' or tok.t == '-='))); err(P, ex.loc, "operands %t and %t to assignment operator %qT have incompatible types", @@ -838,7 +838,7 @@ fn parsefn(P *Parser, decl *Decl, externp bool, name *const u8) void { paramtys Vec<*const Type> = {}; lexexpect(P, '('); - while not lexmatch(P, &tok, ')') { + while !lexmatch(P, &tok, ')') { if lexmatch(P, #null, '...') { Fn.variadic = #t; lexmatch(P, #null, ','); @@ -849,7 +849,7 @@ fn parsefn(P *Parser, decl *Decl, externp bool, name *const u8) void { let type = parsetype(P); paramnames->push(name); paramtys->push(type); - if not lexmatch(P, &tok, ',') { + if !lexmatch(P, &tok, ',') { lexexpect(P, ')'); break; } @@ -862,7 +862,7 @@ fn parsefn(P *Parser, decl *Decl, externp bool, name *const u8) void { static id int = 0; Fn.id = ++id; - if not lexmatch(P, #null, '{') { + if !lexmatch(P, #null, '{') { lexexpects(P, ';', "';' or '{'"); return; } @@ -914,7 +914,7 @@ extern fn parse(P *Parser) [#]Decl { P.alloc = &alloc; P.curenv = mkenv(#null, P.alloc); - while not P.eof { + while !P.eof { fn yield(decl *Decl, arg *void) void { let decls *Vec<*Decl> = arg; decls->push(decl); diff --git a/src/type.cff b/src/type.cff index 97fc44a..ecd8d77 100644 --- a/src/type.cff +++ b/src/type.cff @@ -167,7 +167,7 @@ fn rank2numtype(r int) *const Type { } extern fn typeof2(a *const Type, b *const Type) *const Type { - if a == b and not a->is(:Int) { + if a == b and !a->is(:Int) { return a; } if isnumtype(a) and isnumtype(b) { |