Skip to main content

Shake Lexer Token Specification

§ 1 Definition

§ 1.1 Tokens

A token is a sequence of characters that form a meaningful unit in a program. It holds the following information:

  • The type of the token
  • The position of the token in the source code (Start and End index in the source code)
  • The value of the token (if applicable)

§ 1.2 Token Types

There are two variants of token types, there are types that always have the same value and therefore do not need to store the value in the token (e.g. SEMICOLON or any keyword) and there are types that can have different values (e.g. INTEGER or IDENTIFIER). The latter ones store the value in the token. They are implemented as an enum in the lexer package.

§ 2 Token Types

§ 2.1 "fixed" token types:

Token TypeDescriptionValue
ADDAddition+
ADD_ASSIGNAddition Assignment+=
ASSIGNAssignment=
BIT_ANDBitwise And&
BIT_AND_ASSIGNBitwise And Assignment&=
BIT_NANDBitwise Not And~&
BIT_NORBitwise Not Or~|
BIT_NOTBitwise Not~
BIT_ORBitwise Or|
BIT_OR_ASSIGNBitwise Or Assignment|=
BIT_XNORBitwise Not Xor~^
BIT_XORBitwise Xor^
BIT_XOR_ASSIGNBitwise Xor Assignment^=
COLONColon:
COMMAComma,
DECRDecrement--
DIVDivision/
DIV_ASSIGNDivision Assignment/=
DOTDot.
EOFEnd of File
EQEquals==
GTGreater Than>
GTEGreater Than or Equal>=
INCRIncrement++
KEYWORD_ABSTRACTAbstract Keywordabstract
KEYWORD_ASAs Keywordas
KEYWORD_CLASSClass Keywordclass
KEYWORD_CONSTConst Keywordconst
KEYWORD_CONSTRUCTORConstructor Keywordconstructor
KEYWORD_DODo Keyworddo
KEYWORD_ELSEElse Keywordelse
KEYWORD_ENUMEnum Keywordenum
KEYWORD_FALSEFalse Keywordfalse
KEYWORD_FINALFinal Keywordfinal
KEYWORD_FORFor Keywordfor
KEYWORD_FUNFun Keywordfun
KEYWORD_IFIf Keywordif
KEYWORD_IMPORTImport Keywordimport
KEYWORD_INIn Keywordin
KEYWORD_INLINEInline Keywordinline
KEYWORD_INSTANCEOFInstanceof Keywordinstanceof
KEYWORD_INTERFACEInterface Keywordinterface
KEYWORD_NATIVENative Keywordnative
KEYWORD_NULLNull Keywordnull
KEYWORD_OBJECTObject Keywordobject
KEYWORD_OPERATOROperator Keywordoperator
KEYWORD_OVERRIDEOverride Keywordoverride
KEYWORD_PACKAGEPackage Keywordpackage
KEYWORD_PRIVATEPrivate Keywordprivate
KEYWORD_PROTECTEDProtected Keywordprotected
KEYWORD_PUBLICPublic Keywordpublic
KEYWORD_RETURNReturn Keywordreturn
KEYWORD_STATICStatic Keywordstatic
KEYWORD_SUPERSuper Keywordsuper
KEYWORD_SYNCHRONIZEDSynchronized Keywordsynchronized
KEYWORD_THISThis Keywordthis
KEYWORD_TRUETrue Keywordtrue
KEYWORD_VALVal Keywordval
KEYWORD_VARVar Keywordvar
KEYWORD_WHILEWhile Keywordwhile
LCURLLeft Curly Brace{
LINE_SEPARATORLine Separator\n
LOGICAL_ANDLogical And&&
LOGICAL_NOTLogical Not!
LOGICAL_ORLogical Or||
LOGICAL_XORLogical Xor^
LPARENLeft Parenthesis(
LSQBRLeft Square Bracket[
LTLess Than<
LTELess Then or Equal<=
MODModulo%
MOD_ASSIGNModulo Assignment%=
MULMultiplication*
MUL_ASSIGNMultiplication Assignment*=
NEQAssert not equal!=
POWPower**
POW_ASSIGNPower Assignment**=
RCURLRight Curly Brace}
RPARENRight Parenthesis)
RSQBRRight Square Bracket]
SEMICOLONSemicolon;
SUBSubtraction-
SUB_ASSIGNSubtraction Assignment-=

§ 2.2 "variable" token types:

Token TypeDescriptionValue
CHARACTERCharactere.g. 'a'
FLOATFloate.g. 1.0
IDENTIFIERIdentifiere.g. a
INTEGERIntegere.g. 1
STRINGStringe.g. "a"