Package beaver
Class Symbol
- java.lang.Object
-
- beaver.Symbol
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSymbol()Special case constructor that allows creation of explicitly Symbol-ized nonterminals.Symbol(short id)Symbol(short id, int start, int end)Symbol(short id, int start_line, int start_column, int length)Symbol(short id, int start_line, int start_column, int length, Object value)Symbol(short id, int left, int right, Object value)Symbol(short id, Object value)Symbol(Object value)Creates Symbol for non-symbolic results of action routines
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Symbolclone()static intgetColumn(int position)Extracts column number from a packed position.intgetEnd()Returns a position in a source where this symbol ends.shortgetId()Returns an ID of this symbol.static intgetLine(int position)Extracts line number from a packed position.intgetStart()Returns a position in a source where this symbol starts.static intmakePosition(int line, int column)Packs symbol "coordinates" into a single number.
-
-
-
Field Detail
-
value
public Object value
Value assigned to this symbol.
-
id
protected short id
Numeric symbol ID.
-
start
protected int start
Line and column where this symbol begins.
-
end
protected int end
Line and column where this symbol ends.
-
-
Constructor Detail
-
Symbol
public Symbol(short id)
-
Symbol
public Symbol(short id, Object value)
-
Symbol
public Symbol(short id, int start, int end)
-
Symbol
public Symbol(short id, int left, int right, Object value)
-
Symbol
public Symbol(short id, int start_line, int start_column, int length)
-
Symbol
public Symbol(short id, int start_line, int start_column, int length, Object value)
-
Symbol
public Symbol(Object value)
Creates Symbol for non-symbolic results of action routines- Parameters:
value- attached Symbol's value
-
Symbol
protected Symbol()
Special case constructor that allows creation of explicitly Symbol-ized nonterminals. Used by classes descending from Symbol and which instances are returned by reduce actions. In this case ID and symbol position will be assigned by the parser when reduce action code returns this symbol.
-
-
Method Detail
-
makePosition
public static int makePosition(int line, int column)Packs symbol "coordinates" into a single number.
-
getLine
public static int getLine(int position)
Extracts line number from a packed position.
-
getColumn
public static int getColumn(int position)
Extracts column number from a packed position.
-
getId
public short getId()
Returns an ID of this symbol. This ID typically is, depending on a symbol type, either a terminal ID if a Symbol is a token created and returned by a Scanner, or a nonterminal ID if a symbol was created by parser based on that nonterminal definition. In the former case the ID is one of IDs generated by Beaver for terminal symbols. The latter keeps IDs of nonterminal symbols.- Returns:
- symbol's ID
-
getStart
public int getStart()
Returns a position in a source where this symbol starts.- Returns:
- packed line and column numbers
-
getEnd
public int getEnd()
Returns a position in a source where this symbol ends.- Returns:
- packed line and column numbers
-
clone
public Symbol clone() throws CloneNotSupportedException
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
-