From af263fa26e7bfcfa3afbe0680a2b324c987e9b30 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 15 Apr 2018 11:05:43 +1000 Subject: [PATCH] Remove token ID/Key distinction, part 4 of N --- lang/token/list.go | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/lang/token/list.go b/lang/token/list.go index 8704ace3..96410b51 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -29,14 +29,13 @@ const MaxIntBits = 64 type Flags uint32 const ( - FlagsOther = Flags(0x0001) - FlagsBinaryOp = Flags(0x0004) - FlagsAssociativeOp = Flags(0x0008) - FlagsLiteral = Flags(0x0010) - FlagsNumLiteral = Flags(0x0020) - FlagsStrLiteral = Flags(0x0040) - FlagsIdent = Flags(0x0080) - flagsUnused = Flags(0x8000) + FlagsOther = Flags(0x0001) + FlagsBinaryOp = Flags(0x0004) + FlagsLiteral = Flags(0x0010) + FlagsNumLiteral = Flags(0x0020) + FlagsStrLiteral = Flags(0x0040) + FlagsIdent = Flags(0x0080) + flagsUnused = Flags(0x8000) ) // Key is the high 16 bits of an ID. It is the map key for a Map. @@ -71,7 +70,7 @@ func (x ID) IsBuiltIn() bool { return Key(x>>KeyShift) < nBuiltInKeys } func (x ID) IsUnaryOp() bool { return x.Key() <= 0xFF && x.UnaryForm() != 0 } func (x ID) IsBinaryOp() bool { return Flags(x)&FlagsBinaryOp != 0 } -func (x ID) IsAssociativeOp() bool { return Flags(x)&FlagsAssociativeOp != 0 } +func (x ID) IsAssociativeOp() bool { return x.Key() <= 0xFF && x.AssociativeForm() != 0 } func (x ID) IsLiteral() bool { return Flags(x)&FlagsLiteral != 0 } func (x ID) IsNumLiteral() bool { return Flags(x)&FlagsNumLiteral != 0 } @@ -381,16 +380,16 @@ const ( IDPercentEq = ID(0x2B<