mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
Add ~sat+ and ~sat-
This commit is contained in:
1 parent
6fb1abc739
commit
6d167b7424
7 files changed
+162
-49
No files matched your search
@@ -462,27 +462,67 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *gen) writeExprUnaryOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
|
func (g *gen) writeExprUnaryOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
|
||||||
b.writes(cOpNames[0xFF&n.Operator()])
|
op := n.Operator()
|
||||||
|
opName := cOpNames[0xFF&op]
|
||||||
|
if opName == "" {
|
||||||
|
return fmt.Errorf("unrecognized operator %q", op.AmbiguousForm().Str(g.tm))
|
||||||
|
}
|
||||||
|
|
||||||
|
b.writes(opName)
|
||||||
return g.writeExpr(b, n.RHS().Expr(), rp, parenthesesMandatory, depth)
|
return g.writeExpr(b, n.RHS().Expr(), rp, parenthesesMandatory, depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gen) writeExprBinaryOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
|
func (g *gen) writeExprBinaryOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
|
||||||
|
opName, tilde := "", false
|
||||||
|
|
||||||
op := n.Operator()
|
op := n.Operator()
|
||||||
if op == t.IDXBinaryAs {
|
switch op {
|
||||||
|
case t.IDXBinaryTildeSatPlus, t.IDXBinaryTildeSatMinus:
|
||||||
|
uType := ""
|
||||||
|
qid := n.MType().QID()
|
||||||
|
switch qid[1] {
|
||||||
|
case t.IDU8:
|
||||||
|
uType = "8"
|
||||||
|
case t.IDU16:
|
||||||
|
uType = "16"
|
||||||
|
case t.IDU32:
|
||||||
|
uType = "32"
|
||||||
|
case t.IDU64:
|
||||||
|
uType = "64"
|
||||||
|
}
|
||||||
|
if qid[0] != t.IDBase || uType == "" {
|
||||||
|
return fmt.Errorf("unsupported tilde-operator type %q", n.MType().Str(g.tm))
|
||||||
|
}
|
||||||
|
|
||||||
|
uOp := "add"
|
||||||
|
if op != t.IDXBinaryTildeSatPlus {
|
||||||
|
uOp = "sub"
|
||||||
|
}
|
||||||
|
b.printf("wuffs_base__u%s__sat_%s", uType, uOp)
|
||||||
|
opName, tilde = ",", true
|
||||||
|
|
||||||
|
case t.IDXBinaryAs:
|
||||||
return g.writeExprAs(b, n.LHS().Expr(), n.RHS().TypeExpr(), rp, depth)
|
return g.writeExprAs(b, n.LHS().Expr(), n.RHS().TypeExpr(), rp, depth)
|
||||||
|
|
||||||
|
default:
|
||||||
|
opName = cOpNames[0xFF&op]
|
||||||
|
if opName == "" {
|
||||||
|
return fmt.Errorf("unrecognized operator %q", op.AmbiguousForm().Str(g.tm))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if pp == parenthesesMandatory {
|
|
||||||
|
if pp == parenthesesMandatory || tilde {
|
||||||
b.writeb('(')
|
b.writeb('(')
|
||||||
}
|
}
|
||||||
if err := g.writeExpr(b, n.LHS().Expr(), rp, parenthesesMandatory, depth); err != nil {
|
if err := g.writeExpr(b, n.LHS().Expr(), rp, parenthesesMandatory, depth); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// TODO: does KeyXBinaryAmpHat need special consideration?
|
// TODO: does KeyXBinaryAmpHat need special consideration?
|
||||||
b.writes(cOpNames[0xFF&op])
|
b.writes(opName)
|
||||||
if err := g.writeExpr(b, n.RHS().Expr(), rp, parenthesesMandatory, depth); err != nil {
|
if err := g.writeExpr(b, n.RHS().Expr(), rp, parenthesesMandatory, depth); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if pp == parenthesesMandatory {
|
if pp == parenthesesMandatory || tilde {
|
||||||
b.writeb(')')
|
b.writeb(')')
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -504,10 +544,15 @@ func (g *gen) writeExprAs(b *buffer, lhs *a.Expr, rhs *a.TypeExpr, rp replacemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *gen) writeExprAssociativeOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
|
func (g *gen) writeExprAssociativeOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
|
||||||
|
op := n.Operator()
|
||||||
|
opName := cOpNames[0xFF&op]
|
||||||
|
if opName == "" {
|
||||||
|
return fmt.Errorf("unrecognized operator %q", op.AmbiguousForm().Str(g.tm))
|
||||||
|
}
|
||||||
|
|
||||||
if pp == parenthesesMandatory {
|
if pp == parenthesesMandatory {
|
||||||
b.writeb('(')
|
b.writeb('(')
|
||||||
}
|
}
|
||||||
opName := cOpNames[0xFF&n.Operator()]
|
|
||||||
for i, o := range n.Args() {
|
for i, o := range n.Args() {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
b.writes(opName)
|
b.writes(opName)
|
||||||
@@ -636,12 +681,14 @@ var cOpNames = [256]string{
|
|||||||
t.IDShiftLEq: " <<= ",
|
t.IDShiftLEq: " <<= ",
|
||||||
t.IDShiftREq: " >>= ",
|
t.IDShiftREq: " >>= ",
|
||||||
t.IDAmpEq: " &= ",
|
t.IDAmpEq: " &= ",
|
||||||
t.IDAmpHatEq: " no_such_amp_hat_C_operator ",
|
t.IDAmpHatEq: " no_such_C_operator ",
|
||||||
t.IDPipeEq: " |= ",
|
t.IDPipeEq: " |= ",
|
||||||
t.IDHatEq: " ^= ",
|
t.IDHatEq: " ^= ",
|
||||||
t.IDPercentEq: " %= ",
|
t.IDPercentEq: " %= ",
|
||||||
t.IDTildeModPlusEq: " += ",
|
t.IDTildeModPlusEq: " += ",
|
||||||
t.IDTildeModMinusEq: " -= ",
|
t.IDTildeModMinusEq: " -= ",
|
||||||
|
t.IDTildeSatPlusEq: " no_such_C_operator ",
|
||||||
|
t.IDTildeSatMinusEq: " no_such_C_operator ",
|
||||||
|
|
||||||
t.IDXUnaryPlus: " + ",
|
t.IDXUnaryPlus: " + ",
|
||||||
t.IDXUnaryMinus: " - ",
|
t.IDXUnaryMinus: " - ",
|
||||||
@@ -656,12 +703,14 @@ var cOpNames = [256]string{
|
|||||||
t.IDXBinaryShiftL: " << ",
|
t.IDXBinaryShiftL: " << ",
|
||||||
t.IDXBinaryShiftR: " >> ",
|
t.IDXBinaryShiftR: " >> ",
|
||||||
t.IDXBinaryAmp: " & ",
|
t.IDXBinaryAmp: " & ",
|
||||||
t.IDXBinaryAmpHat: " no_such_amp_hat_C_operator ",
|
t.IDXBinaryAmpHat: " no_such_C_operator ",
|
||||||
t.IDXBinaryPipe: " | ",
|
t.IDXBinaryPipe: " | ",
|
||||||
t.IDXBinaryHat: " ^ ",
|
t.IDXBinaryHat: " ^ ",
|
||||||
t.IDXBinaryPercent: " % ",
|
t.IDXBinaryPercent: " % ",
|
||||||
t.IDXBinaryTildeModPlus: " + ",
|
t.IDXBinaryTildeModPlus: " + ",
|
||||||
t.IDXBinaryTildeModMinus: " - ",
|
t.IDXBinaryTildeModMinus: " - ",
|
||||||
|
t.IDXBinaryTildeSatPlus: " no_such_C_operator ",
|
||||||
|
t.IDXBinaryTildeSatMinus: " no_such_C_operator ",
|
||||||
t.IDXBinaryNotEq: " != ",
|
t.IDXBinaryNotEq: " != ",
|
||||||
t.IDXBinaryLessThan: " < ",
|
t.IDXBinaryLessThan: " < ",
|
||||||
t.IDXBinaryLessEq: " <= ",
|
t.IDXBinaryLessEq: " <= ",
|
||||||
@@ -670,7 +719,7 @@ var cOpNames = [256]string{
|
|||||||
t.IDXBinaryGreaterThan: " > ",
|
t.IDXBinaryGreaterThan: " > ",
|
||||||
t.IDXBinaryAnd: " && ",
|
t.IDXBinaryAnd: " && ",
|
||||||
t.IDXBinaryOr: " || ",
|
t.IDXBinaryOr: " || ",
|
||||||
t.IDXBinaryAs: " no_such_as_C_operator ",
|
t.IDXBinaryAs: " no_such_C_operator ",
|
||||||
|
|
||||||
t.IDXAssociativePlus: " + ",
|
t.IDXAssociativePlus: " + ",
|
||||||
t.IDXAssociativeStar: " * ",
|
t.IDXAssociativeStar: " * ",
|
||||||
|
|||||||
@@ -81,8 +81,13 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
|||||||
if err := g.writeExpr(b, n.LHS(), replaceCallSuspendibles, parenthesesMandatory, depth); err != nil {
|
if err := g.writeExpr(b, n.LHS(), replaceCallSuspendibles, parenthesesMandatory, depth); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// TODO: does KeyAmpHatEq need special consideration?
|
// TODO: `~sat+=`, `~sat-=` and `&^=` need special consideration.
|
||||||
b.writes(cOpNames[0xFF&n.Operator()])
|
op := n.Operator()
|
||||||
|
opName := cOpNames[0xFF&op]
|
||||||
|
if opName == "" {
|
||||||
|
return fmt.Errorf("unrecognized operator %q", op.AmbiguousForm().Str(g.tm))
|
||||||
|
}
|
||||||
|
b.writes(opName)
|
||||||
if err := g.writeExpr(b, n.RHS(), replaceCallSuspendibles, parenthesesMandatory, depth); err != nil {
|
if err := g.writeExpr(b, n.RHS(), replaceCallSuspendibles, parenthesesMandatory, depth); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
- Spun `std/zlib` out of `std/flate`.
|
- Spun `std/zlib` out of `std/flate`.
|
||||||
- Let the `std/zlib` decoder ignore checksums.
|
- Let the `std/zlib` decoder ignore checksums.
|
||||||
- Renamed `std/flate` to `std/deflate`.
|
- Renamed `std/flate` to `std/deflate`.
|
||||||
- Renamed `~+` to `~mod+`; add `~mod-`.
|
- Renamed `~+` to `~mod+`; added `~mod-`, `~sat+` and `~sat-`.
|
||||||
- Renamed `[N] T` and `[] T` types to `array[N] T` and `slice T`.
|
- Renamed `[N] T` and `[] T` types to `array[N] T` and `slice T`.
|
||||||
- Renamed `iterate.N` to `iterate[N]`.
|
- Renamed `iterate.N` to `iterate[N]`.
|
||||||
- Renamed `buf1`, `reader1`, etc to `io_buffer`, `io_reader`, etc.
|
- Renamed `buf1`, `reader1`, etc to `io_buffer`, `io_reader`, etc.
|
||||||
|
|||||||
@@ -171,6 +171,8 @@ var opStrings = [256]string{
|
|||||||
t.IDXBinaryHat: " ^ ",
|
t.IDXBinaryHat: " ^ ",
|
||||||
t.IDXBinaryTildeModPlus: " ~mod+ ",
|
t.IDXBinaryTildeModPlus: " ~mod+ ",
|
||||||
t.IDXBinaryTildeModMinus: " ~mod- ",
|
t.IDXBinaryTildeModMinus: " ~mod- ",
|
||||||
|
t.IDXBinaryTildeSatPlus: " ~sat+ ",
|
||||||
|
t.IDXBinaryTildeSatMinus: " ~sat- ",
|
||||||
t.IDXBinaryNotEq: " != ",
|
t.IDXBinaryNotEq: " != ",
|
||||||
t.IDXBinaryLessThan: " < ",
|
t.IDXBinaryLessThan: " < ",
|
||||||
t.IDXBinaryLessEq: " <= ",
|
t.IDXBinaryLessEq: " <= ",
|
||||||
|
|||||||
+55
-20
@@ -1003,6 +1003,32 @@ func (q *checker) bcheckExprUnaryOp(n *a.Expr, depth uint32) (*big.Int, *big.Int
|
|||||||
return nil, nil, fmt.Errorf("check: unrecognized token (0x%X) for bcheckExprUnaryOp", n.Operator())
|
return nil, nil, fmt.Errorf("check: unrecognized token (0x%X) for bcheckExprUnaryOp", n.Operator())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *checker) bcheckExprXBinaryPlus(lhs *a.Expr, lMin *big.Int, lMax *big.Int, rhs *a.Expr, rMin *big.Int, rMax *big.Int) (*big.Int, *big.Int, error) {
|
||||||
|
return big.NewInt(0).Add(lMin, rMin), big.NewInt(0).Add(lMax, rMax), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *checker) bcheckExprXBinaryMinus(lhs *a.Expr, lMin *big.Int, lMax *big.Int, rhs *a.Expr, rMin *big.Int, rMax *big.Int) (*big.Int, *big.Int, error) {
|
||||||
|
nMin := big.NewInt(0).Sub(lMin, rMax)
|
||||||
|
nMax := big.NewInt(0).Sub(lMax, rMin)
|
||||||
|
for _, x := range q.facts {
|
||||||
|
xOp, xLHS, xRHS := parseBinaryOp(x)
|
||||||
|
if !lhs.Eq(xLHS) || !rhs.Eq(xRHS) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
switch xOp {
|
||||||
|
case t.IDXBinaryLessThan:
|
||||||
|
nMax = min(nMax, minusOne)
|
||||||
|
case t.IDXBinaryLessEq:
|
||||||
|
nMax = min(nMax, zero)
|
||||||
|
case t.IDXBinaryGreaterEq:
|
||||||
|
nMin = max(nMin, zero)
|
||||||
|
case t.IDXBinaryGreaterThan:
|
||||||
|
nMin = max(nMin, one)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nMin, nMax, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (q *checker) bcheckExprBinaryOp(op t.ID, lhs *a.Expr, rhs *a.Expr, depth uint32) (*big.Int, *big.Int, error) {
|
func (q *checker) bcheckExprBinaryOp(op t.ID, lhs *a.Expr, rhs *a.Expr, depth uint32) (*big.Int, *big.Int, error) {
|
||||||
lMin, lMax, err := q.bcheckExpr(lhs, depth)
|
lMin, lMax, err := q.bcheckExpr(lhs, depth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1019,28 +1045,10 @@ func (q *checker) bcheckExprBinaryOp1(op t.ID, lhs *a.Expr, lMin *big.Int, lMax
|
|||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
case t.IDXBinaryPlus:
|
case t.IDXBinaryPlus:
|
||||||
return big.NewInt(0).Add(lMin, rMin), big.NewInt(0).Add(lMax, rMax), nil
|
return q.bcheckExprXBinaryPlus(lhs, lMin, lMax, rhs, rMin, rMax)
|
||||||
|
|
||||||
case t.IDXBinaryMinus:
|
case t.IDXBinaryMinus:
|
||||||
nMin := big.NewInt(0).Sub(lMin, rMax)
|
return q.bcheckExprXBinaryMinus(lhs, lMin, lMax, rhs, rMin, rMax)
|
||||||
nMax := big.NewInt(0).Sub(lMax, rMin)
|
|
||||||
for _, x := range q.facts {
|
|
||||||
xOp, xLHS, xRHS := parseBinaryOp(x)
|
|
||||||
if !lhs.Eq(xLHS) || !rhs.Eq(xRHS) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
switch xOp {
|
|
||||||
case t.IDXBinaryLessThan:
|
|
||||||
nMax = min(nMax, minusOne)
|
|
||||||
case t.IDXBinaryLessEq:
|
|
||||||
nMax = min(nMax, zero)
|
|
||||||
case t.IDXBinaryGreaterEq:
|
|
||||||
nMin = max(nMin, zero)
|
|
||||||
case t.IDXBinaryGreaterThan:
|
|
||||||
nMin = max(nMin, one)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nMin, nMax, nil
|
|
||||||
|
|
||||||
case t.IDXBinaryStar:
|
case t.IDXBinaryStar:
|
||||||
// TODO: handle multiplication by negative numbers. Note that this
|
// TODO: handle multiplication by negative numbers. Note that this
|
||||||
@@ -1132,6 +1140,33 @@ func (q *checker) bcheckExprBinaryOp1(op t.ID, lhs *a.Expr, lMin *big.Int, lMax
|
|||||||
return b[0], b[1], nil
|
return b[0], b[1], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case t.IDXBinaryTildeSatPlus, t.IDXBinaryTildeSatMinus:
|
||||||
|
typ := lhs.MType()
|
||||||
|
if typ.IsIdeal() {
|
||||||
|
typ = rhs.MType()
|
||||||
|
}
|
||||||
|
if qid := typ.QID(); qid[0] == t.IDBase {
|
||||||
|
b := numTypeBounds[qid[1]]
|
||||||
|
|
||||||
|
nFunc := (*checker).bcheckExprXBinaryPlus
|
||||||
|
if op != t.IDXBinaryTildeSatPlus {
|
||||||
|
nFunc = (*checker).bcheckExprXBinaryMinus
|
||||||
|
}
|
||||||
|
nMin, nMax, err := nFunc(q, lhs, lMin, lMax, rhs, rMin, rMax)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if op == t.IDXBinaryTildeSatPlus {
|
||||||
|
nMin = min(nMin, b[1])
|
||||||
|
nMax = min(nMax, b[1])
|
||||||
|
} else {
|
||||||
|
nMin = max(nMin, b[0])
|
||||||
|
nMax = max(nMax, b[0])
|
||||||
|
}
|
||||||
|
return nMin, nMax, nil
|
||||||
|
}
|
||||||
|
|
||||||
case t.IDXBinaryNotEq, t.IDXBinaryLessThan, t.IDXBinaryLessEq, t.IDXBinaryEqEq,
|
case t.IDXBinaryNotEq, t.IDXBinaryLessThan, t.IDXBinaryLessEq, t.IDXBinaryEqEq,
|
||||||
t.IDXBinaryGreaterEq, t.IDXBinaryGreaterThan, t.IDXBinaryAnd, t.IDXBinaryOr:
|
t.IDXBinaryGreaterEq, t.IDXBinaryGreaterThan, t.IDXBinaryAnd, t.IDXBinaryOr:
|
||||||
return zero, one, nil
|
return zero, one, nil
|
||||||
|
|||||||
+5
-3
@@ -282,7 +282,7 @@ func (q *checker) tcheckAssign(n *a.Assign) error {
|
|||||||
n.Operator().Str(q.tm), rhs.Str(q.tm), rTyp.Str(q.tm))
|
n.Operator().Str(q.tm), rhs.Str(q.tm), rTyp.Str(q.tm))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
case t.IDTildeModPlusEq, t.IDTildeModMinusEq:
|
case t.IDTildeModPlusEq, t.IDTildeModMinusEq, t.IDTildeSatPlusEq, t.IDTildeSatMinusEq:
|
||||||
if !lTyp.IsUnsignedInteger() {
|
if !lTyp.IsUnsignedInteger() {
|
||||||
return fmt.Errorf("check: assignment %q: %q, of type %q, does not have unsigned integer type",
|
return fmt.Errorf("check: assignment %q: %q, of type %q, does not have unsigned integer type",
|
||||||
n.Operator().Str(q.tm), lhs.Str(q.tm), lTyp.Str(q.tm))
|
n.Operator().Str(q.tm), lhs.Str(q.tm), lTyp.Str(q.tm))
|
||||||
@@ -810,7 +810,8 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus:
|
case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus,
|
||||||
|
t.IDXBinaryTildeSatPlus, t.IDXBinaryTildeSatMinus:
|
||||||
typ := lTyp
|
typ := lTyp
|
||||||
if typ.IsIdeal() {
|
if typ.IsIdeal() {
|
||||||
typ = rTyp
|
typ = rTyp
|
||||||
@@ -890,7 +891,8 @@ func evalConstValueBinaryOp(tm *t.Map, n *a.Expr, l *big.Int, r *big.Int) (*big.
|
|||||||
return nil, fmt.Errorf("check: division by zero in const expression %q", n.Str(tm))
|
return nil, fmt.Errorf("check: division by zero in const expression %q", n.Str(tm))
|
||||||
}
|
}
|
||||||
return big.NewInt(0).Mod(l, r), nil
|
return big.NewInt(0).Mod(l, r), nil
|
||||||
case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus:
|
case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus,
|
||||||
|
t.IDXBinaryTildeSatPlus, t.IDXBinaryTildeSatMinus:
|
||||||
return nil, fmt.Errorf("check: cannot apply tilde-operators to ideal numbers")
|
return nil, fmt.Errorf("check: cannot apply tilde-operators to ideal numbers")
|
||||||
case t.IDXBinaryNotEq:
|
case t.IDXBinaryNotEq:
|
||||||
return btoi(l.Cmp(r) != 0), nil
|
return btoi(l.Cmp(r) != 0), nil
|
||||||
|
|||||||
+34
-14
@@ -209,6 +209,8 @@ const (
|
|||||||
IDPercentEq = ID(0x1B)
|
IDPercentEq = ID(0x1B)
|
||||||
IDTildeModPlusEq = ID(0x1C)
|
IDTildeModPlusEq = ID(0x1C)
|
||||||
IDTildeModMinusEq = ID(0x1D)
|
IDTildeModMinusEq = ID(0x1D)
|
||||||
|
IDTildeSatPlusEq = ID(0x1E)
|
||||||
|
IDTildeSatMinusEq = ID(0x1F)
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -232,6 +234,8 @@ const (
|
|||||||
IDPercent = ID(0x2B)
|
IDPercent = ID(0x2B)
|
||||||
IDTildeModPlus = ID(0x2C)
|
IDTildeModPlus = ID(0x2C)
|
||||||
IDTildeModMinus = ID(0x2D)
|
IDTildeModMinus = ID(0x2D)
|
||||||
|
IDTildeSatPlus = ID(0x2E)
|
||||||
|
IDTildeSatMinus = ID(0x2F)
|
||||||
|
|
||||||
IDNotEq = ID(0x30)
|
IDNotEq = ID(0x30)
|
||||||
IDLessThan = ID(0x31)
|
IDLessThan = ID(0x31)
|
||||||
@@ -268,17 +272,19 @@ const (
|
|||||||
IDXBinaryPipe = ID(0x50)
|
IDXBinaryPipe = ID(0x50)
|
||||||
IDXBinaryHat = ID(0x51)
|
IDXBinaryHat = ID(0x51)
|
||||||
IDXBinaryPercent = ID(0x52)
|
IDXBinaryPercent = ID(0x52)
|
||||||
IDXBinaryNotEq = ID(0x53)
|
IDXBinaryTildeModPlus = ID(0x53)
|
||||||
IDXBinaryLessThan = ID(0x54)
|
IDXBinaryTildeModMinus = ID(0x54)
|
||||||
IDXBinaryLessEq = ID(0x55)
|
IDXBinaryTildeSatPlus = ID(0x55)
|
||||||
IDXBinaryEqEq = ID(0x56)
|
IDXBinaryTildeSatMinus = ID(0x56)
|
||||||
IDXBinaryGreaterEq = ID(0x57)
|
IDXBinaryNotEq = ID(0x57)
|
||||||
IDXBinaryGreaterThan = ID(0x58)
|
IDXBinaryLessThan = ID(0x58)
|
||||||
IDXBinaryAnd = ID(0x59)
|
IDXBinaryLessEq = ID(0x59)
|
||||||
IDXBinaryOr = ID(0x5A)
|
IDXBinaryEqEq = ID(0x5A)
|
||||||
IDXBinaryAs = ID(0x5B)
|
IDXBinaryGreaterEq = ID(0x5B)
|
||||||
IDXBinaryTildeModPlus = ID(0x5C)
|
IDXBinaryGreaterThan = ID(0x5C)
|
||||||
IDXBinaryTildeModMinus = ID(0x5D)
|
IDXBinaryAnd = ID(0x5D)
|
||||||
|
IDXBinaryOr = ID(0x5E)
|
||||||
|
IDXBinaryAs = ID(0x5F)
|
||||||
|
|
||||||
IDXAssociativePlus = ID(0x60)
|
IDXAssociativePlus = ID(0x60)
|
||||||
IDXAssociativeStar = ID(0x61)
|
IDXAssociativeStar = ID(0x61)
|
||||||
@@ -444,6 +450,8 @@ var builtInsByID = [nBuiltInIDs]string{
|
|||||||
IDPercentEq: "%=",
|
IDPercentEq: "%=",
|
||||||
IDTildeModPlusEq: "~mod+=",
|
IDTildeModPlusEq: "~mod+=",
|
||||||
IDTildeModMinusEq: "~mod-=",
|
IDTildeModMinusEq: "~mod-=",
|
||||||
|
IDTildeSatPlusEq: "~sat+=",
|
||||||
|
IDTildeSatMinusEq: "~sat-=",
|
||||||
|
|
||||||
IDPlus: "+",
|
IDPlus: "+",
|
||||||
IDMinus: "-",
|
IDMinus: "-",
|
||||||
@@ -458,6 +466,8 @@ var builtInsByID = [nBuiltInIDs]string{
|
|||||||
IDPercent: "%",
|
IDPercent: "%",
|
||||||
IDTildeModPlus: "~mod+",
|
IDTildeModPlus: "~mod+",
|
||||||
IDTildeModMinus: "~mod-",
|
IDTildeModMinus: "~mod-",
|
||||||
|
IDTildeSatPlus: "~sat+",
|
||||||
|
IDTildeSatMinus: "~sat-",
|
||||||
|
|
||||||
IDNotEq: "!=",
|
IDNotEq: "!=",
|
||||||
IDLessThan: "<",
|
IDLessThan: "<",
|
||||||
@@ -684,6 +694,10 @@ var lexers = [nBuiltInIDs][]suffixLexer{
|
|||||||
{"mod+", IDTildeModPlus},
|
{"mod+", IDTildeModPlus},
|
||||||
{"mod-=", IDTildeModMinusEq},
|
{"mod-=", IDTildeModMinusEq},
|
||||||
{"mod-", IDTildeModMinus},
|
{"mod-", IDTildeModMinus},
|
||||||
|
{"sat+=", IDTildeSatPlusEq},
|
||||||
|
{"sat+", IDTildeSatPlus},
|
||||||
|
{"sat-=", IDTildeSatMinusEq},
|
||||||
|
{"sat-", IDTildeSatMinus},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,6 +719,10 @@ var ambiguousForms = [nBuiltInIDs]ID{
|
|||||||
IDXBinaryPipe: IDPipe,
|
IDXBinaryPipe: IDPipe,
|
||||||
IDXBinaryHat: IDHat,
|
IDXBinaryHat: IDHat,
|
||||||
IDXBinaryPercent: IDPercent,
|
IDXBinaryPercent: IDPercent,
|
||||||
|
IDXBinaryTildeModPlus: IDTildeModPlus,
|
||||||
|
IDXBinaryTildeModMinus: IDTildeModMinus,
|
||||||
|
IDXBinaryTildeSatPlus: IDTildeSatPlus,
|
||||||
|
IDXBinaryTildeSatMinus: IDTildeSatMinus,
|
||||||
IDXBinaryNotEq: IDNotEq,
|
IDXBinaryNotEq: IDNotEq,
|
||||||
IDXBinaryLessThan: IDLessThan,
|
IDXBinaryLessThan: IDLessThan,
|
||||||
IDXBinaryLessEq: IDLessEq,
|
IDXBinaryLessEq: IDLessEq,
|
||||||
@@ -714,8 +732,6 @@ var ambiguousForms = [nBuiltInIDs]ID{
|
|||||||
IDXBinaryAnd: IDAnd,
|
IDXBinaryAnd: IDAnd,
|
||||||
IDXBinaryOr: IDOr,
|
IDXBinaryOr: IDOr,
|
||||||
IDXBinaryAs: IDAs,
|
IDXBinaryAs: IDAs,
|
||||||
IDXBinaryTildeModPlus: IDTildeModPlus,
|
|
||||||
IDXBinaryTildeModMinus: IDTildeModMinus,
|
|
||||||
|
|
||||||
IDXAssociativePlus: IDPlus,
|
IDXAssociativePlus: IDPlus,
|
||||||
IDXAssociativeStar: IDStar,
|
IDXAssociativeStar: IDStar,
|
||||||
@@ -774,6 +790,8 @@ var binaryForms = [nBuiltInIDs]ID{
|
|||||||
IDPercentEq: IDXBinaryPercent,
|
IDPercentEq: IDXBinaryPercent,
|
||||||
IDTildeModPlusEq: IDXBinaryTildeModPlus,
|
IDTildeModPlusEq: IDXBinaryTildeModPlus,
|
||||||
IDTildeModMinusEq: IDXBinaryTildeModMinus,
|
IDTildeModMinusEq: IDXBinaryTildeModMinus,
|
||||||
|
IDTildeSatPlusEq: IDXBinaryTildeSatPlus,
|
||||||
|
IDTildeSatMinusEq: IDXBinaryTildeSatMinus,
|
||||||
|
|
||||||
IDPlus: IDXBinaryPlus,
|
IDPlus: IDXBinaryPlus,
|
||||||
IDMinus: IDXBinaryMinus,
|
IDMinus: IDXBinaryMinus,
|
||||||
@@ -788,6 +806,8 @@ var binaryForms = [nBuiltInIDs]ID{
|
|||||||
IDPercent: IDXBinaryPercent,
|
IDPercent: IDXBinaryPercent,
|
||||||
IDTildeModPlus: IDXBinaryTildeModPlus,
|
IDTildeModPlus: IDXBinaryTildeModPlus,
|
||||||
IDTildeModMinus: IDXBinaryTildeModMinus,
|
IDTildeModMinus: IDXBinaryTildeModMinus,
|
||||||
|
IDTildeSatPlus: IDXBinaryTildeSatPlus,
|
||||||
|
IDTildeSatMinus: IDXBinaryTildeSatMinus,
|
||||||
|
|
||||||
IDNotEq: IDXBinaryNotEq,
|
IDNotEq: IDXBinaryNotEq,
|
||||||
IDLessThan: IDXBinaryLessThan,
|
IDLessThan: IDXBinaryLessThan,
|
||||||
@@ -806,7 +826,7 @@ var associativeForms = [nBuiltInIDs]ID{
|
|||||||
IDAmp: IDXAssociativeAmp,
|
IDAmp: IDXAssociativeAmp,
|
||||||
IDPipe: IDXAssociativePipe,
|
IDPipe: IDXAssociativePipe,
|
||||||
IDHat: IDXAssociativeHat,
|
IDHat: IDXAssociativeHat,
|
||||||
// TODO: IDTildeModPlus, IDTildeModMinus?
|
// TODO: IDTildeModPlus, IDTildeSatPlus?
|
||||||
IDAnd: IDXAssociativeAnd,
|
IDAnd: IDXAssociativeAnd,
|
||||||
IDOr: IDXAssociativeOr,
|
IDOr: IDXAssociativeOr,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user