public abstract class Symbol extends Decoratable
Symbols match either tokens in the input (for TerminalSymbol
symbols) or other symbols
(for NonterminalSymbol
symbols). For convenience, this interface defines both match methods
for all Symbols.
Constructor and Description |
---|
Symbol()
Create a symbol with no attributes.
|
Symbol(java.util.Collection<ParserAttribute> attributes)
Create a symbol with an initial set of attributes.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
matches(Symbol input)
Does this symbol match the specified symbol?
|
abstract boolean |
matches(Token input)
Does this symbol match the specified token?
|
addAttribute, addAttributes, getAttribute, getAttributes, getAttributesMap, getAttributeValue, hasAttribute
public Symbol()
public Symbol(java.util.Collection<ParserAttribute> attributes)
attributes
- the attributesGrammarException
- if the attribute names are not uniqueAttributeException
- if an attribute has an invalid valuepublic abstract boolean matches(Token input)
This is very like equality, but consider that for some kinds of symbols (for example, tokens that match regular expressions) it isn't really the same as equality.
input
- The token.public abstract boolean matches(Symbol input)
input
- The symbol.