|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xrel.parser.SymTable
The symbol table contains the types, the patterns, the variables and the expressions inside the program.
Field Summary | |
protected java.util.HashMap |
automata
Contains the automata inside the program. |
protected java.util.Vector |
ErrorList
|
protected int |
ErrorNum
|
protected java.util.Vector |
expressions
Contains the expressions of the program. |
int |
MAX_ERROR_NUM
Maximum number of signaled error, after this limit error checking stops. |
int |
originalExpressions
number of program expressions |
int |
originalPatterns
number of program patterns (variable handled at hand from the extern) |
protected java.util.Vector |
patterns
Contains the patterns of the program. |
protected java.lang.String |
switchId
the name of the typeswitch identifier, if any |
protected java.util.Vector |
types
Contains the types of the program. |
protected java.util.Vector |
variables
Contains the variables bound inside the patterns of the program. |
protected int |
WarningNum
|
Fields inherited from interface xrel.parser.XRelParserTreeConstants |
JJTAS, JJTCASE, JJTCOMMA, JJTEMPTY, JJTEXPORTTP, JJTIDENTIFIER, JJTIMPORTST, jjtNodeName, JJTOPERATOR, JJTPAR, JJTPROGRAM, JJTSTATEMENTLIST, JJTSTRING, JJTSTRINGLITERAL, JJTSWITCHCASE, JJTTAG, JJTTYPEDECL, JJTVOID |
Fields inherited from interface xrel.parser.SymElementKind |
EXPRESSION, LABEL, PATTERN, S_EXPRESSIONS, S_LABELS, S_PATTERNS, S_TYPES, S_VARIABLES, TYPE, UNDEFINED, VARIABLE |
Fields inherited from interface xrel.parser.SpecialNames |
AnyTagName, AnyTypeName, AutomatonPrefix, EmptyPatternName, ExportTypeName, ExpressionPrefix, PatternPrefix, SpecialPrefix, StringName, StringPatternName, StringTypeName, StrLiteralPrefix, StrLiteralSuffix, StrUnquotedPrefix, StrUnquotedSuffix |
Constructor Summary | |
SymTable()
Initializes the symbol table. |
Method Summary | |
void |
add_parsing_error(SimpleNode n,
java.lang.String msg)
|
void |
add_parsing_error(Token first,
Token last,
java.lang.String msg)
|
void |
add_syntax_error(SimpleNode n,
java.lang.String msg)
|
void |
add_syntax_error(Token first,
Token last,
java.lang.String msg)
|
void |
add_type_error(SimpleNode n,
java.lang.String msg)
|
void |
add_type_error(Token first,
Token last,
java.lang.String msg)
|
void |
add_warning(SimpleNode n,
java.lang.String msg)
|
void |
add_warning(Token first,
Token last,
java.lang.String msg)
|
void |
addAutomaton(TA A)
|
protected void |
addClause(Node clause)
|
void |
checkErrors(SimpleNode rt)
|
void |
detachPatterns()
Detaches the symbol table elements from the original syntax tree. |
void |
dump(java.io.PrintStream out,
int kinds,
boolean debug,
boolean internalFormat)
Prints a list of the content of the symbol table to a stream. |
void |
dumpTokens(java.io.PrintStream out,
int kinds,
boolean debug)
|
boolean |
foundErrors()
|
boolean |
foundWarnings()
|
SimpleNode |
getClause(int i)
|
TADifference |
getDiffAutomaton(TA A1,
TA A2,
int BuildPhases,
boolean debug)
|
SimpleNode |
getImportSt()
|
TAProduct |
getProductAutomaton(TA A1,
TA A2,
int BuildPhases,
boolean force,
boolean debug)
|
TASimple |
getSimpleAutomaton(java.lang.String nm,
SymElement el,
int BuildPhases,
boolean debug)
Returns an automaton with a given name. |
SymElement |
getTypeSwitchVar()
Returns the variable element associated to the typeswitch identifier. |
SimpleNode |
getTypeSwNode()
|
TAUnion |
getUnionAutomaton(java.util.HashSet alNames,
int BuildPhases,
boolean debug)
|
java.util.Vector |
getVector(int k)
Gets the vector of kind k. |
void |
mergeVariables()
Join variables that have the same name and the same scope. |
void |
put_expressions(int scope,
SimpleNode nodeValue)
Puts expressions of a code block into the symbol table. |
void |
put_pat(int scope,
java.lang.String name,
SimpleNode nodeValue)
Puts a pattern into the symbol table. |
SymElement |
put_type(int scope,
java.lang.String name,
SimpleNode nodeValue)
Puts a type into the symbol table. |
SymElement |
put_var(int scope,
java.lang.String name,
SimpleNode nodeValue)
Puts a variable into the symbol table. |
TA |
search_automaton(java.lang.String nm)
|
SymElement |
search(int k,
int scope,
java.lang.String name)
Searches an identifier with name "name", scope "scope" and of kind k (type or pattern or variable or expression). |
SymElement |
search(int kinds,
java.lang.String name)
Searches the last identifier with name "name" inserted in the symbol table. This function explicitly searches first variables (if specified) then patterns (if specified) then everything else. N.B.: to get the last one I search it from the bottom |
SymElement |
searchPattern(java.lang.String pStr,
int scope)
|
protected void |
setImportSt(Node impSt)
|
void |
setSwitchId(java.lang.String sId)
Set the typeswitch variable name. |
protected void |
setTypeSwNode(Node tswNode)
|
void |
showBoundVariables(java.io.PrintStream out,
boolean uniqueName,
boolean internalFormat)
Shows the variables bound in the pattern matching and theirs values. |
void |
showErrors(java.io.PrintStream out,
SimpleNode rt)
|
void |
showThings(java.io.PrintStream out)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Vector types
protected java.util.Vector patterns
protected java.util.Vector variables
protected java.util.Vector expressions
protected java.util.HashMap automata
public int originalPatterns
public int originalExpressions
protected java.lang.String switchId
protected int ErrorNum
protected int WarningNum
protected java.util.Vector ErrorList
public final int MAX_ERROR_NUM
Constructor Detail |
public SymTable()
Method Detail |
public void showThings(java.io.PrintStream out)
protected void addClause(Node clause)
public SimpleNode getClause(int i)
protected void setTypeSwNode(Node tswNode)
public SimpleNode getTypeSwNode()
protected void setImportSt(Node impSt)
public SimpleNode getImportSt()
public java.util.Vector getVector(int k)
k
- the kind of the vector required (TYPE, PATTERN, VARIABLE or
EXPRESSION)public SymElement getTypeSwitchVar()
public void setSwitchId(java.lang.String sId)
sId
- public void detachPatterns()
public SymElement put_type(int scope, java.lang.String name, SimpleNode nodeValue)
scope
- the scope of the element (i.e. its identifier)name
- the identifier of the elementnodeValue
- the root node associated to the expression that
defines the typepublic SymElement put_var(int scope, java.lang.String name, SimpleNode nodeValue)
scope
- the scope of the element (i.e. its identifier)name
- the name of the elementnodeId
- the node of the identifiernodeValue
- the subtree associated to the elementpublic void put_pat(int scope, java.lang.String name, SimpleNode nodeValue)
scope
- the scope of the element (i.e. its identifier)name
- the name of the elementnodeValue
- the subtree associated to the elementpublic void put_expressions(int scope, SimpleNode nodeValue)
scope
- the scope of the element (i.e. its identifier)name
- the name of the elementnodeValue
- the ASTStatementList nodepublic TASimple getSimpleAutomaton(java.lang.String nm, SymElement el, int BuildPhases, boolean debug)
nm
- the name of the automatonpublic TAProduct getProductAutomaton(TA A1, TA A2, int BuildPhases, boolean force, boolean debug)
public void addAutomaton(TA A)
public TADifference getDiffAutomaton(TA A1, TA A2, int BuildPhases, boolean debug)
public TAUnion getUnionAutomaton(java.util.HashSet alNames, int BuildPhases, boolean debug)
public TA search_automaton(java.lang.String nm)
public void mergeVariables()
Join variables that have the same name and the same scope.
This is a little trick as I need to check syntactic errors and linearity constraints before to compute a type for the variable.
This function copies also the subtrees of the variables (it detaches the variable types from the tree).
public SymElement search(int k, int scope, java.lang.String name)
k
- TYPE or PATTERN or VARIABLE or EXPRESSIONscope
- scoping number: 0 for types and the number of the clause
for variables/patterns/expressions (0 if the variable is bound in the
import statement or if the pattern is in the import statement)name
- the name of the identifier to searchpublic SymElement search(int kinds, java.lang.String name)
Searches the last identifier with name "name" inserted in the symbol table.
This function explicitly searches first variables (if specified) then patterns (if specified) then everything else.
N.B.: to get the last one I search it from the bottom
name
- the identifier to searchpublic SymElement searchPattern(java.lang.String pStr, int scope)
public void showBoundVariables(java.io.PrintStream out, boolean uniqueName, boolean internalFormat)
out
- the print stream where to write outuniqueName
- if this flag is true variable names are prepended with
the internal unique codeinternalFormat
- if this flag is true output is shown in an internal
format, otherwise in an external (more readable) one.public void dump(java.io.PrintStream out, int kinds, boolean debug, boolean internalFormat)
out
- the stream where to direct the outputpublic void dumpTokens(java.io.PrintStream out, int kinds, boolean debug)
public void add_parsing_error(SimpleNode n, java.lang.String msg)
public void add_parsing_error(Token first, Token last, java.lang.String msg)
public void add_syntax_error(SimpleNode n, java.lang.String msg)
public void add_syntax_error(Token first, Token last, java.lang.String msg)
public void add_type_error(SimpleNode n, java.lang.String msg)
public void add_type_error(Token first, Token last, java.lang.String msg)
public void add_warning(SimpleNode n, java.lang.String msg)
public void add_warning(Token first, Token last, java.lang.String msg)
public void checkErrors(SimpleNode rt)
public void showErrors(java.io.PrintStream out, SimpleNode rt)
public boolean foundErrors()
public boolean foundWarnings()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |