From b24a929ec749e8ed71111822dffff5e37f05e899 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 15 Apr 2018 15:44:31 +1000 Subject: [PATCH] Remove token ID/Key distinction, part 10 of N --- lang/token/list.go | 358 ++++++++++++++++++++++----------------------- 1 file changed, 171 insertions(+), 187 deletions(-) diff --git a/lang/token/list.go b/lang/token/list.go index a7a0ded1..c5a98069 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -18,21 +18,6 @@ package token // integer types. const MaxIntBits = 64 -// Flags are the low 16 bits of an ID. For example, they signify whether a -// token is an operator, an identifier, etc. -// -// The flags are not exclusive. For example, the "+" token is both a unary and -// binary operator. It is also associative: (a + b) + c equals a + (b + c). -// -// A valid token will have non-zero flags. If none of the other flags apply, -// the FlagsOther bit will be set. -type Flags uint32 - -const ( - FlagsOther = Flags(0x0001) - flagsUnused = Flags(0x8000) -) - // Key is the high 16 bits of an ID. It is the map key for a Map. type Key uint32 @@ -56,8 +41,7 @@ func (x ID) UnaryForm() ID { return unaryForms[0xFF&(x>>KeyShift)] } func (x ID) BinaryForm() ID { return binaryForms[0xFF&(x>>KeyShift)] } func (x ID) AssociativeForm() ID { return associativeForms[0xFF&(x>>KeyShift)] } -func (x ID) Key() Key { return Key(x >> KeyShift) } -func (x ID) Flags() Flags { return Flags(x & FlagsMask) } +func (x ID) Key() Key { return Key(x >> KeyShift) } func (x ID) IsBuiltIn() bool { return Key(x>>KeyShift) < nBuiltInKeys } @@ -374,43 +358,43 @@ const ( const ( IDInvalid = ID(0) - IDDoubleZ = ID(0x01<