Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

98 wiersze
3.2KB

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

Powered by TurnKey Linux.