From 77b2ae9b24d07770fdd22530bf22061a275cc0f0 Mon Sep 17 00:00:00 2001 From: lemon Date: Tue, 16 Aug 2022 05:32:02 +0200 Subject: change 'not' to '!' it looks nicer --- src/parse.cff | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/parse.cff') 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 { 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 = {}; - 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); -- cgit v1.2.3