Class SymbolTable

  • All Implemented Interfaces:
    java.io.Serializable

    public class SymbolTable
    extends java.lang.Object
    implements java.io.Serializable
    Symbol table
    See Also:
    Serialized Form
    • Field Detail

      • table

        private final java.util.Map<java.lang.String,​Variable> table
      • RESERVED

        private static final java.util.Map<java.lang.String,​Variable> RESERVED
    • Constructor Detail

      • SymbolTable

        public SymbolTable()
    • Method Detail

      • reserveKeyword

        private static void reserveKeyword​(Variable v)
      • isReservedKeyword

        public static boolean isReservedKeyword​(java.lang.String name)
      • isReservedKeyword

        public static boolean isReservedKeyword​(Variable v)
      • isReserved

        public boolean isReserved​(java.lang.String name)
        Check variable has been reserved?
        Parameters:
        name -
        Returns:
      • tryReserveKeyword

        public static Variable tryReserveKeyword​(Variable var)
        Try to reserve key word, return the reserved variable if success, otherwise return itself.
        Parameters:
        var -
        Returns:
      • getVariable

        public Variable getVariable​(java.lang.String name)
        Get variable by name
        Parameters:
        name -
        Returns:
      • reserve

        public Variable reserve​(java.lang.String lexeme)