Class SymbolTable

java.lang.Object
net.aifusion.asn.SymbolTable

public class SymbolTable extends Object
Class to manage a symbol table
Author:
Sharad Singhal
  • Constructor Details

    • SymbolTable

      public SymbolTable(Tokenizer tokenizer)
      Create a symbol table using the tokens in the tokenizer
      Parameters:
      tokenizer - - tokenizer containing the input definition
  • Method Details

    • getSymbolTable

      public LinkedHashMap<String,Symbol> getSymbolTable()
      Get the underlying map containing <symbolName,Symbol> from this symbol table
      Returns:
      map containing <symbolName,Symbol>
    • getDefinition

      public AsnNode getDefinition(String name)
      Get the definition of a symbol
      Parameters:
      name - - fully qualified name of the symbol
      Returns:
      - definition of the symbol, if any. Null if the symbol is not defined, or does not yet have a definition
    • setDefinition

      public void setDefinition(String name, AsnNode definition)
      Set the definition of a symbol
      Parameters:
      name - - fully qualified name of the symbol
      definition - - corresponding definition
    • get

      public Symbol get(String name)
      Get the symbol associated with a given symbol
      Parameters:
      name - - fully qualified name of the symbol
      Returns:
      - associated symbol. Null if none defined
    • getProduction

      public AsnProduction getProduction(String name)
      Get the production associated with a given symbol
      Parameters:
      name - - fully qualified name of the symbol
      Returns:
      - production associated with the symbol, null if none defined
    • getType

      public AsnNode getType(String name)
      Get the primitive type associated with a symbol
      Parameters:
      name - - fully qualified name of the symbol
      Returns:
      - primitive (universal) type of the symbol. Null if the symbol is not defined, or does not reduce to a universal type
    • main

      public static void main(String[] args)