Tokens


Token Types

Each time it is called, the Lexical Analyzer returns a type-value pair representing the next token found in the source. The token types in our language are listed below. For each token that is isolated, the lexical analyzer will determine its type and set the type specification to the appropriate value.

  1. PROGRAM
  2. BEGIN
  3. END
  4. VAR
  5. FUNCTION
  6. PROCEDURE
  7. RESULT
  8. INTEGER
  9. REAL
  10. ARRAY
  11. OF
  12. IF
  13. THEN
  14. ELSE
  15. WHILE
  16. DO
  17. NOT
  18. IDENTIFIER
  19. INTCONSTANT or REALCONSTANT
  20. RELOP
  21. MULOP
  22. ADDOP
  23. ASSIGNOP
  24. COMMA
  25. SEMICOLON
  26. COLON
  27. RIGHTPAREN
  28. LEFTPAREN
  29. RIGHTBRACKET
  30. LEFTBRACKET
  31. UNARYMINUS
  32. UNARYPLUS
  33. DOUBLEDOT
  34. ENDMARKER (single dot)
  35. ENDOFFILE

Value

The value portion of the type-value pair will vary depending on the type of token isolated.


RELOP
  1. =
  2. <>
  3. <
  4. >
  5. < =
  6. > =

ADDOP
  1. +
  2. -
  3. OR

MULOP
  1. *
  2. /
  3. DIV
  4. MOD
  5. AND