Package org.nineml.coffeegrinder.parser
Class TerminalSymbol
java.lang.Object
org.nineml.coffeegrinder.util.Decoratable
org.nineml.coffeegrinder.parser.Symbol
org.nineml.coffeegrinder.parser.TerminalSymbol
A terminal symbol.
Terminal symbols match some input token(s) literally.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TerminalSymbolstatic final TerminalSymbolstatic final TerminalSymbol -
Constructor Summary
ConstructorsConstructorDescriptionTerminalSymbol(Token token) Make a symbol for the specified token.TerminalSymbol(Token token, Collection<ParserAttribute> attributes) Make a symbol for the specified token with the given attributesTerminalSymbol(Token token, ParserAttribute attribute) Make a symbol for the specified token with a given ParserAttribute. -
Method Summary
Modifier and TypeMethodDescriptionstatic TerminalSymbolch(char terminal) Return a token for a string.booleanTest tokens for equality.getToken()Get the token associated with this terminal symbol.inthashCode()Assure that equal tokens return the same hash code.final booleanDoes this symbol match this other symbol?booleanDoes this symbol match the given token?static TerminalSymbolReturn a token for a string.static TerminalSymbolReturn a token for a string.toString()Pretty print a token.Methods inherited from class org.nineml.coffeegrinder.util.Decoratable
addAttribute, addAttributes, getAttribute, getAttributes, getAttributesMap, getAttributeValue, hasAttribute
-
Field Details
-
EPSILON
-
EOF
-
UNDEFINED
-
-
Constructor Details
-
TerminalSymbol
Make a symbol for the specified token.- Parameters:
token- the token- Throws:
NullPointerException- if the token is null
-
TerminalSymbol
Make a symbol for the specified token with a given ParserAttribute.- Parameters:
token- the tokenattribute- the attribute- Throws:
NullPointerException- if either is nullGrammarException- if the attribute attempts to make the symbol optional
-
TerminalSymbol
Make a symbol for the specified token with the given attributes- Parameters:
token- the tokenattributes- a collection of attributes- Throws:
NullPointerException- if the token is nullGrammarException- if the attributes attempt to make the symbol optional
-
-
Method Details
-
s
Return a token for a string.This is just a convenience method for a terminal symbol for a
TokenString.- Parameters:
terminal- the string- Returns:
- the terminal symbol
-
ch
Return a token for a string.This is just a convenience method for a terminal symbol for a
TokenCharacter.- Parameters:
terminal- the character- Returns:
- the terminal symbol
-
regex
Return a token for a string.This is just a convenience method for a terminal symbol for a
TokenRegex.- Parameters:
regex- the regex- Returns:
- the terminal symbol
-
getToken
Get the token associated with this terminal symbol.- Returns:
- the token
-
matches
Does this symbol match the given token? -
matches
Does this symbol match this other symbol?No, it does not. No terminal ever matches another symbol.
-
equals
Test tokens for equality.Two tokens are equal if they represent the same string and have the same attributes.
-
hashCode
public int hashCode()Assure that equal tokens return the same hash code. -
toString
Pretty print a token.
-