Class ConstructSymbol

java.lang.Object
quickparse.grammar.symbol.Symbol
quickparse.grammar.symbol.ConstructSymbol

public class ConstructSymbol
extends Symbol
Defines the symbol used in grammars to represent a syntactical construct.

For example, given the grammatical rule
A -> '(' B ')'

A and B are syntactical constructs that can be represented by this class.
  • Method Details

    • get

      public static ConstructSymbol get​(java.lang.String symbol)
      Gets a new ConstructSymbol instance for the given string.
      This method uses the Flyweight design pattern by GoF to cache already created instances.
      Parameters:
      symbol - the symbol to wrap into the ConstructSymbol instance
      Returns:
      a ConstructSymbol instance
    • getName

      public java.lang.String getName()
      Description copied from class: Symbol
      The name of the symbol
      Specified by:
      getName in class Symbol
      Returns:
      the name of this symbol as a String
    • accept

      public <R,​ C> R accept​(C context, Symbol.Function<R,​C> symbolFunction)
      Description copied from class: Symbol
      Solves the subclass of this symbol (ConstructSymbol or TokenSymbol and computes the given Symbol.Function
      Specified by:
      accept in class Symbol
      Type Parameters:
      R - the return type of the function
      C - the context type for the function
      Parameters:
      context - the context used for computation
      symbolFunction - the function that must be computed on this symbol
      Returns:
      the return value returned by computing the Symbol.Function
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object