Package org.nineml.coffeegrinder.parser
Class Symbol
java.lang.Object
org.nineml.coffeegrinder.util.Decoratable
org.nineml.coffeegrinder.parser.Symbol
- Direct Known Subclasses:
NonterminalSymbol
,TerminalSymbol
A grammar symbol.
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 Summary
ConstructorsConstructorDescriptionSymbol()
Create a symbol with no attributes.Symbol
(Collection<ParserAttribute> attributes) Create a symbol with an initial set of attributes. -
Method Summary
Methods inherited from class org.nineml.coffeegrinder.util.Decoratable
addAttribute, addAttributes, getAttribute, getAttributes, getAttributesMap, getAttributeValue, hasAttribute
-
Constructor Details
-
Symbol
public Symbol()Create a symbol with no attributes. -
Symbol
Create a symbol with an initial set of attributes.- Parameters:
attributes
- the attributes- Throws:
GrammarException
- if the attribute names are not uniqueAttributeException
- if an attribute has an invalid value
-
-
Method Details
-
matches
Does this symbol match the specified token?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.
- Parameters:
input
- The token.- Returns:
- true if the token matches.
-
matches
Does this symbol match the specified symbol?- Parameters:
input
- The symbol.- Returns:
- true if it is the same symbol as this symbol.
-