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
public abstract class Symbol extends Decoratable
A grammar symbol.Symbols match either tokens in the input (for
TerminalSymbolsymbols) or other symbols (forNonterminalSymbolsymbols). For convenience, this interface defines both match methods for all Symbols.
-
-
Constructor Summary
Constructors Constructor Description Symbol()Create a symbol with no attributes.Symbol(java.util.Collection<ParserAttribute> attributes)Create a symbol with an initial set of attributes.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract voidexport(GrammarExporter exporter)Export this symbol with the specified exporter.abstract booleanmatches(Symbol input)Does this symbol match the specified symbol?abstract booleanmatches(Token input)Does this symbol match the specified token?-
Methods inherited from class org.nineml.coffeegrinder.util.Decoratable
addAttribute, addAttributes, getAttribute, getAttributes, getAttributesMap, getAttributeValue, hasAttribute
-
-
-
-
Constructor Detail
-
Symbol
public Symbol()
Create a symbol with no attributes.
-
Symbol
public Symbol(java.util.Collection<ParserAttribute> attributes)
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 Detail
-
matches
public abstract boolean matches(Token input)
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
public abstract boolean matches(Symbol input)
Does this symbol match the specified symbol?- Parameters:
input- The symbol.- Returns:
- true if it is the same symbol as this symbol.
-
export
public abstract void export(GrammarExporter exporter)
Export this symbol with the specified exporter.- Parameters:
exporter- the exporter.
-
-