|
- ; tokens.inc - Nova128 token kinds and lexer error codes (E02-S02).
- ;
- ; Values are stable: parsers, dumps, and golden files depend on them. Add new
- ; kinds at the end of their group; never renumber.
-
- .ifndef TOKENS_INC
- TOKENS_INC = 1
-
- ; ---------------------------------------------------------- basic kinds
- TOK_EOF = $00
- TOK_EOL = $01
- TOK_IDENT = $02 ; tok_text = normalized name ($41-$5A, digits, $5F)
- TOK_NUMBER = $03 ; tok_value = 0..65535
- TOK_STRING = $04 ; tok_text = decoded bytes
- TOK_CHAR = $05 ; tok_value = one PETSCII byte
- TOK_ERROR = $06 ; tok_err = LEXERR_*; the rest of the line is skipped
-
- ; ---------------------------------------------------------- punctuation
- TOK_LPAREN = $10
- TOK_RPAREN = $11
- TOK_LBRACKET = $12
- TOK_RBRACKET = $13
- TOK_COMMA = $14
- TOK_DOT = $15
- TOK_COLON = $16
- TOK_EQ = $17 ; = (assignment and equality)
- TOK_PLUS = $18
- TOK_MINUS = $19
- TOK_STAR = $1A
- TOK_SLASH = $1B
- TOK_LT = $1C
- TOK_GT = $1D
- TOK_NE = $1E ; <>
- TOK_LE = $1F ; <=
- TOK_GE = $20 ; >=
-
- ; ------------------------------------------------------------- keywords
- ; Ordered as in the lexer's keyword table (alphabetical).
- TOK_KW_FIRST = $40
- KW_AND = $40
- KW_AS = $41
- KW_BOOLEAN = $42
- KW_BYTE = $43
- KW_CHAR = $44
- KW_CLASS = $45
- KW_DELETE = $46
- KW_ELSE = $47
- KW_END = $48
- KW_FALSE = $49
- KW_FOR = $4A
- KW_IF = $4B
- KW_IMPLEMENTS = $4C
- KW_INTEGER = $4D
- KW_INTERFACE = $4E
- KW_METHOD = $4F
- KW_NEW = $50
- KW_NOT = $51
- KW_NULL = $52
- KW_OR = $53
- KW_PRINT = $54
- KW_PRIVATE = $55
- KW_PROGRAM = $56
- KW_PUBLIC = $57
- KW_RETURN = $58
- KW_SELF = $59
- KW_STEP = $5A
- KW_TO = $5B
- KW_TRUE = $5C
- KW_VAR = $5D
- KW_WHILE = $5E
- KW_WORD = $5F
- TOK_KW_LAST = $5F
-
- ; ------------------------------------------------------ lexer error codes
- LEXERR_INVALID_CHAR = 1 ; byte cannot start any token
- LEXERR_IDENT_TOO_LONG = 2 ; more than 16 identifier characters
- LEXERR_NUMBER_RANGE = 3 ; value above 65535
- LEXERR_BAD_NUMBER = 4 ; $/% without digits, or digits run into letters
- LEXERR_UNTERMINATED_STRING = 5 ; end of line inside "..."
- LEXERR_BAD_ESCAPE = 6 ; \ followed by an unsupported character
- LEXERR_BAD_CHAR_LITERAL = 7 ; '' empty, several characters, or unterminated
-
- ; ------------------------------------------------------------- limits
- LEX_IDENT_MAX = 16 ; significant identifier characters
- LEX_TEXT_MAX = 80 ; tok_text capacity (one source line)
-
- ; ------------------------------------------------------- PETSCII bytes
- PET_SPACE = $20
- PET_TAB = $09
- PET_QUOTE = $22
- PET_APOS = $27
- PET_BACKSLASH = $5C ; ASCII '\' (shown as a pound sign on the C128)
- PET_UNDERSCORE = $5F ; ASCII '_' (shown as a left arrow)
- ESC_N_VALUE = $0D ; "\n" (D119, proposed)
- ESC_R_VALUE = $0D ; "\r" (D119, proposed)
-
- .endif
|