mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 09:01:35 +01:00
Add a ~+ operator.
This commit is contained in:
1 parent
e7d01e7b2a
commit
6492c52156
8 files changed
+154
-99
No files matched your search
@@ -510,18 +510,19 @@ var cTypeNames = [...]string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var cOpNames = [256]string{
|
var cOpNames = [256]string{
|
||||||
t.KeyEq: " = ",
|
t.KeyEq: " = ",
|
||||||
t.KeyPlusEq: " += ",
|
t.KeyPlusEq: " += ",
|
||||||
t.KeyMinusEq: " -= ",
|
t.KeyMinusEq: " -= ",
|
||||||
t.KeyStarEq: " *= ",
|
t.KeyStarEq: " *= ",
|
||||||
t.KeySlashEq: " /= ",
|
t.KeySlashEq: " /= ",
|
||||||
t.KeyShiftLEq: " <<= ",
|
t.KeyShiftLEq: " <<= ",
|
||||||
t.KeyShiftREq: " >>= ",
|
t.KeyShiftREq: " >>= ",
|
||||||
t.KeyAmpEq: " &= ",
|
t.KeyAmpEq: " &= ",
|
||||||
t.KeyAmpHatEq: " no_such_amp_hat_C_operator ",
|
t.KeyAmpHatEq: " no_such_amp_hat_C_operator ",
|
||||||
t.KeyPipeEq: " |= ",
|
t.KeyPipeEq: " |= ",
|
||||||
t.KeyHatEq: " ^= ",
|
t.KeyHatEq: " ^= ",
|
||||||
t.KeyPercentEq: " %= ",
|
t.KeyPercentEq: " %= ",
|
||||||
|
t.KeyTildePlusEq: " += ",
|
||||||
|
|
||||||
t.KeyXUnaryPlus: "+",
|
t.KeyXUnaryPlus: "+",
|
||||||
t.KeyXUnaryMinus: "-",
|
t.KeyXUnaryMinus: "-",
|
||||||
@@ -547,6 +548,7 @@ var cOpNames = [256]string{
|
|||||||
t.KeyXBinaryAnd: " && ",
|
t.KeyXBinaryAnd: " && ",
|
||||||
t.KeyXBinaryOr: " || ",
|
t.KeyXBinaryOr: " || ",
|
||||||
t.KeyXBinaryAs: " no_such_as_C_operator ",
|
t.KeyXBinaryAs: " no_such_as_C_operator ",
|
||||||
|
t.KeyXBinaryTildePlus: " + ",
|
||||||
|
|
||||||
t.KeyXAssociativePlus: " + ",
|
t.KeyXAssociativePlus: " + ",
|
||||||
t.KeyXAssociativeStar: " * ",
|
t.KeyXAssociativeStar: " * ",
|
||||||
|
|||||||
+1
-1
@@ -1493,7 +1493,7 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
}
|
}
|
||||||
if (v_n_copied > 0) {
|
if (v_n_copied > 0) {
|
||||||
v_hlen -= v_n_copied;
|
v_hlen -= v_n_copied;
|
||||||
v_hdist = ((v_hdist + (v_n_copied & 32767)) & 32767);
|
v_hdist = ((v_hdist + v_n_copied) & 32767);
|
||||||
if (v_hdist == 0) {
|
if (v_hdist == 0) {
|
||||||
goto label_5_break;
|
goto label_5_break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -524,6 +524,11 @@ func (n *TypeExpr) IsRefined() bool {
|
|||||||
return t.Key(n.id0>>t.KeyShift) != t.KeyOpenBracket && (n.lhs != nil || n.mhs != nil)
|
return t.Key(n.id0>>t.KeyShift) != t.KeyOpenBracket && (n.lhs != nil || n.mhs != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *TypeExpr) IsUnsignedInteger() bool {
|
||||||
|
return n.id0 == 0 && (n.id1.Key() == t.KeyU8 || n.id1.Key() == t.KeyU16 ||
|
||||||
|
n.id1.Key() == t.KeyU32 || n.id1.Key() == t.KeyU64) // TODO: t.KeyUsize?
|
||||||
|
}
|
||||||
|
|
||||||
func (n *TypeExpr) HasPointers() bool {
|
func (n *TypeExpr) HasPointers() bool {
|
||||||
for ; n != nil; n = n.Inner() {
|
for ; n != nil; n = n.Inner() {
|
||||||
switch n.id0.Key() {
|
switch n.id0.Key() {
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ var opStrings = [256]string{
|
|||||||
t.KeyXBinaryAnd: " and ",
|
t.KeyXBinaryAnd: " and ",
|
||||||
t.KeyXBinaryOr: " or ",
|
t.KeyXBinaryOr: " or ",
|
||||||
t.KeyXBinaryAs: " as ",
|
t.KeyXBinaryAs: " as ",
|
||||||
|
t.KeyXBinaryTildePlus: " ~+ ",
|
||||||
|
|
||||||
t.KeyXAssociativePlus: " + ",
|
t.KeyXAssociativePlus: " + ",
|
||||||
t.KeyXAssociativeStar: " * ",
|
t.KeyXAssociativeStar: " * ",
|
||||||
|
|||||||
@@ -997,6 +997,14 @@ func (q *checker) bcheckExprBinaryOp1(op t.Key, lhs *a.Expr, lMin *big.Int, lMax
|
|||||||
|
|
||||||
case t.KeyXBinaryAs:
|
case t.KeyXBinaryAs:
|
||||||
// Unreachable, as this is checked by the caller.
|
// Unreachable, as this is checked by the caller.
|
||||||
|
|
||||||
|
case t.KeyXBinaryTildePlus:
|
||||||
|
typ := lhs.MType()
|
||||||
|
if typ.IsIdeal() {
|
||||||
|
typ = rhs.MType()
|
||||||
|
}
|
||||||
|
b := numTypeBounds[typ.Name().Key()]
|
||||||
|
return b[0], b[1], nil
|
||||||
}
|
}
|
||||||
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprBinaryOp", op)
|
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprBinaryOp", op)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,6 +262,11 @@ func (q *checker) tcheckAssign(n *a.Assign) error {
|
|||||||
}
|
}
|
||||||
return fmt.Errorf("check: assignment %q: shift %q, of type %q, does not have numeric type",
|
return fmt.Errorf("check: assignment %q: shift %q, of type %q, does not have numeric type",
|
||||||
n.Operator().String(q.tm), rhs.String(q.tm), rTyp.String(q.tm))
|
n.Operator().String(q.tm), rhs.String(q.tm), rTyp.String(q.tm))
|
||||||
|
case t.KeyTildePlusEq:
|
||||||
|
if !lTyp.IsUnsignedInteger() {
|
||||||
|
return fmt.Errorf("check: assignment %q: %q, of type %q, does not have unsigned integer type",
|
||||||
|
n.Operator().String(q.tm), lhs.String(q.tm), lTyp.String(q.tm))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rTyp.IsIdeal() || lTyp.EqIgnoringRefinements(rTyp) {
|
if rTyp.IsIdeal() || lTyp.EqIgnoringRefinements(rTyp) {
|
||||||
@@ -826,6 +831,28 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch op.Key() {
|
||||||
|
case t.KeyXBinaryTildePlus:
|
||||||
|
typ := lTyp
|
||||||
|
if typ.IsIdeal() {
|
||||||
|
typ = rTyp
|
||||||
|
if typ.IsIdeal() {
|
||||||
|
return fmt.Errorf("check: binary %q: %q and %q, of types %q and %q, do not have non-ideal types",
|
||||||
|
op.AmbiguousForm().String(q.tm),
|
||||||
|
lhs.String(q.tm), rhs.String(q.tm),
|
||||||
|
lTyp.String(q.tm), rTyp.String(q.tm),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !typ.IsUnsignedInteger() {
|
||||||
|
return fmt.Errorf("check: binary %q: %q and %q, of types %q and %q, do not have unsigned integer types",
|
||||||
|
op.AmbiguousForm().String(q.tm),
|
||||||
|
lhs.String(q.tm), rhs.String(q.tm),
|
||||||
|
lTyp.String(q.tm), rTyp.String(q.tm),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if lcv, rcv := lhs.ConstValue(), rhs.ConstValue(); lcv != nil && rcv != nil {
|
if lcv, rcv := lhs.ConstValue(), rhs.ConstValue(); lcv != nil && rcv != nil {
|
||||||
ncv, err := evalConstValueBinaryOp(q.tm, n, lcv, rcv)
|
ncv, err := evalConstValueBinaryOp(q.tm, n, lcv, rcv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -901,6 +928,8 @@ func evalConstValueBinaryOp(tm *t.Map, n *a.Expr, l *big.Int, r *big.Int) (*big.
|
|||||||
return btoi((l.Cmp(zero) != 0) && (r.Cmp(zero) != 0)), nil
|
return btoi((l.Cmp(zero) != 0) && (r.Cmp(zero) != 0)), nil
|
||||||
case t.KeyXBinaryOr:
|
case t.KeyXBinaryOr:
|
||||||
return btoi((l.Cmp(zero) != 0) || (r.Cmp(zero) != 0)), nil
|
return btoi((l.Cmp(zero) != 0) || (r.Cmp(zero) != 0)), nil
|
||||||
|
case t.KeyXBinaryTildePlus:
|
||||||
|
return nil, fmt.Errorf("check: cannot apply ~+ operator to ideal numbers")
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("check: unrecognized token.Key (0x%02X) for evalConstValueBinaryOp", n.ID0().Key())
|
return nil, fmt.Errorf("check: unrecognized token.Key (0x%02X) for evalConstValueBinaryOp", n.ID0().Key())
|
||||||
}
|
}
|
||||||
|
|||||||
+95
-84
@@ -173,30 +173,32 @@ const (
|
|||||||
KeySemicolon = Key(IDSemicolon >> KeyShift)
|
KeySemicolon = Key(IDSemicolon >> KeyShift)
|
||||||
KeyDollar = Key(IDDollar >> KeyShift)
|
KeyDollar = Key(IDDollar >> KeyShift)
|
||||||
|
|
||||||
KeyEq = Key(IDEq >> KeyShift)
|
KeyEq = Key(IDEq >> KeyShift)
|
||||||
KeyPlusEq = Key(IDPlusEq >> KeyShift)
|
KeyPlusEq = Key(IDPlusEq >> KeyShift)
|
||||||
KeyMinusEq = Key(IDMinusEq >> KeyShift)
|
KeyMinusEq = Key(IDMinusEq >> KeyShift)
|
||||||
KeyStarEq = Key(IDStarEq >> KeyShift)
|
KeyStarEq = Key(IDStarEq >> KeyShift)
|
||||||
KeySlashEq = Key(IDSlashEq >> KeyShift)
|
KeySlashEq = Key(IDSlashEq >> KeyShift)
|
||||||
KeyShiftLEq = Key(IDShiftLEq >> KeyShift)
|
KeyShiftLEq = Key(IDShiftLEq >> KeyShift)
|
||||||
KeyShiftREq = Key(IDShiftREq >> KeyShift)
|
KeyShiftREq = Key(IDShiftREq >> KeyShift)
|
||||||
KeyAmpEq = Key(IDAmpEq >> KeyShift)
|
KeyAmpEq = Key(IDAmpEq >> KeyShift)
|
||||||
KeyAmpHatEq = Key(IDAmpHatEq >> KeyShift)
|
KeyAmpHatEq = Key(IDAmpHatEq >> KeyShift)
|
||||||
KeyPipeEq = Key(IDPipeEq >> KeyShift)
|
KeyPipeEq = Key(IDPipeEq >> KeyShift)
|
||||||
KeyHatEq = Key(IDHatEq >> KeyShift)
|
KeyHatEq = Key(IDHatEq >> KeyShift)
|
||||||
KeyPercentEq = Key(IDPercentEq >> KeyShift)
|
KeyPercentEq = Key(IDPercentEq >> KeyShift)
|
||||||
|
KeyTildePlusEq = Key(IDTildePlusEq >> KeyShift)
|
||||||
|
|
||||||
KeyPlus = Key(IDPlus >> KeyShift)
|
KeyPlus = Key(IDPlus >> KeyShift)
|
||||||
KeyMinus = Key(IDMinus >> KeyShift)
|
KeyMinus = Key(IDMinus >> KeyShift)
|
||||||
KeyStar = Key(IDStar >> KeyShift)
|
KeyStar = Key(IDStar >> KeyShift)
|
||||||
KeySlash = Key(IDSlash >> KeyShift)
|
KeySlash = Key(IDSlash >> KeyShift)
|
||||||
KeyShiftL = Key(IDShiftL >> KeyShift)
|
KeyShiftL = Key(IDShiftL >> KeyShift)
|
||||||
KeyShiftR = Key(IDShiftR >> KeyShift)
|
KeyShiftR = Key(IDShiftR >> KeyShift)
|
||||||
KeyAmp = Key(IDAmp >> KeyShift)
|
KeyAmp = Key(IDAmp >> KeyShift)
|
||||||
KeyAmpHat = Key(IDAmpHat >> KeyShift)
|
KeyAmpHat = Key(IDAmpHat >> KeyShift)
|
||||||
KeyPipe = Key(IDPipe >> KeyShift)
|
KeyPipe = Key(IDPipe >> KeyShift)
|
||||||
KeyHat = Key(IDHat >> KeyShift)
|
KeyHat = Key(IDHat >> KeyShift)
|
||||||
KeyPercent = Key(IDPercent >> KeyShift)
|
KeyPercent = Key(IDPercent >> KeyShift)
|
||||||
|
KeyTildePlus = Key(IDTildePlus >> KeyShift)
|
||||||
|
|
||||||
KeyNotEq = Key(IDNotEq >> KeyShift)
|
KeyNotEq = Key(IDNotEq >> KeyShift)
|
||||||
KeyLessThan = Key(IDLessThan >> KeyShift)
|
KeyLessThan = Key(IDLessThan >> KeyShift)
|
||||||
@@ -320,6 +322,7 @@ const (
|
|||||||
KeyXBinaryAnd = Key(IDXBinaryAnd >> KeyShift)
|
KeyXBinaryAnd = Key(IDXBinaryAnd >> KeyShift)
|
||||||
KeyXBinaryOr = Key(IDXBinaryOr >> KeyShift)
|
KeyXBinaryOr = Key(IDXBinaryOr >> KeyShift)
|
||||||
KeyXBinaryAs = Key(IDXBinaryAs >> KeyShift)
|
KeyXBinaryAs = Key(IDXBinaryAs >> KeyShift)
|
||||||
|
KeyXBinaryTildePlus = Key(IDXBinaryTildePlus >> KeyShift)
|
||||||
|
|
||||||
KeyXAssociativePlus = Key(IDXAssociativePlus >> KeyShift)
|
KeyXAssociativePlus = Key(IDXAssociativePlus >> KeyShift)
|
||||||
KeyXAssociativeStar = Key(IDXAssociativeStar >> KeyShift)
|
KeyXAssociativeStar = Key(IDXAssociativeStar >> KeyShift)
|
||||||
@@ -351,30 +354,32 @@ const (
|
|||||||
IDSemicolon = ID(0x26<<KeyShift | FlagsTightLeft)
|
IDSemicolon = ID(0x26<<KeyShift | FlagsTightLeft)
|
||||||
IDDollar = ID(0x27<<KeyShift | FlagsTightRight)
|
IDDollar = ID(0x27<<KeyShift | FlagsTightRight)
|
||||||
|
|
||||||
IDEq = ID(0x30<<KeyShift | FlagsAssign)
|
IDEq = ID(0x30<<KeyShift | FlagsAssign)
|
||||||
IDPlusEq = ID(0x31<<KeyShift | FlagsAssign)
|
IDPlusEq = ID(0x31<<KeyShift | FlagsAssign)
|
||||||
IDMinusEq = ID(0x32<<KeyShift | FlagsAssign)
|
IDMinusEq = ID(0x32<<KeyShift | FlagsAssign)
|
||||||
IDStarEq = ID(0x33<<KeyShift | FlagsAssign)
|
IDStarEq = ID(0x33<<KeyShift | FlagsAssign)
|
||||||
IDSlashEq = ID(0x34<<KeyShift | FlagsAssign)
|
IDSlashEq = ID(0x34<<KeyShift | FlagsAssign)
|
||||||
IDShiftLEq = ID(0x35<<KeyShift | FlagsAssign)
|
IDShiftLEq = ID(0x35<<KeyShift | FlagsAssign)
|
||||||
IDShiftREq = ID(0x36<<KeyShift | FlagsAssign)
|
IDShiftREq = ID(0x36<<KeyShift | FlagsAssign)
|
||||||
IDAmpEq = ID(0x37<<KeyShift | FlagsAssign)
|
IDAmpEq = ID(0x37<<KeyShift | FlagsAssign)
|
||||||
IDAmpHatEq = ID(0x38<<KeyShift | FlagsAssign)
|
IDAmpHatEq = ID(0x38<<KeyShift | FlagsAssign)
|
||||||
IDPipeEq = ID(0x39<<KeyShift | FlagsAssign)
|
IDPipeEq = ID(0x39<<KeyShift | FlagsAssign)
|
||||||
IDHatEq = ID(0x3A<<KeyShift | FlagsAssign)
|
IDHatEq = ID(0x3A<<KeyShift | FlagsAssign)
|
||||||
IDPercentEq = ID(0x3B<<KeyShift | FlagsAssign)
|
IDPercentEq = ID(0x3B<<KeyShift | FlagsAssign)
|
||||||
|
IDTildePlusEq = ID(0x3C<<KeyShift | FlagsAssign)
|
||||||
|
|
||||||
IDPlus = ID(0x41<<KeyShift | FlagsBinaryOp | FlagsUnaryOp | FlagsAssociativeOp)
|
IDPlus = ID(0x41<<KeyShift | FlagsBinaryOp | FlagsUnaryOp | FlagsAssociativeOp)
|
||||||
IDMinus = ID(0x42<<KeyShift | FlagsBinaryOp | FlagsUnaryOp)
|
IDMinus = ID(0x42<<KeyShift | FlagsBinaryOp | FlagsUnaryOp)
|
||||||
IDStar = ID(0x43<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
IDStar = ID(0x43<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
||||||
IDSlash = ID(0x44<<KeyShift | FlagsBinaryOp)
|
IDSlash = ID(0x44<<KeyShift | FlagsBinaryOp)
|
||||||
IDShiftL = ID(0x45<<KeyShift | FlagsBinaryOp)
|
IDShiftL = ID(0x45<<KeyShift | FlagsBinaryOp)
|
||||||
IDShiftR = ID(0x46<<KeyShift | FlagsBinaryOp)
|
IDShiftR = ID(0x46<<KeyShift | FlagsBinaryOp)
|
||||||
IDAmp = ID(0x47<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
IDAmp = ID(0x47<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
||||||
IDAmpHat = ID(0x48<<KeyShift | FlagsBinaryOp)
|
IDAmpHat = ID(0x48<<KeyShift | FlagsBinaryOp)
|
||||||
IDPipe = ID(0x49<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
IDPipe = ID(0x49<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
||||||
IDHat = ID(0x4A<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
IDHat = ID(0x4A<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
||||||
IDPercent = ID(0x4B<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
IDPercent = ID(0x4B<<KeyShift | FlagsBinaryOp | FlagsAssociativeOp)
|
||||||
|
IDTildePlus = ID(0x4C<<KeyShift | FlagsBinaryOp) // TODO: FlagsAssociativeOp?
|
||||||
|
|
||||||
IDNotEq = ID(0x50<<KeyShift | FlagsBinaryOp)
|
IDNotEq = ID(0x50<<KeyShift | FlagsBinaryOp)
|
||||||
IDLessThan = ID(0x51<<KeyShift | FlagsBinaryOp)
|
IDLessThan = ID(0x51<<KeyShift | FlagsBinaryOp)
|
||||||
@@ -505,6 +510,7 @@ const (
|
|||||||
IDXBinaryAnd = ID(0xE9<<KeyShift | FlagsBinaryOp)
|
IDXBinaryAnd = ID(0xE9<<KeyShift | FlagsBinaryOp)
|
||||||
IDXBinaryOr = ID(0xEA<<KeyShift | FlagsBinaryOp)
|
IDXBinaryOr = ID(0xEA<<KeyShift | FlagsBinaryOp)
|
||||||
IDXBinaryAs = ID(0xEB<<KeyShift | FlagsBinaryOp)
|
IDXBinaryAs = ID(0xEB<<KeyShift | FlagsBinaryOp)
|
||||||
|
IDXBinaryTildePlus = ID(0xEC<<KeyShift | FlagsBinaryOp)
|
||||||
|
|
||||||
IDXAssociativePlus = ID(0xF0<<KeyShift | FlagsAssociativeOp)
|
IDXAssociativePlus = ID(0xF0<<KeyShift | FlagsAssociativeOp)
|
||||||
IDXAssociativeStar = ID(0xF1<<KeyShift | FlagsAssociativeOp)
|
IDXAssociativeStar = ID(0xF1<<KeyShift | FlagsAssociativeOp)
|
||||||
@@ -546,34 +552,32 @@ var builtInsByKey = [nBuiltInKeys]struct {
|
|||||||
KeySemicolon: {";", IDSemicolon},
|
KeySemicolon: {";", IDSemicolon},
|
||||||
KeyDollar: {"$", IDDollar},
|
KeyDollar: {"$", IDDollar},
|
||||||
|
|
||||||
KeyEq: {"=", IDEq},
|
KeyEq: {"=", IDEq},
|
||||||
KeyPlusEq: {"+=", IDPlusEq},
|
KeyPlusEq: {"+=", IDPlusEq},
|
||||||
KeyMinusEq: {"-=", IDMinusEq},
|
KeyMinusEq: {"-=", IDMinusEq},
|
||||||
KeyStarEq: {"*=", IDStarEq},
|
KeyStarEq: {"*=", IDStarEq},
|
||||||
KeySlashEq: {"/=", IDSlashEq},
|
KeySlashEq: {"/=", IDSlashEq},
|
||||||
KeyShiftLEq: {"<<=", IDShiftLEq},
|
KeyShiftLEq: {"<<=", IDShiftLEq},
|
||||||
KeyShiftREq: {">>=", IDShiftREq},
|
KeyShiftREq: {">>=", IDShiftREq},
|
||||||
KeyAmpEq: {"&=", IDAmpEq},
|
KeyAmpEq: {"&=", IDAmpEq},
|
||||||
KeyAmpHatEq: {"&^=", IDAmpHatEq},
|
KeyAmpHatEq: {"&^=", IDAmpHatEq},
|
||||||
KeyPipeEq: {"|=", IDPipeEq},
|
KeyPipeEq: {"|=", IDPipeEq},
|
||||||
KeyHatEq: {"^=", IDHatEq},
|
KeyHatEq: {"^=", IDHatEq},
|
||||||
KeyPercentEq: {"%=", IDPercentEq},
|
KeyPercentEq: {"%=", IDPercentEq},
|
||||||
|
KeyTildePlusEq: {"~+=", IDTildePlusEq},
|
||||||
|
|
||||||
KeyPlus: {"+", IDPlus},
|
KeyPlus: {"+", IDPlus},
|
||||||
KeyMinus: {"-", IDMinus},
|
KeyMinus: {"-", IDMinus},
|
||||||
KeyStar: {"*", IDStar},
|
KeyStar: {"*", IDStar},
|
||||||
KeySlash: {"/", IDSlash},
|
KeySlash: {"/", IDSlash},
|
||||||
KeyShiftL: {"<<", IDShiftL},
|
KeyShiftL: {"<<", IDShiftL},
|
||||||
KeyShiftR: {">>", IDShiftR},
|
KeyShiftR: {">>", IDShiftR},
|
||||||
KeyAmp: {"&", IDAmp},
|
KeyAmp: {"&", IDAmp},
|
||||||
KeyAmpHat: {"&^", IDAmpHat},
|
KeyAmpHat: {"&^", IDAmpHat},
|
||||||
KeyPipe: {"|", IDPipe},
|
KeyPipe: {"|", IDPipe},
|
||||||
KeyHat: {"^", IDHat},
|
KeyHat: {"^", IDHat},
|
||||||
KeyPercent: {"%", IDPercent},
|
KeyPercent: {"%", IDPercent},
|
||||||
// TODO: tilde-ops such as ~+ for ignoring overflow. Swift defines overflow
|
KeyTildePlus: {"~+", IDPercent},
|
||||||
// ops for +, - and *. Swift syntax uses a leading &. Puffs uses a leading
|
|
||||||
// ~ as it is less ambiguous with the &^ operator (and any potential use of
|
|
||||||
// & as address-of) and ~ is otherwise unused.
|
|
||||||
|
|
||||||
KeyNotEq: {"!=", IDNotEq},
|
KeyNotEq: {"!=", IDNotEq},
|
||||||
KeyLessThan: {"<", IDLessThan},
|
KeyLessThan: {"<", IDLessThan},
|
||||||
@@ -770,6 +774,10 @@ var lexers = [256][]suffixLexer{
|
|||||||
{"=", IDGreaterEq},
|
{"=", IDGreaterEq},
|
||||||
{"", IDGreaterThan},
|
{"", IDGreaterThan},
|
||||||
},
|
},
|
||||||
|
'~': {
|
||||||
|
{"+=", IDTildePlusEq},
|
||||||
|
{"+", IDTildePlus},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var ambiguousForms = [256]ID{
|
var ambiguousForms = [256]ID{
|
||||||
@@ -797,6 +805,7 @@ var ambiguousForms = [256]ID{
|
|||||||
KeyXBinaryAnd: IDAnd,
|
KeyXBinaryAnd: IDAnd,
|
||||||
KeyXBinaryOr: IDOr,
|
KeyXBinaryOr: IDOr,
|
||||||
KeyXBinaryAs: IDAs,
|
KeyXBinaryAs: IDAs,
|
||||||
|
KeyXBinaryTildePlus: IDTildePlus,
|
||||||
|
|
||||||
KeyXAssociativePlus: IDPlus,
|
KeyXAssociativePlus: IDPlus,
|
||||||
KeyXAssociativeStar: IDStar,
|
KeyXAssociativeStar: IDStar,
|
||||||
@@ -814,17 +823,18 @@ var unaryForms = [256]ID{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var binaryForms = [256]ID{
|
var binaryForms = [256]ID{
|
||||||
KeyPlusEq: IDXBinaryPlus,
|
KeyPlusEq: IDXBinaryPlus,
|
||||||
KeyMinusEq: IDXBinaryMinus,
|
KeyMinusEq: IDXBinaryMinus,
|
||||||
KeyStarEq: IDXBinaryStar,
|
KeyStarEq: IDXBinaryStar,
|
||||||
KeySlashEq: IDXBinarySlash,
|
KeySlashEq: IDXBinarySlash,
|
||||||
KeyShiftLEq: IDXBinaryShiftL,
|
KeyShiftLEq: IDXBinaryShiftL,
|
||||||
KeyShiftREq: IDXBinaryShiftR,
|
KeyShiftREq: IDXBinaryShiftR,
|
||||||
KeyAmpEq: IDXBinaryAmp,
|
KeyAmpEq: IDXBinaryAmp,
|
||||||
KeyAmpHatEq: IDXBinaryAmpHat,
|
KeyAmpHatEq: IDXBinaryAmpHat,
|
||||||
KeyPipeEq: IDXBinaryPipe,
|
KeyPipeEq: IDXBinaryPipe,
|
||||||
KeyHatEq: IDXBinaryHat,
|
KeyHatEq: IDXBinaryHat,
|
||||||
KeyPercentEq: IDXBinaryPercent,
|
KeyPercentEq: IDXBinaryPercent,
|
||||||
|
KeyTildePlusEq: IDXBinaryTildePlus,
|
||||||
|
|
||||||
KeyPlus: IDXBinaryPlus,
|
KeyPlus: IDXBinaryPlus,
|
||||||
KeyMinus: IDXBinaryMinus,
|
KeyMinus: IDXBinaryMinus,
|
||||||
@@ -846,6 +856,7 @@ var binaryForms = [256]ID{
|
|||||||
KeyAnd: IDXBinaryAnd,
|
KeyAnd: IDXBinaryAnd,
|
||||||
KeyOr: IDXBinaryOr,
|
KeyOr: IDXBinaryOr,
|
||||||
KeyAs: IDXBinaryAs,
|
KeyAs: IDXBinaryAs,
|
||||||
|
KeyTildePlus: IDXBinaryTildePlus,
|
||||||
}
|
}
|
||||||
|
|
||||||
var associativeForms = [256]ID{
|
var associativeForms = [256]ID{
|
||||||
|
|||||||
@@ -390,8 +390,7 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
|||||||
}
|
}
|
||||||
if n_copied > 0 {
|
if n_copied > 0 {
|
||||||
hlen -= n_copied
|
hlen -= n_copied
|
||||||
// TODO: a "~+" tilde-operator that ignores overflow.
|
hdist = (hdist ~+ n_copied) & 0x7FFF
|
||||||
hdist = (hdist + (n_copied & 0x7FFF)) & 0x7FFF
|
|
||||||
if hdist == 0 {
|
if hdist == 0 {
|
||||||
// Wrap around the this.history ringbuffer.
|
// Wrap around the this.history ringbuffer.
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in new issue
Block a user