|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--antlr.Parser | +--antlr.LLkParser | +--CpcParser
Classe que incorpora l'analisis sintactica del compilador. Es la classe principal que parseja el fitxer de pseudocodi. A més executa les comprovacions semántiques i la generació de codi.
Abans de parserjar un programa, es millor establir primer les seguents propietats:
Finalment parsejar el programa cridant:
programa(boolean)
Field Summary | |
static java.lang.String[] |
_tokenNames
|
static antlr.collections.impl.BitSet |
_tokenSet_0
|
private static long[] |
_tokenSet_0_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_1
|
private static long[] |
_tokenSet_1_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_10
|
private static long[] |
_tokenSet_10_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_11
|
private static long[] |
_tokenSet_11_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_12
|
private static long[] |
_tokenSet_12_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_13
|
private static long[] |
_tokenSet_13_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_14
|
private static long[] |
_tokenSet_14_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_15
|
private static long[] |
_tokenSet_15_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_16
|
private static long[] |
_tokenSet_16_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_17
|
private static long[] |
_tokenSet_17_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_18
|
private static long[] |
_tokenSet_18_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_19
|
private static long[] |
_tokenSet_19_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_2
|
private static long[] |
_tokenSet_2_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_20
|
private static long[] |
_tokenSet_20_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_21
|
private static long[] |
_tokenSet_21_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_22
|
private static long[] |
_tokenSet_22_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_23
|
private static long[] |
_tokenSet_23_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_24
|
private static long[] |
_tokenSet_24_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_25
|
private static long[] |
_tokenSet_25_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_26
|
private static long[] |
_tokenSet_26_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_27
|
private static long[] |
_tokenSet_27_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_28
|
private static long[] |
_tokenSet_28_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_29
|
private static long[] |
_tokenSet_29_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_3
|
private static long[] |
_tokenSet_3_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_30
|
private static long[] |
_tokenSet_30_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_31
|
private static long[] |
_tokenSet_31_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_32
|
private static long[] |
_tokenSet_32_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_33
|
private static long[] |
_tokenSet_33_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_34
|
private static long[] |
_tokenSet_34_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_35
|
private static long[] |
_tokenSet_35_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_36
|
private static long[] |
_tokenSet_36_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_37
|
private static long[] |
_tokenSet_37_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_38
|
private static long[] |
_tokenSet_38_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_39
|
private static long[] |
_tokenSet_39_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_4
|
private static long[] |
_tokenSet_4_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_40
|
private static long[] |
_tokenSet_40_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_5
|
private static long[] |
_tokenSet_5_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_6
|
private static long[] |
_tokenSet_6_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_7
|
private static long[] |
_tokenSet_7_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_8
|
private static long[] |
_tokenSet_8_data_
|
static antlr.collections.impl.BitSet |
_tokenSet_9
|
private static long[] |
_tokenSet_9_data_
|
private ParamInfo |
auxExpAssig
Auxiliar, per saber la info de la variable en una inst. d'assignacio. |
private java.lang.String |
EXT_DEF
Constant que defineix l'extensió per defecte dels fitxers pseudocodi d'entrada. |
private int |
ID_NOT_DECLARED
Constant per identificar quan un ID o un camp d'una classe no s'ha declarat. |
private java.lang.String |
inFilename
Nom del fitxer d'entrada que es tracta. |
private boolean |
isFirstInstruction
Per saber si super() és la primera instrucció d'un constructor |
private java.lang.String |
LONGITUT_OF_TAULA
Constant que defineix un mètode acceptat en les taules. |
private int |
numAvisos
Informació del traductor, per imprimir al final del tractament. |
private int |
numErrors
Informació del traductor, per imprimir al final del tractament. |
private CpcGenJava |
out
S'encarrega de generar el codi Java de sortida. |
private java.lang.String |
outFile
Nom del fitxer de sortida que es genera. |
private SymbolTable |
symbolTable
La taula de símbols utilitzada per el traductor |
private boolean |
verboseMode
Especifica si el mode verbose està activat. |
private java.lang.String |
version
Versió del traductor, que s'imprimeix en els fitxers de sortida generats. |
Fields inherited from class antlr.LLkParser |
|
Fields inherited from class antlr.Parser |
astFactory, inputState, returnAST, tokenNames, traceDepth |
Fields inherited from interface PseudocodiTokenTypes |
ACCIO, ALGORISME, ALTRAMENT, ATRIBUTS, ATRIBUTS_CLASSE, BOOLEA, CARACTER, CAS, CERT, CLASS_DEF, CLASS_TYPE, CLASSE, COMA, COMENTARI1, COMENTARI2, CONST, CONSTRUCTOR, CORXET_DRET, CORXET_ESQ, CREAR, DE, DESTRUCTOR, DESTRUIR, DIV, DOSPUNTS, ELEMENTAL_TYPE, ENTER, EOF, ESCRIURE, ESCRIURELN, ESPAIS_BLANC, EXPONENT, FALGORISME, FALS, FATRIBUTS, FATRIBUTS_CLASSE, FCAS, FCLASSE, FCONST, FCONSTRUCTOR, FDESTRUCTOR, FER, FFUNCIO, FIMPLEMENTACIO, FINS, FINTERFICIE, FMENTRE, FMETODE, FMETODE_CLASSE, FMETODES, FMETODES_CLASSE, FPER, FSI, FUNCIO, FVAR, HERETA, IDENTIFICADOR, IMPLEMENTACIO, INTERFICIE, JO, LITERAL_CADENA, LITERAL_CARACTER, LLAVORS, LLEGIR, MEMBRE_CLASSE, MENTRE, METODE, METODE_CLASSE, METODES, METODES_CLASSE, MOD, NULL, NULL_TREE_LOOKAHEAD, NUMERO, NUMERO_ENTER, NUMERO_REAL, OP_ASSIGNACIO, OP_CAS, OP_DIFERENT, OP_DIV, OP_I, OP_IGUAL, OP_MGRAN, OP_MGRAN_IGUAL, OP_MPETIT, OP_MPETIT_IGUAL, OP_MULT, OP_NO, OP_O, OP_RESTA, OP_SUMA, PAREN_DRET, PAREN_ESQ, PAS, PER, PRIVATE, PUBLIC, PUNT, PUNTCOMA, REAL, RES, RETORNA, SALT_LINIA, SI, SUPER, SUPER_CLASS, TAULA, VAR |
Constructor Summary | |
|
CpcParser(antlr.ParserSharedInputState state)
|
|
CpcParser(antlr.TokenBuffer tokenBuf)
|
protected |
CpcParser(antlr.TokenBuffer tokenBuf,
int k)
|
|
CpcParser(antlr.TokenStream lexer)
|
protected |
CpcParser(antlr.TokenStream lexer,
int k)
|
Method Summary | |
void |
acces_taula(java.lang.String varName,
ParamInfo indexInf)
|
void |
algorisme()
|
void |
bloc_algorisme()
REGLES COMUNES: VARIABLES,DECLARACIONS,INSTRUCCIONS, etc. |
void |
bloc_atribut_classe()
|
void |
bloc_atribut()
|
void |
bloc_classe()
|
void |
bloc_implementacio()
|
void |
bloc_instruccions()
|
void |
bloc_interficie()
|
void |
bloc_metode_classe()
|
void |
bloc_metode()
|
void |
capzalera_constructor(boolean declararAmbit)
|
void |
capzalera_destructor(boolean declararAmbit)
|
void |
capzalera_funcio(boolean declararAmbit)
|
void |
capzalera_mentre()
|
void |
capzalera_metode_classe(boolean declararAmbit)
|
void |
capzalera_metode(boolean declararAmbit)
|
void |
capzalera_per()
|
private void |
checkAccesTable(ParamInfo factInf,
ParamInfo tableInf,
int linia)
Tracta l'acces a una taula, i comprova que les dimensions concordin |
private void |
checkAllMetodesImplemented(int linia)
Comprova que tots els membres de la interficie estiguin implementats |
private ParamInfo |
checkFuncParams(java.util.LinkedList list,
ParamInfo[] parParams,
int nParParams,
int linia)
Comprova que els parametres passats a la funcio, siguin correctes (te en compte sobrecarrega de noms) |
private void |
checkIsDefinedInInterficie(java.lang.String scopeName,
ParamInfo[] params,
int numParams,
int linia)
Comprova que el metode estigui declarat en la interficie. |
private ParamInfo |
checkParametersOfFunction(java.lang.String varName,
java.lang.String className,
int cridaType,
java.util.LinkedList list,
ParamInfo[] parParams,
int numParams,
int linia)
Comprova els parametres de la funcio. |
private void |
checkSuperIsFirstStatement(int linia)
Comprova que super es la primera instruccio del constructor |
private int |
checkTypes(ParamInfo pInf1,
ParamInfo pInf2,
boolean doAutoCast,
boolean reportError,
int linia)
Comprova que els dos tipus siguin compatibles. |
int |
classe()
|
void |
closeOutFile()
Tanca el fitxer de sortida en el que escrivia |
boolean |
cond_cas(boolean firstCond)
|
void |
constructor()
|
private void |
copyNodeToParamInfo(TNode node,
ParamInfo idInf,
java.lang.String text)
Copia la informacio desada en la TS (TNode) a la informacio del parametre ParamInfo |
int |
corxets(int dim)
|
ParamInfo |
crida_funcio(java.lang.String varName,
java.lang.String className,
int cridaType)
|
void |
declar_atributs()
|
void |
declar_const(int typeDecl)
|
void |
declar_var(int typeDecl)
|
private void |
declararConstant(java.lang.String varName,
int Type,
java.lang.String expressio,
int typeDecl,
int linia)
Declara una constant en l'ambit actual de la TS |
private void |
declararFuncio(java.lang.String scopeName,
ParamInfo[] params,
int numParams,
ParamInfo retParam,
boolean declararAmbit,
int linia,
int funcType)
Declara una funcio/metode/metode de classe/constructor/destructor en la TS |
private void |
declararFuncioAmbitActual(java.lang.String scopedName,
ParamInfo[] params,
int numParams,
ParamInfo retParam,
int funcType,
int linia)
Declara una funcio/metode/metode de classe/constructor/destructor en l'ambit actual, de tal manera que sigui visible en l'ambit i pugui ser cridada. |
private void |
declararVariable(java.lang.String varName,
int idType,
int type,
int dimension,
java.lang.String typeClassName,
int typeDecl,
int linia)
Declara una variable en l'ambit actual de la TS |
void |
destructor()
|
ParamInfo |
expressio_simple()
|
ParamInfo |
expressio()
|
ParamInfo |
factor()
|
void |
funcio()
|
private java.lang.String |
genRandomName()
Genera un nom a l'atzar per el fitxer temporal de sortida |
private java.lang.String |
getElementalTypeName(int type)
Retorna el nom del tipus elemental passat com constant entera representativa (enter, real,...). |
private java.lang.String |
getFuncToString(java.lang.String varName,
ParamInfo[] parParams,
int numParams)
Retorna la funció amb els tipus dels parametres formatejats, de tal manera que són llegibles per l'usuari. |
private int |
getHash(java.lang.String className)
Retorna un numero únic representatiu pera cada classe de pseudocodi amb una funcio hash. |
private java.util.LinkedList |
getListOfFunctions(java.lang.String varName,
java.lang.String className,
int linia)
Retorna el node que conte la informacio de la funcio |
int |
getNumAvisos()
Retorna el numero d'avisos generats |
java.lang.String |
getOutFile()
Retorna el nom de fitxer de sortida en el que s'escriu |
SymbolTable |
getSymbolTable()
Retorna la TS confeccionada fins al moment |
private java.lang.String |
getTypeName(ParamInfo parInf)
Retorna un String que representa el nom del tipus, ja sigui elemental o una classe. |
ParamInfo |
index_taula(java.lang.String varName)
|
void |
inst_assignacio_crida_funcio()
|
void |
inst_cas()
|
ParamInfo |
inst_crear()
|
void |
inst_destruir()
|
void |
inst_escriure()
|
void |
inst_escriureln()
|
ParamInfo |
inst_llegir()
|
void |
inst_mentre()
|
void |
inst_per()
|
void |
inst_res()
|
void |
inst_retorna()
|
void |
inst_si_llavors()
|
void |
instruccio_ratlla()
|
void |
instruccio_simple()
|
void |
instruccions()
Instruccions |
private ParamInfo |
isDeclaredId(java.lang.String id,
int linia,
java.util.LinkedList list)
Comprova que l'identificador estigui declarat, i retorna la info que ens interesa de la TS |
private ParamInfo |
isDeclaredIdOfClass(java.lang.String id,
ParamInfo classInf,
int linia)
Comprova que l'identificador estigui declarat en la classe, i retorna la info de la TS. |
private boolean |
isDefinedFuncInList(java.util.LinkedList list,
ParamInfo[] params,
int numParams)
Comprova si la funcio està definida, tot comprovant la signatura de les funcions de la llista. |
private boolean |
isEqualsParamsFunc(ParamInfo[] params1,
int nParams1,
ParamInfo[] params2,
int nParams2)
Comprova si els parametres d'una funcio son iguals als d'un altra. |
private void |
isIdFunction(ParamInfo destInf,
int linia)
|
private boolean |
isStoreVariable(ParamInfo var1,
int linia)
Comprova que la variable sigui adequada per una assignacio. |
void |
llista_const(int typeDecl)
VIGILAR expressio A L'HORA DE DECLARAR |
void |
llista_identif(java.lang.String[] declName,
int index)
|
void |
llista_var(int typeDecl)
|
private void |
loadClassToSimbolTable(java.lang.String classname,
int linia)
Carrega tot el que es public d'una classe (la seva interficie). |
void |
metode_classe()
|
void |
metode()
|
java.lang.String |
op_div()
|
java.lang.String |
op_mod()
|
java.lang.String |
op_mult_div()
|
java.lang.String |
op_relacional()
|
java.lang.String |
op_suma_resta()
|
private void |
openOutFilename()
Obre el fitxer de sortida per a poder escriure-hi. |
ParamInfo |
operant()
|
ParamInfo |
parametre_actual()
|
ParamInfo |
parametre()
|
int |
parametres_actuals(ParamInfo[] parParams,
int index,
ParamInfo textInf)
|
int |
parametres_formals(ParamInfo[] params,
int index)
|
ParamInfo |
parametres_retorn()
|
ParamInfo |
post_variable(ParamInfo typeInf)
|
int |
programa(boolean isNeedBeClass)
Regla principal, que engloba qualsevol fitxer de pseudocodi. |
void |
reportError(PSemanticException ex)
Funcio de reportar errors semàntics. |
void |
reportError(antlr.RecognitionException ex)
Sobreescriu la funcio de reportar errors sintàctics. |
void |
reportWarning(PSemanticWarning ex)
Sobreescriu la funció de reportar avisos (Warnings). |
void |
sepa_inst()
sepa_inst: regla que especifica el separador d'instruccions |
void |
setInputFilename(java.lang.String filename)
Especifica el nom del fitxer d'entrada per imprimir-lo ens els missatges d'errors |
void |
setVerboseMode(boolean verbose)
Especifica si esta actiu el mode Verbose, que reporta a l'usuari molta informacio referent a les tasques que duu a terme el traductor |
void |
setVersion(java.lang.String ver)
Especifica la versio del traductor, que s'escriu en els fitxers generats. |
ParamInfo |
tipus_compost()
|
int |
tipus_elemental()
|
ParamInfo |
tipus_simple()
|
ParamInfo |
tipus()
|
private java.lang.String |
toStringSuperClassName()
Retorna el nom de la classe pare. |
private void |
tractarFitxerFinal()
|
private void |
tractarHerencia(java.lang.String className,
int linia)
Tracta l'herencia de la classe, quan aquesta es declarada |
private void |
tractarInstAssig(ParamInfo destInf,
ParamInfo sourceInf,
int linia)
Tracta l'instruccio d'assignacio: Fa comprobacions semantiques i la traduccio. |
private void |
tractarInstCas(ParamInfo condInf,
boolean firstCond,
int linia)
Tracta l'instruccio cas: Fa les comprovacions semantiques i la corresponent traduccio |
private void |
tractarInstCrida(ParamInfo cridaInf,
int linia)
Tracta l'instruccio que es una crida a una accio/funcio: fa comprovacions semantiques i la corresponent traduccio |
private void |
tractarInstPer(ParamInfo varInf,
ParamInfo iniExp,
ParamInfo endExp,
ParamInfo pasExp,
int linia)
Tracta l'instruccio per: fa comprovacions semantiques i la corresponent traduccio |
private void |
tractarInstSi(ParamInfo condInf,
int linia)
Tracta l'instruccio si: Fa comprovacions semantiques i la corresponent traduccio |
private void |
tractarJo(ParamInfo factInf)
Tracta quan es troba la referencia a la propia classe: JO, modificant el ParamInfo |
private int |
tryCast(ParamInfo destInf,
ParamInfo pInf1,
ParamInfo pInf2,
int linia)
Intenta fer cast de tipus elementals. |
private boolean |
tryObjectCast(ParamInfo pReq,
ParamInfo pPar)
Comprova si es pot fer un cast entre classes, tot utilitzant la herencia de classes |
java.lang.String |
val_boolea()
|
ParamInfo |
variable()
|
Methods inherited from class antlr.LLkParser |
consume, LA, LT, traceIn, traceOut |
Methods inherited from class antlr.Parser |
addMessageListener, addParserListener, addParserMatchListener, addParserTokenListener, addSemanticPredicateListener, addSyntacticPredicateListener, addTraceListener, consumeUntil, consumeUntil, defaultDebuggingSetup, getAST, getASTFactory, getFilename, getInputState, getTokenName, getTokenNames, isDebugMode, mark, match, match, matchNot, panic, removeMessageListener, removeParserListener, removeParserMatchListener, removeParserTokenListener, removeSemanticPredicateListener, removeSyntacticPredicateListener, removeTraceListener, reportError, reportWarning, rewind, setASTFactory, setASTNodeClass, setASTNodeType, setDebugMode, setFilename, setIgnoreInvalidDebugCalls, setInputState, setTokenBuffer, traceIndent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private final int ID_NOT_DECLARED
private final java.lang.String EXT_DEF
private final java.lang.String LONGITUT_OF_TAULA
Constant que defineix un mètode acceptat en les taules.
nomTaula.longitud() retorna un enter que especifica la llargària amb que s'ha instanciat la taula.
private SymbolTable symbolTable
private CpcGenJava out
private java.lang.String inFilename
private java.lang.String outFile
private java.lang.String version
private ParamInfo auxExpAssig
private int numErrors
private int numAvisos
private boolean isFirstInstruction
private boolean verboseMode
En cas afirmatiu treu missatges informatius durant el procés de traducció
public static final java.lang.String[] _tokenNames
private static final long[] _tokenSet_0_data_
public static final antlr.collections.impl.BitSet _tokenSet_0
private static final long[] _tokenSet_1_data_
public static final antlr.collections.impl.BitSet _tokenSet_1
private static final long[] _tokenSet_2_data_
public static final antlr.collections.impl.BitSet _tokenSet_2
private static final long[] _tokenSet_3_data_
public static final antlr.collections.impl.BitSet _tokenSet_3
private static final long[] _tokenSet_4_data_
public static final antlr.collections.impl.BitSet _tokenSet_4
private static final long[] _tokenSet_5_data_
public static final antlr.collections.impl.BitSet _tokenSet_5
private static final long[] _tokenSet_6_data_
public static final antlr.collections.impl.BitSet _tokenSet_6
private static final long[] _tokenSet_7_data_
public static final antlr.collections.impl.BitSet _tokenSet_7
private static final long[] _tokenSet_8_data_
public static final antlr.collections.impl.BitSet _tokenSet_8
private static final long[] _tokenSet_9_data_
public static final antlr.collections.impl.BitSet _tokenSet_9
private static final long[] _tokenSet_10_data_
public static final antlr.collections.impl.BitSet _tokenSet_10
private static final long[] _tokenSet_11_data_
public static final antlr.collections.impl.BitSet _tokenSet_11
private static final long[] _tokenSet_12_data_
public static final antlr.collections.impl.BitSet _tokenSet_12
private static final long[] _tokenSet_13_data_
public static final antlr.collections.impl.BitSet _tokenSet_13
private static final long[] _tokenSet_14_data_
public static final antlr.collections.impl.BitSet _tokenSet_14
private static final long[] _tokenSet_15_data_
public static final antlr.collections.impl.BitSet _tokenSet_15
private static final long[] _tokenSet_16_data_
public static final antlr.collections.impl.BitSet _tokenSet_16
private static final long[] _tokenSet_17_data_
public static final antlr.collections.impl.BitSet _tokenSet_17
private static final long[] _tokenSet_18_data_
public static final antlr.collections.impl.BitSet _tokenSet_18
private static final long[] _tokenSet_19_data_
public static final antlr.collections.impl.BitSet _tokenSet_19
private static final long[] _tokenSet_20_data_
public static final antlr.collections.impl.BitSet _tokenSet_20
private static final long[] _tokenSet_21_data_
public static final antlr.collections.impl.BitSet _tokenSet_21
private static final long[] _tokenSet_22_data_
public static final antlr.collections.impl.BitSet _tokenSet_22
private static final long[] _tokenSet_23_data_
public static final antlr.collections.impl.BitSet _tokenSet_23
private static final long[] _tokenSet_24_data_
public static final antlr.collections.impl.BitSet _tokenSet_24
private static final long[] _tokenSet_25_data_
public static final antlr.collections.impl.BitSet _tokenSet_25
private static final long[] _tokenSet_26_data_
public static final antlr.collections.impl.BitSet _tokenSet_26
private static final long[] _tokenSet_27_data_
public static final antlr.collections.impl.BitSet _tokenSet_27
private static final long[] _tokenSet_28_data_
public static final antlr.collections.impl.BitSet _tokenSet_28
private static final long[] _tokenSet_29_data_
public static final antlr.collections.impl.BitSet _tokenSet_29
private static final long[] _tokenSet_30_data_
public static final antlr.collections.impl.BitSet _tokenSet_30
private static final long[] _tokenSet_31_data_
public static final antlr.collections.impl.BitSet _tokenSet_31
private static final long[] _tokenSet_32_data_
public static final antlr.collections.impl.BitSet _tokenSet_32
private static final long[] _tokenSet_33_data_
public static final antlr.collections.impl.BitSet _tokenSet_33
private static final long[] _tokenSet_34_data_
public static final antlr.collections.impl.BitSet _tokenSet_34
private static final long[] _tokenSet_35_data_
public static final antlr.collections.impl.BitSet _tokenSet_35
private static final long[] _tokenSet_36_data_
public static final antlr.collections.impl.BitSet _tokenSet_36
private static final long[] _tokenSet_37_data_
public static final antlr.collections.impl.BitSet _tokenSet_37
private static final long[] _tokenSet_38_data_
public static final antlr.collections.impl.BitSet _tokenSet_38
private static final long[] _tokenSet_39_data_
public static final antlr.collections.impl.BitSet _tokenSet_39
private static final long[] _tokenSet_40_data_
public static final antlr.collections.impl.BitSet _tokenSet_40
Constructor Detail |
protected CpcParser(antlr.TokenBuffer tokenBuf, int k)
public CpcParser(antlr.TokenBuffer tokenBuf)
protected CpcParser(antlr.TokenStream lexer, int k)
public CpcParser(antlr.TokenStream lexer)
public CpcParser(antlr.ParserSharedInputState state)
Method Detail |
public void reportError(antlr.RecognitionException ex)
Sobreescriu la funcio de reportar errors sintàctics.
Canvia una mica el missatge desat en l'excepcio per a que sigui igual al que surt quan es reporten missatges semàntics. En acabat, incrementa la variable de comptatge d'errors.
reportError
in class antlr.Parser
public void reportError(PSemanticException ex)
Funcio de reportar errors semàntics.
Imprimeix per pantalla l'error i incrementa la variable de comptatge d'errors.
public void reportWarning(PSemanticWarning ex)
Sobreescriu la funció de reportar avisos (Warnings).
Imprimeix per pantalla l'avís i incrementa la variable de comptatge d'avisos.
private java.lang.String getFuncToString(java.lang.String varName, ParamInfo[] parParams, int numParams)
private java.lang.String getTypeName(ParamInfo parInf)
private java.lang.String getElementalTypeName(int type)
Retorna el nom del tipus elemental passat com constant entera representativa (enter, real,...).
La constant està definida en la interfície PseudocodiTokenTypes.
private int getHash(java.lang.String className)
private void declararVariable(java.lang.String varName, int idType, int type, int dimension, java.lang.String typeClassName, int typeDecl, int linia)
private void declararConstant(java.lang.String varName, int Type, java.lang.String expressio, int typeDecl, int linia)
private void declararFuncio(java.lang.String scopeName, ParamInfo[] params, int numParams, ParamInfo retParam, boolean declararAmbit, int linia, int funcType)
private void declararFuncioAmbitActual(java.lang.String scopedName, ParamInfo[] params, int numParams, ParamInfo retParam, int funcType, int linia)
private boolean isDefinedFuncInList(java.util.LinkedList list, ParamInfo[] params, int numParams)
private boolean isEqualsParamsFunc(ParamInfo[] params1, int nParams1, ParamInfo[] params2, int nParams2)
private void checkAllMetodesImplemented(int linia)
private void checkIsDefinedInInterficie(java.lang.String scopeName, ParamInfo[] params, int numParams, int linia)
private boolean isStoreVariable(ParamInfo var1, int linia)
Comprova que la variable sigui adequada per una assignacio.
En cas que no ho sigui, mostra el missatge en pantalla.
private void isIdFunction(ParamInfo destInf, int linia)
private ParamInfo isDeclaredId(java.lang.String id, int linia, java.util.LinkedList list)
private ParamInfo isDeclaredIdOfClass(java.lang.String id, ParamInfo classInf, int linia)
Comprova que l'identificador estigui declarat en la classe, i retorna la info de la TS.
El que fa és comprovar que el camp estigui declarat com a visible en la definició de la classe
private void copyNodeToParamInfo(TNode node, ParamInfo idInf, java.lang.String text)
private void checkAccesTable(ParamInfo factInf, ParamInfo tableInf, int linia)
private java.util.LinkedList getListOfFunctions(java.lang.String varName, java.lang.String className, int linia)
private ParamInfo checkParametersOfFunction(java.lang.String varName, java.lang.String className, int cridaType, java.util.LinkedList list, ParamInfo[] parParams, int numParams, int linia)
private ParamInfo checkFuncParams(java.util.LinkedList list, ParamInfo[] parParams, int nParParams, int linia)
private int checkTypes(ParamInfo pInf1, ParamInfo pInf2, boolean doAutoCast, boolean reportError, int linia)
Comprova que els dos tipus siguin compatibles.
Si doAutocast es cert, llavors intenta fer un cast automatic.
Si reportError es cert, en cas que siguin incompatibles mostrara un missatge d'error.
private boolean tryObjectCast(ParamInfo pReq, ParamInfo pPar)
private int tryCast(ParamInfo destInf, ParamInfo pInf1, ParamInfo pInf2, int linia)
private void tractarInstAssig(ParamInfo destInf, ParamInfo sourceInf, int linia)
private java.lang.String toStringSuperClassName()
private void tractarInstCrida(ParamInfo cridaInf, int linia)
private void tractarInstPer(ParamInfo varInf, ParamInfo iniExp, ParamInfo endExp, ParamInfo pasExp, int linia)
private void tractarInstSi(ParamInfo condInf, int linia)
private void tractarInstCas(ParamInfo condInf, boolean firstCond, int linia)
private void tractarJo(ParamInfo factInf)
private void checkSuperIsFirstStatement(int linia)
public void setVersion(java.lang.String ver)
public void setVerboseMode(boolean verbose)
public void setInputFilename(java.lang.String filename)
private void openOutFilename()
private java.lang.String genRandomName()
private void tractarHerencia(java.lang.String className, int linia)
public SymbolTable getSymbolTable()
public int getNumAvisos()
public java.lang.String getOutFile()
public void closeOutFile()
private void loadClassToSimbolTable(java.lang.String classname, int linia)
Carrega tot el que es public d'una classe (la seva interficie).
Per fer-ho, intenta traduir el fitxer de classe. Un cop traduit, agafa la taula de simbols generada per la traduccio de la classe externai la desa en un node. Aquest node es introduit en la nostra TS, tot identificant-lo com una definicio de classe (CLASS_DEF).
private void tractarFitxerFinal()
public final int programa(boolean isNeedBeClass) throws antlr.RecognitionException, antlr.TokenStreamException
Regla principal, que engloba qualsevol fitxer de pseudocodi.
Aquesta regla es la que s'ha de cridar per poder parsejar un fitxer. El parametre boolea isNeedBeClass especifica, si es cert, que el fitxer a tractar ha de ser obligatoriament una classe.
antlr.RecognitionException
antlr.TokenStreamException
public final void sepa_inst() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void algorisme() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final int classe() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_algorisme() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_classe() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_interficie() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_implementacio() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_atribut_classe() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_atribut() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_metode_classe() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_metode() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void declar_atributs() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void declar_var(int typeDecl) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void declar_const(int typeDecl) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void capzalera_constructor(boolean declararAmbit) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void capzalera_metode(boolean declararAmbit) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void capzalera_metode_classe(boolean declararAmbit) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void funcio() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void metode() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void metode_classe() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void constructor() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void destructor() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final int parametres_formals(ParamInfo[] params, int index) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo parametres_retorn() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void bloc_instruccions() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void capzalera_funcio(boolean declararAmbit) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void capzalera_destructor(boolean declararAmbit) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo parametre() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo tipus() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void instruccions() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo tipus_simple() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo tipus_compost() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final int tipus_elemental() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final int corxets(int dim) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void llista_var(int typeDecl) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void llista_identif(java.lang.String[] declName, int index) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void llista_const(int typeDecl) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo expressio() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo variable() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo post_variable(ParamInfo typeInf) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo crida_funcio(java.lang.String varName, java.lang.String className, int cridaType) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo index_taula(java.lang.String varName) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final int parametres_actuals(ParamInfo[] parParams, int index, ParamInfo textInf) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo parametre_actual() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void acces_taula(java.lang.String varName, ParamInfo indexInf) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final java.lang.String op_suma_resta() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final java.lang.String op_mult_div() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final java.lang.String op_mod() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final java.lang.String op_div() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final java.lang.String op_relacional() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo factor() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final java.lang.String val_boolea() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo operant() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo expressio_simple() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo inst_crear() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParamInfo inst_llegir() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void instruccio_ratlla() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void instruccio_simple() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_assignacio_crida_funcio() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_si_llavors() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_cas() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_mentre() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_per() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_res() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_escriure() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_escriureln() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_destruir() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void inst_retorna() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final boolean cond_cas(boolean firstCond) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void capzalera_mentre() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void capzalera_per() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |