Package quickparse.grammar.symbol
Class Symbol
java.lang.Object
quickparse.grammar.symbol.Symbol
- Direct Known Subclasses:
ConstructSymbol,TokenSymbol
public abstract class Symbol
extends java.lang.Object
Defines a
grammar symbol. A grammar symbol can identify a construct
(i.e., a 'non-terminal' symbol) or a token (i.e., a 'terminal' symbol).-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSymbol.ConstructActionAn action that can be executed on aConstructSymbolstatic interfaceSymbol.ConstructFunction<R,C>A function that can be executed on aConstructSymbolstatic interfaceSymbol.Function<R,C>Represents a function that can be computed on aConstructSymbolor, alternatively, on aTokenSymbol.static interfaceSymbol.TokenActionAn action that can be executed on aTokenSymbolstatic interfaceSymbol.TokenFunction<R,C>A function that can be executed on aTokenSymbol -
Constructor Summary
Constructors Constructor Description Symbol() -
Method Summary
Modifier and Type Method Description abstract <R, C> Raccept(C context, Symbol.Function<R,C> symbolFunction)Solves the subclass of this symbol (ConstructSymbolorTokenSymboland computes the givenSymbol.Functionabstract java.lang.StringgetName()The name of the symbol<R, C> RifConstruct(C context, Symbol.ConstructFunction<R,C> function)If this symbol is aConstructSymbolinstance, computes the givenSymbol.ConstructFunctionon it.voidifConstruct(Symbol.ConstructAction action)If this symbol is aConstructSymbolinstance, computes the givenSymbol.ConstructActionon it.<R, C> RifToken(C context, Symbol.TokenFunction<R,C> function)If this symbol is aConstructSymbolinstance, computes the givenSymbol.TokenFunctionon it.voidifToken(Symbol.TokenAction action)If this symbol is aTokenSymbolinstance, computes the givenSymbol.TokenActionon it.
-
Constructor Details
-
Symbol
public Symbol()
-
-
Method Details
-
getName
public abstract java.lang.String getName()The name of the symbol- Returns:
- the name of this symbol as a
String
-
accept
Solves the subclass of this symbol (ConstructSymbolorTokenSymboland computes the givenSymbol.Function- Type Parameters:
R- the return type of the functionC- the context type for the function- Parameters:
context- the context used for computationsymbolFunction- the function that must be computed on this symbol- Returns:
- the return value returned by computing the
Symbol.Function
-
ifToken
If this symbol is aTokenSymbolinstance, computes the givenSymbol.TokenActionon it.- Parameters:
action- theSymbol.TokenActionto compute
-
ifConstruct
If this symbol is aConstructSymbolinstance, computes the givenSymbol.ConstructActionon it.- Parameters:
action- theSymbol.ConstructActionto compute
-
ifToken
If this symbol is aConstructSymbolinstance, computes the givenSymbol.TokenFunctionon it.- Type Parameters:
R- the return type of the functionC- the context type for the function- Parameters:
context- the contex used to compute theSymbol.TokenFunctionfunction- theSymbol.TokenFunctionto compute- Returns:
- the return value returned by computing the
Symbol.TokenFunction
-
ifConstruct
If this symbol is aConstructSymbolinstance, computes the givenSymbol.ConstructFunctionon it.- Type Parameters:
R- the return type of the functionC- the context type for the function- Parameters:
context- the contex used to compute theSymbol.ConstructFunctionfunction- theSymbol.ConstructFunctionto compute- Returns:
- the return value returned by computing the
Symbol.ConstructFunction
-