public abstract class Symbol extends Object
-+ Symbol | +--+This class is abstract.Terminal- Lexical Symbol (i.e. number, id '+') | | | +--ErrorToken- Lexical Symbol declared with %error | +--NonTerminal- Syntactical symbol (i.e. Expression, Statement)
| Modifier and Type | Field and Description |
|---|---|
protected Associativity |
associativity
The associativity of a given symbol.
|
protected int |
count
Reference count of the symbol
|
protected String |
fullName
the full name.
|
protected int |
id
The numeric identifier for the symbol.
|
protected String |
name
the name of the symbol.
|
protected int |
precedence
The numeric precedence of the symbol.
|
protected int |
token
The lexical value returned from the lexical analyzer.
|
protected Type |
type
The type of the symbol.
|
protected String |
variable
A language-named representation of a terminal.
|
| Modifier and Type | Method and Description |
|---|---|
void |
computeVariable()
Compute a language usable variable name
|
boolean |
equals(Object obj) |
Associativity |
getAssociativity() |
int |
getCount() |
String |
getFullName() |
int |
getId() |
String |
getName() |
int |
getPrecedence() |
int |
getToken() |
Type |
getType() |
String |
getVariable() |
boolean |
isIdentifier()
is the name of this non-terminal already a good variable name
|
void |
setAssociativity(Associativity associativity) |
void |
setCount(int count) |
void |
setFullName(String fullName) |
void |
setId(int id) |
void |
setName(String name) |
void |
setPrecedence(int precedence) |
void |
setToken(int token) |
void |
setType(Type type) |
String |
toString()
Minimal representation.
|
protected int id
protected String name
protected String fullName
protected int precedence
precedence is usually provided with %prec.
Usually the associativity with higher precedence is picked for a Rule
For conflict resolution:
if shift-reduce conflict
left associativity implies reduce
right associativity implies shift
non assoc implies errorprotected Associativity associativity
protected int count
protected int token
protected Type type
stack[stackTop-1].type
protected String variable
public Symbol(String name)
public void computeVariable()
public boolean isIdentifier()
public String getVariable()
public int getId()
public void setId(int id)
id - the id to setpublic String getName()
public void setName(String name)
name - the name to setpublic String getFullName()
public void setFullName(String fullName)
fullName - the fullName to setpublic int getPrecedence()
public void setPrecedence(int precedence)
precedence - the precedence to setpublic Associativity getAssociativity()
public void setAssociativity(Associativity associativity)
associativity - the associativity to setpublic int getCount()
public void setCount(int count)
count - the count to setpublic int getToken()
public void setToken(int token)
token - the token to setpublic Type getType()
public void setType(Type type)
type - the type to setpublic boolean equals(Object obj)
equals in class ObjectObject.equals(java.lang.Object)public String toString()
toString in class ObjectObject.toString()Copyright © 2017. All rights reserved.