diff --git a/crocgrammar.txt b/crocgrammar.txt index 5153310..2fb084f 100644 --- a/crocgrammar.txt +++ b/crocgrammar.txt @@ -249,7 +249,6 @@ ReturnTypes: Type: BasicType - ! null not null any @ DottedName @@ -425,7 +424,6 @@ EqualExpression: ShiftExpression == ShiftExpression ShiftExpression != ShiftExpression ShiftExpression is ShiftExpression - ShiftExpression ! is ShiftExpression ShiftExpression is not ShiftExpression RelExpression: @@ -435,7 +433,6 @@ RelExpression: ShiftExpression >= ShiftExpression ShiftExpression <=> ShiftExpression ShiftExpression in ShiftExpression - ShiftExpression ! in ShiftExpression ShiftExpression not in ShiftExpression ShiftExpression: diff --git a/samples/threadtest.croc b/samples/threadtest.croc index 495ae82..2fafbb0 100644 --- a/samples/threadtest.croc +++ b/samples/threadtest.croc @@ -63,7 +63,7 @@ class Thread { if(:mNeedMessage) { - assert(:mMessageHead !is null) + assert(:mMessageHead is not null) :mNeedMessage = false local ok, value = :receive() assert(ok) diff --git a/src/croc/compiler/parser.cpp b/src/croc/compiler/parser.cpp index 003eb60..75959ec 100644 --- a/src/croc/compiler/parser.cpp +++ b/src/croc/compiler/parser.cpp @@ -688,7 +688,7 @@ namespace croc ret = cast(uint32_t)TypeMask::Any; } - else if(l.type() == Token::Not || l.type() == Token::NotKeyword) + else if(l.type() == Token::NotKeyword) { l.next(); l.expect(Token::Null); @@ -1901,25 +1901,6 @@ namespace croc exp1 = new(c) NotEqualExp(location, exp2->endLocation, exp1, exp2); break; - case Token::Not: - if(l.peek().type == Token::Is) - { - l.next(); - l.next(); - exp2 = parseShiftExp(); - exp1 = new(c) NotIsExp(location, exp2->endLocation, exp1, exp2); - } - else if(l.peek().type == Token::In) - { - l.next(); - l.next(); - exp2 = parseShiftExp(); - exp1 = new(c) NotInExp(location, exp2->endLocation, exp1, exp2); - } - // no, there should not be an 'else' here - - break; - case Token::NotKeyword: if(l.peek().type == Token::In) { diff --git a/src/croc/stdlib/docs.croc b/src/croc/stdlib/docs.croc index 3dd0b05..7c3f475 100644 --- a/src/croc/stdlib/docs.croc +++ b/src/croc/stdlib/docs.croc @@ -126,7 +126,7 @@ access their doc tables through their parents' \tt{children} doctable member. Th */ function childDocs(obj: class|namespace, child: string) { - if(child !in obj) + if(child not in obj) throw ValueError("Object has no child named '{}'".format(child)) local docs = docsOf(obj) diff --git a/src/croc/stdlib/doctools_console.croc b/src/croc/stdlib/doctools_console.croc index 00868b8..d9389bf 100644 --- a/src/croc/stdlib/doctools_console.croc +++ b/src/croc/stdlib/doctools_console.croc @@ -227,7 +227,7 @@ class BasicConsoleOutputter : DocOutputter { :beginParagraph() - if(name !is "docs") + if(name is not "docs") { :beginBold() @@ -494,7 +494,7 @@ class BasicConsoleOutputter : DocOutputter local first, second = splitAtWS(s, remaining) - if(first !is null) + if(first is not null) :baseWrite(first) :newline() diff --git a/src/croc/stdlib/doctools_output.croc b/src/croc/stdlib/doctools_output.croc index e7bca31..b491b99 100644 --- a/src/croc/stdlib/doctools_output.croc +++ b/src/croc/stdlib/doctools_output.croc @@ -64,7 +64,7 @@ class LinkResolver // Might be some globals added by user code that aren't in docsOf(_G).children foreach(name, val; _G) { - if(name !is "_G" && name !in :_globals && name !in modules.loaded) + if(name is not "_G" && name not in :_globals && name not in modules.loaded) { if(local dt = docsOf(val)) :_globals[name] = :_makeMapRec(dt) @@ -99,7 +99,7 @@ class LinkResolver */ function enterModule(name: string) { - if(:_item !is null || :_module !is null) + if(:_item is not null || :_module is not null) throw StateError("Attempting to enter a module from {} scope".format(:currentScope())) if(local m = :_modules[name]) @@ -117,7 +117,7 @@ class LinkResolver */ function enterItem(name: string) { - if(:_item !is null || :_module is null) + if(:_item is not null || :_module is null) throw StateError("Attempting to enter an item from {} scope".format(:currentScope())) if(local i = :_module.children[name]) @@ -133,9 +133,9 @@ class LinkResolver */ function leave() { - if(:_item !is null) + if(:_item is not null) :_item = null - else if(:_module !is null) + else if(:_module is not null) :_module = null else throw StateError("Attempting to leave at global scope") @@ -196,10 +196,10 @@ class LinkResolver // Private function _inItem(link: string) = - :_item !is null && link in :_item.children + :_item is not null && link in :_item.children function _inCurModule(link: string) = - :_module !is null && :_inModule(:_module, link) + :_module is not null && :_inModule(:_module, link) function _inModules(link: string) { @@ -262,7 +262,7 @@ class LinkResolver local f = link[dot + 1 ..] local i = :_globals[n] - return i !is null && i.children && f in i.children + return i is not null && i.children && f in i.children } function _inGlobals(link: string) = @@ -376,7 +376,7 @@ class LinkTranslator /// Checks if a given name is a valid name for a doc section. function validSectionName(name: string) = - !(#name == 0 || (#name == 1 && name[0] == '_') || (name[0] != '_' && name !in stdSections)) + !(#name == 0 || (#name == 1 && name[0] == '_') || (name[0] != '_' && name not in stdSections)) /// Checks if a paragraph list is empty (has no actual text). function isPlistEmpty(plist: array) = @@ -502,7 +502,7 @@ function toHeader(doctable: table, parentFQN: string, full: bool = true) if(doctable.name == "constructor") { - if(parentFQN !is "") + if(parentFQN is not "") ret.append(parentFQN, ".") ret.append("this") @@ -512,7 +512,7 @@ function toHeader(doctable: table, parentFQN: string, full: bool = true) if(full) ret.append("function ") - if(parentFQN !is "") + if(parentFQN is not "") ret.append(parentFQN, ".") ret.append(doctable.name) @@ -544,7 +544,7 @@ function toHeader(doctable: table, parentFQN: string, full: bool = true) if(full) ret.append(doctable.kind, " ") - if(parentFQN !is "") + if(parentFQN is not "") ret.append(parentFQN, ".") ret.append(doctable.name) @@ -557,7 +557,7 @@ function toHeader(doctable: table, parentFQN: string, full: bool = true) break case "field": - if(parentFQN !is "") + if(parentFQN is not "") ret.append(parentFQN, ".") ret.append(doctable.name) @@ -573,7 +573,7 @@ function toHeader(doctable: table, parentFQN: string, full: bool = true) if(full) ret.append(doctable.protection, " ") - if(parentFQN !is "") + if(parentFQN is not "") ret.append(parentFQN, ".") ret.append(doctable.name) @@ -706,7 +706,7 @@ class SectionOrder // Make sure all standard sections are accounted for foreach(sec; stdSections) - if(sec !in order) + if(sec not in order) throw ValueError("Standard section '{}' does not exist in the given order".format(sec)) // Make sure there are no duplicates @@ -749,7 +749,7 @@ class SectionOrder throw ValueError("Invalid section name '{}'".format(target)) else if(sec == target) throw ValueError("Section names must be different") - else if(target !in ord) + else if(target not in ord) throw ValueError("Section '{}' does not exist in the section order".format(target)) local ord = :_sectionOrder diff --git a/src/croc/stdlib/doctools_trac.croc b/src/croc/stdlib/doctools_trac.croc index 176b5bd..9263509 100644 --- a/src/croc/stdlib/doctools_trac.croc +++ b/src/croc/stdlib/doctools_trac.croc @@ -146,7 +146,7 @@ class TracWikiOutputter : DocOutputter override function beginSection(name: string) { - if(name !is "docs") + if(name is not "docs") { :beginParagraph() :beginBold() diff --git a/src/croc/stdlib/hash_weaktables.croc b/src/croc/stdlib/hash_weaktables.croc index 7f0c306..08a3645 100644 --- a/src/croc/stdlib/hash_weaktables.croc +++ b/src/croc/stdlib/hash_weaktables.croc @@ -74,7 +74,7 @@ class WeakKeyTable : WeakTableBase { local v = :_data[keys[idx]] - if(v !is null) + if(v is not null) return deref(keys[idx]), v } } @@ -107,7 +107,7 @@ class WeakKeyTable : WeakTableBase /** Gets an array of the keys (dereferenced) of this table. */ - function keys() = [deref(k) foreach k, _; :_data if deref(k) !is null] + function keys() = [deref(k) foreach k, _; :_data if deref(k) is not null] /** Gets an array of the values of this table. @@ -171,7 +171,7 @@ class WeakValTable : WeakTableBase { local v = deref(:_data[keys[idx]]) - if(v !is null) + if(v is not null) return keys[idx], v } } @@ -209,7 +209,7 @@ class WeakValTable : WeakTableBase /** Gets an array of the values (dereferenced) of this table. */ - function values() = [deref(v) foreach _, v; :_data if deref(v) !is null] + function values() = [deref(v) foreach _, v; :_data if deref(v) is not null] /** Normalizes the table by removing any key-value pairs where the value has been collected. This is usually called @@ -266,7 +266,7 @@ class WeakKeyValTable : WeakTableBase { local v = deref(:_data[keys[idx]]) - if(v !is null) + if(v is not null) return deref(keys[idx]), v } } @@ -299,12 +299,12 @@ class WeakKeyValTable : WeakTableBase /** Gets an array of the keys (dereferenced) of this table. */ - function keys() = [deref(k) foreach k, _; :_data if deref(k) !is null] + function keys() = [deref(k) foreach k, _; :_data if deref(k) is not null] /** Gets an array of the values (dereferenced) of this table. */ - function values() = [deref(v) foreach _, v; :_data if deref(v) !is null] + function values() = [deref(v) foreach _, v; :_data if deref(v) is not null] /** Normalizes the table by removing any key-value pairs where the key or value have been collected. This is usually diff --git a/src/croc/stdlib/serialization.croc b/src/croc/stdlib/serialization.croc index 4742f98..36438d3 100644 --- a/src/croc/stdlib/serialization.croc +++ b/src/croc/stdlib/serialization.croc @@ -128,7 +128,7 @@ local class Serializer } local method = SerializeMethods[typeof(val)] - assert(method !is null, "t: " ~ typeof(val)) + assert(method is not null, "t: " ~ typeof(val)) return :(method)(val) } @@ -508,7 +508,7 @@ local class Deserializer throw ValueError("Malformed data (expected object of type '{}' but found '{}' instead)".format(r)) } - if(typeof(val) !is w) + if(typeof(val) is not w) { throw ValueError("Malformed data (expected type '{}' but found a backref to type '{}' instead)".format( w, niceTypeof(val))) diff --git a/src/croc/stdlib/stream.croc b/src/croc/stdlib/stream.croc index a96c833..5e35037 100644 --- a/src/croc/stdlib/stream.croc +++ b/src/croc/stdlib/stream.croc @@ -1047,7 +1047,7 @@ class TextReader #:_chunks = 0 - while outer(:_string !is "") + while outer(:_string is not "") { foreach(pos, c; :_string) { @@ -1294,7 +1294,7 @@ class NativeStream : Stream */ override this(stream: nativeobj, caps: string) { - if(hidden(with this, "handle") !is null) + if(hidden(with this, "handle") is not null) throw StateError("Attempting to call constructor on an already-initialized stream") nativeStreamCtor(this, stream, caps) diff --git a/tools/depgrapher.croc b/tools/depgrapher.croc index f35f1b8..5f3b30d 100644 --- a/tools/depgrapher.croc +++ b/tools/depgrapher.croc @@ -6,7 +6,7 @@ import string: StringBuffer function as_(c: class) = \i: instance -> - (i as c) !is null + (i as c) is not null local cats = { @@ -269,7 +269,7 @@ digraph d function cycleColor(c) { - if(c !in cycleColors) + if(c not in cycleColors) { // local r, g, b = cycleColors[c] = "\"#{:x2}{:x2}{:x2}\"".format(math.rand(128) + 127, math.rand(128) + 127, math.rand(128) + 127) @@ -282,7 +282,7 @@ digraph d { if(cat is :ignore) continue - else if(cat !is :uncat) + else if(cat is not :uncat) { ret.append(@' subgraph cluster_' ~ cat.name ~ @' @@ -299,7 +299,7 @@ digraph d foreach(mod; cat.modules) ret.formatln("\t\"{}\" [style = filled, fillcolor = {}]", mod.name, mod.cycle ? cycleColor(mod.cycle) : "grey") - if(cat !is :uncat) + if(cat is not :uncat) ret.formatln("\t}") foreach(mod; cat.modules) @@ -355,7 +355,7 @@ digraph d foreach(w, _; v.deps) { - if(w !in index) + if(w not in index) { tarjan(w) lowlink[v] = min(lowlink[v], lowlink[w]) @@ -372,7 +372,7 @@ digraph d { local n = S.pop() cycle.append(n) - } while(n !is v) + } while(n is not v) if(#cycle > 1) foreach(mod; cycle) @@ -381,7 +381,7 @@ digraph d } foreach(mod; :allModules) - if(mod !in index) + if(mod not in index) tarjan(mod) hash.clear(index)