Rename "!=" to "<>"; "!" now only shows impurity
diff --git a/doc/changelog.md b/doc/changelog.md
index f58e8c0..205ad84 100644
--- a/doc/changelog.md
+++ b/doc/changelog.md
@@ -21,6 +21,7 @@
- Spun `std/zlib` out of `std/flate`.
- Let the `std/zlib` decoder ignore checksums.
- Renamed `std/flate` to `std/deflate`.
+- Renamed `!=` to `<>`; `!` is now only for impure functions.
- Renamed `~+` to `~mod+`; added `~mod-`, `~sat+` and `~sat-`.
- Removed `&^`.
- Renamed `$(etc)` to `[etc]`.
@@ -67,4 +68,4 @@
---
-Updated on February 2019.
+Updated on March 2019.
diff --git a/lang/ast/string.go b/lang/ast/string.go
index 871814c..7a02a00 100644
--- a/lang/ast/string.go
+++ b/lang/ast/string.go
@@ -164,7 +164,7 @@
t.IDXBinaryTildeModMinus: " ~mod- ",
t.IDXBinaryTildeSatPlus: " ~sat+ ",
t.IDXBinaryTildeSatMinus: " ~sat- ",
- t.IDXBinaryNotEq: " != ",
+ t.IDXBinaryNotEq: " <> ",
t.IDXBinaryLessThan: " < ",
t.IDXBinaryLessEq: " <= ",
t.IDXBinaryEqEq: " == ",
diff --git a/lang/check/check_test.go b/lang/check/check_test.go
index 12aabca..d80cc9e 100644
--- a/lang/check/check_test.go
+++ b/lang/check/check_test.go
@@ -86,7 +86,7 @@
while:label p == q,
pre true,
inv true,
- post p != q,
+ post p <> q,
{
// Redundant, but shows the labeled jump syntax.
continue:label
@@ -191,7 +191,7 @@
"i = 10 | 3": 11,
"i = 10 ^ 3": 9,
- "b = 10 != 3": 1,
+ "b = 10 <> 3": 1,
"b = 10 < 3": 0,
"b = 10 <= 3": 0,
"b = 10 == 3": 0,
diff --git a/lang/token/list.go b/lang/token/list.go
index 4ea4afb..2fca633 100644
--- a/lang/token/list.go
+++ b/lang/token/list.go
@@ -659,7 +659,7 @@
IDTildeSatPlus: "~sat+",
IDTildeSatMinus: "~sat-",
- IDNotEq: "!=",
+ IDNotEq: "<>",
IDLessThan: "<",
IDLessEq: "<=",
IDEqEq: "==",
@@ -954,6 +954,7 @@
'}': IDCloseCurly,
',': IDComma,
+ '!': IDExclam,
'?': IDQuestion,
':': IDColon,
';': IDSemicolon,
@@ -975,10 +976,6 @@
{".", IDDotDot},
{"", IDDot},
},
- '!': {
- {"=", IDNotEq},
- {"", IDExclam},
- },
'&': {
{"=", IDAmpEq},
{"", IDAmp},
@@ -1020,6 +1017,7 @@
{"<=", IDShiftLEq},
{"<", IDShiftL},
{"=", IDLessEq},
+ {">", IDNotEq},
{"", IDLessThan},
},
'>': {
diff --git a/std/deflate/decode_deflate.wuffs b/std/deflate/decode_deflate.wuffs
index ce43f78..d5dd5dd 100644
--- a/std/deflate/decode_deflate.wuffs
+++ b/std/deflate/decode_deflate.wuffs
@@ -259,14 +259,14 @@
// TODO: make this "if" into a function invariant?
//
// Ditto for decode_huffman_slow and decode_huffman_fast.
- if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
+ if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
return "#internal error: inconsistent n_bits"
}
this.n_bits = 0
this.bits = 0
length = args.src.read_u32le?()
- if (length.low_bits(n:16) + length.high_bits(n:16)) != 0xFFFF {
+ if (length.low_bits(n:16) + length.high_bits(n:16)) <> 0xFFFF {
return "#inconsistent stored block length"
}
length = length.low_bits(n:16)
@@ -414,7 +414,7 @@
}
// For H-CL, there should be no redirections and all symbols should be
// literals.
- if (table_entry >> 24) != 0x80 {
+ if (table_entry >> 24) <> 0x80 {
return "#internal error: inconsistent Huffman decoder state"
}
table_entry = (table_entry >> 8) & 0xFF
@@ -477,7 +477,7 @@
}
}
- if i != (n_lit + n_dist) {
+ if i <> (n_lit + n_dist) {
return "#bad Huffman code length count"
}
if this.code_lengths[256] == 0 {
@@ -588,7 +588,7 @@
remaining -= counts[i] as base.u32
i += 1
}
- if remaining != 0 {
+ if remaining <> 0 {
// TODO: when is a degenerate Huffman table valid?
return "#bad Huffman code (under-subscribed)"
}
@@ -649,7 +649,7 @@
if i < args.n_codes0 {
return "#internal error: inconsistent Huffman decoder state"
}
- if this.code_lengths[i] != 0 {
+ if this.code_lengths[i] <> 0 {
if offsets[this.code_lengths[i] & 15] >= 320 {
return "#internal error: inconsistent Huffman decoder state"
}
@@ -668,7 +668,7 @@
while true,
inv n_symbols <= 288,
{
- if counts[min_cl] != 0 {
+ if counts[min_cl] <> 0 {
break
}
if min_cl >= 9 {
@@ -680,7 +680,7 @@
while true,
inv n_symbols <= 288,
{
- if counts[max_cl] != 0 {
+ if counts[max_cl] <> 0 {
break
}
if max_cl <= 1 {
@@ -709,7 +709,7 @@
// - this.huffs[0][0b01111] = 0x80000305 (literal, symbols[8]=0x03, code_length=5)
// - this.huffs[0][0b11111] = 0x80001805 (literal, symbols[9]=0x18, code_length=5)
i = 0
- if (n_symbols != (offsets[max_cl] as base.u32)) or (n_symbols != (offsets[15] as base.u32)) {
+ if (n_symbols <> (offsets[max_cl] as base.u32)) or (n_symbols <> (offsets[15] as base.u32)) {
return "#internal error: inconsistent Huffman decoder state"
}
if (args.n_codes0 + (symbols[0] as base.u32)) >= 320 {
@@ -753,7 +753,7 @@
redirect_key = (key >> cl) & 511
key = key.low_bits(n:cl)
- if prev_redirect_key != redirect_key {
+ if prev_redirect_key <> redirect_key {
prev_redirect_key = redirect_key
// Calculate the number of bits needed for the 2nd level table.
diff --git a/std/deflate/decode_huffman_fast.wuffs b/std/deflate/decode_huffman_fast.wuffs
index 53e4672..a459373 100644
--- a/std/deflate/decode_huffman_fast.wuffs
+++ b/std/deflate/decode_huffman_fast.wuffs
@@ -34,7 +34,7 @@
var hlen base.u32[..0x7FFF]
var hdist base.u32
- if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
+ if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
return "#internal error: inconsistent n_bits"
}
@@ -97,18 +97,18 @@
bits >>= table_entry_n_bits
n_bits -= table_entry_n_bits
- if (table_entry >> 31) != 0 {
+ if (table_entry >> 31) <> 0 {
// Literal.
args.dst.write_fast_u8!(x:((table_entry >> 8) & 0xFF) as base.u8)
continue:loop
- } else if (table_entry >> 30) != 0 {
+ } else if (table_entry >> 30) <> 0 {
// No-op; code continues past the if-else chain.
assert args.src.available() >= 8
- } else if (table_entry >> 29) != 0 {
+ } else if (table_entry >> 29) <> 0 {
// End of block.
this.end_of_block = true
break:loop
- } else if (table_entry >> 28) != 0 {
+ } else if (table_entry >> 28) <> 0 {
// Redirect.
// Ensure that we have at least 15 bits of input.
@@ -139,19 +139,19 @@
bits >>= table_entry_n_bits
n_bits -= table_entry_n_bits
- if (table_entry >> 31) != 0 {
+ if (table_entry >> 31) <> 0 {
// Literal.
args.dst.write_fast_u8!(x:((table_entry >> 8) & 0xFF) as base.u8)
continue:loop
- } else if (table_entry >> 30) != 0 {
+ } else if (table_entry >> 30) <> 0 {
// No-op; code continues past the if-else chain.
- } else if (table_entry >> 29) != 0 {
+ } else if (table_entry >> 29) <> 0 {
// End of block.
this.end_of_block = true
break:loop
- } else if (table_entry >> 28) != 0 {
+ } else if (table_entry >> 28) <> 0 {
return "#internal error: inconsistent Huffman decoder state"
- } else if (table_entry >> 27) != 0 {
+ } else if (table_entry >> 27) <> 0 {
return "#bad Huffman code"
} else {
return "#internal error: inconsistent Huffman decoder state"
@@ -160,7 +160,7 @@
// Once again, redundant but explicit assertions.
assert args.src.available() >= 8
- } else if (table_entry >> 27) != 0 {
+ } else if (table_entry >> 27) <> 0 {
return "#bad Huffman code"
} else {
return "#internal error: inconsistent Huffman decoder state"
@@ -257,7 +257,7 @@
}
// For H-D, all symbols should be base_number + extra_bits.
- if (table_entry >> 24) != 0x40 {
+ if (table_entry >> 24) <> 0x40 {
if (table_entry >> 24) == 0x08 {
return "#bad Huffman code"
}
@@ -396,7 +396,7 @@
this.bits = bits & (((1 as base.u32) << n_bits) - 1)
this.n_bits = n_bits
- if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
+ if (this.n_bits >= 8) or ((this.bits >> this.n_bits) <> 0) {
return "#internal error: inconsistent n_bits"
}
}
diff --git a/std/deflate/decode_huffman_slow.wuffs b/std/deflate/decode_huffman_slow.wuffs
index c3a7137..39385fa 100644
--- a/std/deflate/decode_huffman_slow.wuffs
+++ b/std/deflate/decode_huffman_slow.wuffs
@@ -38,7 +38,7 @@
// decode_huffman_*.wuffs files as small as possible, while retaining both
// correctness and performance.
- if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
+ if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
return "#internal error: inconsistent n_bits"
}
@@ -64,17 +64,17 @@
n_bits += 8
}
- if (table_entry >> 31) != 0 {
+ if (table_entry >> 31) <> 0 {
// Literal.
args.dst.write_u8?(x:((table_entry >> 8) & 0xFF) as base.u8)
continue:loop
- } else if (table_entry >> 30) != 0 {
+ } else if (table_entry >> 30) <> 0 {
// No-op; code continues past the if-else chain.
- } else if (table_entry >> 29) != 0 {
+ } else if (table_entry >> 29) <> 0 {
// End of block.
this.end_of_block = true
break:loop
- } else if (table_entry >> 28) != 0 {
+ } else if (table_entry >> 28) <> 0 {
// Redirect.
redir_top = (table_entry >> 8) & 0xFFFF
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
@@ -96,25 +96,25 @@
n_bits += 8
}
- if (table_entry >> 31) != 0 {
+ if (table_entry >> 31) <> 0 {
// Literal.
args.dst.write_u8?(x:((table_entry >> 8) & 0xFF) as base.u8)
continue:loop
- } else if (table_entry >> 30) != 0 {
+ } else if (table_entry >> 30) <> 0 {
// No-op; code continues past the if-else chain.
- } else if (table_entry >> 29) != 0 {
+ } else if (table_entry >> 29) <> 0 {
// End of block.
this.end_of_block = true
break:loop
- } else if (table_entry >> 28) != 0 {
+ } else if (table_entry >> 28) <> 0 {
return "#internal error: inconsistent Huffman decoder state"
- } else if (table_entry >> 27) != 0 {
+ } else if (table_entry >> 27) <> 0 {
return "#bad Huffman code"
} else {
return "#internal error: inconsistent Huffman decoder state"
}
- } else if (table_entry >> 27) != 0 {
+ } else if (table_entry >> 27) <> 0 {
return "#bad Huffman code"
} else {
return "#internal error: inconsistent Huffman decoder state"
@@ -180,7 +180,7 @@
}
// For H-D, all symbols should be base_number + extra_bits.
- if (table_entry >> 24) != 0x40 {
+ if (table_entry >> 24) <> 0x40 {
if (table_entry >> 24) == 0x08 {
return "#bad Huffman code"
}
@@ -287,7 +287,7 @@
this.bits = bits
this.n_bits = n_bits
- if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
+ if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
return "#internal error: inconsistent n_bits"
}
}
diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs
index a6f8f65..38b8271 100644
--- a/std/gif/decode_gif.wuffs
+++ b/std/gif/decode_gif.wuffs
@@ -146,7 +146,7 @@
(this.frame_rect_x1 == this.width) and
(this.frame_rect_y1 == this.height)
- if args.dst != nullptr {
+ if args.dst <> nullptr {
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY magic pixfmt constant.
args.dst.set!(
@@ -217,7 +217,7 @@
if not this.end_of_data {
if this.call_sequence == 0 {
this.decode_image_config?(dst:nullptr, src:args.src)
- } else if this.call_sequence != 1 {
+ } else if this.call_sequence <> 1 {
if this.call_sequence == 2 {
this.skip_frame?(src:args.src)
}
@@ -236,7 +236,7 @@
blend = 2 // 2 is WUFFS_BASE__ANIMATION_BLEND__OPAQUE.
}
- if args.dst != nullptr {
+ if args.dst <> nullptr {
args.dst.update!(bounds:this.util.make_rect_ie_u32(
min_incl_x:this.frame_rect_x0.min(x:this.width),
min_incl_y:this.frame_rect_y0.min(x:this.height),
@@ -258,7 +258,7 @@
// Skip the optional Local Color Table, 3 bytes (RGB) per entry.
flags = args.src.read_u8?()
- if (flags & 0x80) != 0 {
+ if (flags & 0x80) <> 0 {
args.src.skip?(n:(3 as base.u32) << (1 + (flags & 0x07)))
}
// Skip the literal width.
@@ -272,7 +272,7 @@
// TODO: honor args.opts.
pub func decoder.decode_frame?(dst ptr base.pixel_buffer, src base.io_reader, workbuf slice base.u8, opts nptr base.decode_frame_options) {
- if this.call_sequence != 2 {
+ if this.call_sequence <> 2 {
this.decode_frame_config?(dst:nullptr, src:args.src)
}
this.decode_id_part1?(dst:args.dst, src:args.src)
@@ -298,7 +298,7 @@
if not this.restarted {
this.frame_config_io_position = args.src.position()
- } else if this.frame_config_io_position != args.src.position() {
+ } else if this.frame_config_io_position <> args.src.position() {
return base."#bad restart"
} else {
this.restarted = false
@@ -331,8 +331,8 @@
c[i] = args.src.read_u8?()
i += 1
}
- if (c[0] != 0x47) or (c[1] != 0x49) or (c[2] != 0x46) or (c[3] != 0x38) or
- ((c[4] != 0x37) and (c[4] != 0x39)) or (c[5] != 0x61) {
+ if (c[0] <> 0x47) or (c[1] <> 0x49) or (c[2] <> 0x46) or (c[3] <> 0x38) or
+ ((c[4] <> 0x37) and (c[4] <> 0x39)) or (c[5] <> 0x61) {
return "#bad header"
}
}
@@ -353,7 +353,7 @@
args.src.skip?(n:2)
// Read the optional Global Color Table.
- if (flags & 0x80) != 0 {
+ if (flags & 0x80) <> 0 {
num_palette_entries = (1 as base.u32) << (1 + (flags & 0x07))
i = 0
while i < num_palette_entries {
@@ -444,7 +444,7 @@
// as per:
// - http://www.vurdalakov.net/misc/gif/animexts-looping-application-extension
// - http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension
- if block_size != 11 {
+ if block_size <> 11 {
args.src.skip?(n:block_size as base.u32)
break
}
@@ -453,8 +453,8 @@
block_size = 0 // Re-purpose the block_size variable as a counter.
while block_size < 11 {
c = args.src.read_u8?()
- not_animexts = not_animexts or (c != animexts1dot0[block_size])
- not_netscape = not_netscape or (c != netscape2dot0[block_size])
+ not_animexts = not_animexts or (c <> animexts1dot0[block_size])
+ not_netscape = not_netscape or (c <> netscape2dot0[block_size])
block_size += 1
}
if not_animexts and not_netscape {
@@ -464,12 +464,12 @@
// Those 11 bytes should be followed by 0x03, 0x01 and then the loop
// count.
block_size = args.src.read_u8?()
- if block_size != 3 {
+ if block_size <> 3 {
args.src.skip?(n:block_size as base.u32)
break
}
c = args.src.read_u8?()
- if c != 0x01 {
+ if c <> 0x01 {
args.src.skip?(n:2)
break
}
@@ -505,12 +505,12 @@
return "#bad graphic control"
}
c = args.src.read_u8?()
- if c != 4 {
+ if c <> 4 {
return "#bad graphic control"
}
flags = args.src.read_u8?()
- this.gc_has_transparent_index = (flags & 0x01) != 0
+ this.gc_has_transparent_index = (flags & 0x01) <> 0
// Convert the disposal method from GIF's wire format to Wuffs constants.
//
@@ -536,7 +536,7 @@
this.gc_transparent_index = args.src.read_u8?()
c = args.src.read_u8?()
- if c != 0 {
+ if c <> 0 {
return "#bad graphic control"
}
this.seen_graphic_control = true
@@ -584,7 +584,7 @@
var lw base.u8
flags = args.src.read_u8?()
- if (flags & 0x40) != 0 {
+ if (flags & 0x40) <> 0 {
this.interlace = 4
} else {
this.interlace = 0
@@ -592,7 +592,7 @@
// Read the optional Local Color Table.
this.which_palette = 1
- if (flags & 0x80) != 0 {
+ if (flags & 0x80) <> 0 {
num_palette_entries = (1 as base.u32) << (1 + (flags & 0x07))
i = 0
while i < num_palette_entries {
@@ -762,8 +762,8 @@
this.compressed_wi = 0
if (this.dst_y < this.frame_rect_y1) and
- (this.frame_rect_x0 != this.frame_rect_x1) and
- (this.frame_rect_y0 != this.frame_rect_y1) {
+ (this.frame_rect_x0 <> this.frame_rect_x1) and
+ (this.frame_rect_y0 <> this.frame_rect_y1) {
return base."#not enough data"
}
}
@@ -856,7 +856,7 @@
continue
}
- if src_ri != args.src.length() {
+ if src_ri <> args.src.length() {
return "#internal error: inconsistent ri/wi"
}
break
diff --git a/std/gzip/decode_gzip.wuffs b/std/gzip/decode_gzip.wuffs
index ff8302c..297b191 100644
--- a/std/gzip/decode_gzip.wuffs
+++ b/std/gzip/decode_gzip.wuffs
@@ -54,15 +54,15 @@
// Read the header.
c = args.src.read_u8?()
- if c != 0x1F {
+ if c <> 0x1F {
return "#bad header"
}
c = args.src.read_u8?()
- if c != 0x8B {
+ if c <> 0x8B {
return "#bad header"
}
c = args.src.read_u8?()
- if c != 0x08 {
+ if c <> 0x08 {
return "#bad compression method"
}
flags = args.src.read_u8?()
@@ -70,7 +70,7 @@
args.src.skip?(n:6)
// Handle FEXTRA.
- if (flags & 0x04) != 0 {
+ if (flags & 0x04) <> 0 {
xlen = args.src.read_u16le?()
args.src.skip?(n:xlen as base.u32)
}
@@ -80,7 +80,7 @@
// TODO: API for returning the header's FNAME field. This might require
// converting ISO 8859-1 to UTF-8. We may also want to cap the UTF-8
// filename length to NAME_MAX, which is 255.
- if (flags & 0x08) != 0 {
+ if (flags & 0x08) <> 0 {
while true {
c = args.src.read_u8?()
if c == 0 {
@@ -90,7 +90,7 @@
}
// Handle FCOMMENT.
- if (flags & 0x10) != 0 {
+ if (flags & 0x10) <> 0 {
while true {
c = args.src.read_u8?()
if c == 0 {
@@ -100,12 +100,12 @@
}
// Handle FHCRC.
- if (flags & 0x02) != 0 {
+ if (flags & 0x02) <> 0 {
args.src.skip?(n:2)
}
// Reserved flags bits must be zero.
- if (flags & 0xE0) != 0 {
+ if (flags & 0xE0) <> 0 {
return "#bad encoding flags"
}
@@ -125,7 +125,7 @@
checksum_want = args.src.read_u32le?()
decoded_length_want = args.src.read_u32le?()
if (not this.ignore_checksum) and
- ((checksum_got != checksum_want) or (decoded_length_got != decoded_length_want)) {
+ ((checksum_got <> checksum_want) or (decoded_length_got <> decoded_length_want)) {
return "#bad checksum"
}
}
diff --git a/std/lzw/decode_lzw.wuffs b/std/lzw/decode_lzw.wuffs
index 159287f..7f3698c 100644
--- a/std/lzw/decode_lzw.wuffs
+++ b/std/lzw/decode_lzw.wuffs
@@ -204,7 +204,7 @@
lm1_a = (this.lm1s[prev_code] ~mod+ 1) & 4095
this.lm1s[save_code] = lm1_a
- if (lm1_a % 8) != 0 {
+ if (lm1_a % 8) <> 0 {
this.prefixes[save_code] = this.prefixes[prev_code]
this.suffixes[save_code] = this.suffixes[prev_code]
this.suffixes[save_code][lm1_a % 8] = code as base.u8
@@ -277,7 +277,7 @@
lm1_b = (this.lm1s[prev_code] ~mod+ 1) & 4095
this.lm1s[save_code] = lm1_b
- if (lm1_b % 8) != 0 {
+ if (lm1_b % 8) <> 0 {
this.prefixes[save_code] = this.prefixes[prev_code]
this.suffixes[save_code] = this.suffixes[prev_code]
this.suffixes[save_code][lm1_b % 8] = first_byte
@@ -310,7 +310,7 @@
// Rewind args.src, if we're not in "$short read" and we've read too many
// bits.
- if this.read_from_return_value != 2 {
+ if this.read_from_return_value <> 2 {
while n_bits >= 8 {
n_bits -= 8
if args.src.can_undo_byte() {
diff --git a/std/zlib/decode_zlib.wuffs b/std/zlib/decode_zlib.wuffs
index 5267121..b7b5817 100644
--- a/std/zlib/decode_zlib.wuffs
+++ b/std/zlib/decode_zlib.wuffs
@@ -51,16 +51,16 @@
var checksum_want base.u32
x = args.src.read_u16be?()
- if ((x >> 8) & 0x0F) != 0x08 {
+ if ((x >> 8) & 0x0F) <> 0x08 {
return "#bad compression method"
}
if (x >> 12) > 0x07 {
return "#bad compression window size"
}
- if (x & 0x20) != 0 {
+ if (x & 0x20) <> 0 {
return "#TODO: unsupported preset dictionary"
}
- if (x % 31) != 0 {
+ if (x % 31) <> 0 {
return "#bad parity check"
}
@@ -77,7 +77,7 @@
yield? status
}
checksum_want = args.src.read_u32be?()
- if (not this.ignore_checksum) and (checksum_got != checksum_want) {
+ if (not this.ignore_checksum) and (checksum_got <> checksum_want) {
return "#bad checksum"
}
}