public class Terminal extends Object implements AlphabetSymbol
Grammar
. A terminal
can also be a range of characters in which case the range between min and max should not
include >, < or /. In that case it could break the analysis. If the check parameter
in the range constructor is set to true, this property will be cheked.
The CharRangeSplitter
can be used to break char ranges
up into a number of char ranges to ensure this invariant.
Terminals are immutable.Constructor and Description |
---|
Terminal(char min,
char max)
Constructs a new Terminal by invoking
Terminal(char, char, boolean) with (min, max, false) |
Terminal(char min,
char max,
boolean check)
Constructs a new Terminal.
|
Terminal(String symbol)
Constructs a new Terminal with only 1 symbol, namely that given
|
Terminal(Terminal t)
Clones the terminal t
|
Modifier and Type | Method and Description |
---|---|
void |
accept(GrammarEntityVisitor visitor)
Accepts the given grammar entity visitor in a visitor pattern
|
boolean |
equals(Object o) |
CodeLocation |
getCodeLocation() |
<T> T |
getData() |
char |
getMax()
Returns the maximum character of the terminal range
|
char |
getMin()
Returns the minimum character of the terminal range
|
String |
getSymbol()
Returns the symbol if the terminal only has 1 symbol, else
return a textual representation of the range.
|
int |
hashCode() |
boolean |
isEpsilon()
Returns whether this terminal has the language ε.
|
boolean |
isRange()
Returns whether this terminal represents a range
|
boolean |
isWhiteSpace()
Return true if this grammar entity contains only whitespace
|
void |
setCodeLocation(CodeLocation codeLocation) |
<T> T |
setData(T data) |
String |
toString()
Returns the same as
getSymbol() |
public Terminal(char min, char max)
Terminal(char, char, boolean)
with (min, max, false)public Terminal(char min, char max, boolean check)
Terminal(String)
min
- The minimum character in the rangemax
- The maximum character in the rangecheck
- whether to check that the ranges do not contain <, > or "public Terminal(String symbol)
symbol
- Symbol of the Terminalpublic Terminal(Terminal t)
t
- public void accept(GrammarEntityVisitor visitor)
GrammarEntity
accept
in interface GrammarEntity
public CodeLocation getCodeLocation()
public <T> T getData()
public char getMax()
public char getMin()
public String getSymbol()
public boolean isEpsilon()
public boolean isRange()
public boolean isWhiteSpace()
GrammarEntity
isWhiteSpace
in interface GrammarEntity
public void setCodeLocation(CodeLocation codeLocation)
public <T> T setData(T data)
public String toString()
getSymbol()
Copyright © 2008-2013 Mathias Schwarz.