mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Rename [i..j] to [i ..= j], the same as Rust
This commit is contained in:
1 parent
18c6e5716a
commit
d501daddc3
18 files changed
+219
-206
No files matched your search
+3
-3
@@ -636,7 +636,7 @@ func NewJump(keyword t.ID, label t.ID) *Jump {
|
||||
// MaxTypeExprDepth is an advisory limit for a TypeExpr's recursion depth.
|
||||
const MaxTypeExprDepth = 63
|
||||
|
||||
// TypeExpr is a type expression, such as "base.u32", "base.u32[..8]", "foo",
|
||||
// TypeExpr is a type expression, such as "base.u32", "base.u32[..= 8]", "foo",
|
||||
// "pkg.bar", "ptr T", "array[8] T", "slice T" or "table T":
|
||||
// - ID0: <0|IDArray|IDFunc|IDNptr|IDPtr|IDSlice|IDTable>
|
||||
// - ID1: <0|pkg>
|
||||
@@ -662,8 +662,8 @@ const MaxTypeExprDepth = 63
|
||||
// A zero ID0 means a (possibly package-qualified) type like "pkg.foo" or
|
||||
// "foo". ID1 is the "pkg" or zero, ID2 is the "foo".
|
||||
//
|
||||
// Numeric types can be refined as "foo[LHS..MHS]". LHS and MHS are Expr's,
|
||||
// possibly nil. For example, the LHS for "base.u32[..4095]" is nil.
|
||||
// Numeric types can be refined as "foo[LHS ..= MHS]". LHS and MHS are Expr's,
|
||||
// possibly nil. For example, the LHS for "base.u32[..= 4095]" is nil.
|
||||
//
|
||||
// TODO: struct types, list types, nptr vs ptr.
|
||||
type TypeExpr Node
|
||||
|
||||
+9
-3
@@ -234,9 +234,15 @@ func (n *TypeExpr) appendStr(buf []byte, tm *t.Map, depth uint32) []byte {
|
||||
}
|
||||
if n.Min() != nil || n.Max() != nil {
|
||||
buf = append(buf, '[')
|
||||
buf = n.Min().appendStr(buf, tm, false, 0)
|
||||
buf = append(buf, ".."...)
|
||||
buf = n.Max().appendStr(buf, tm, false, 0)
|
||||
if n.Min() != nil {
|
||||
buf = n.Min().appendStr(buf, tm, false, 0)
|
||||
buf = append(buf, ' ')
|
||||
}
|
||||
buf = append(buf, "..="...)
|
||||
if n.Max() != nil {
|
||||
buf = append(buf, ' ')
|
||||
buf = n.Max().appendStr(buf, tm, false, 0)
|
||||
}
|
||||
buf = append(buf, ']')
|
||||
}
|
||||
return buf
|
||||
|
||||
@@ -62,13 +62,13 @@ func TestString(tt *testing.T) {
|
||||
"x as base.u32",
|
||||
"x as T",
|
||||
"x as T",
|
||||
"x as T[i..]",
|
||||
"x as T[..j]",
|
||||
"x as T[i..j]",
|
||||
"x as T[i ..=]",
|
||||
"x as T[..= j]",
|
||||
"x as T[i ..= j]",
|
||||
"x as pkg.T",
|
||||
"x as ptr T",
|
||||
"x as array[4] T",
|
||||
"x as array[8 + (2 * N)] ptr array[4] ptr pkg.T[i..j]",
|
||||
"x as array[8 + (2 * N)] ptr array[4] ptr pkg.T[i ..= j]",
|
||||
}
|
||||
|
||||
tm := &t.Map{}
|
||||
|
||||
Reference in new issue
Block a user