pascal.cup
Páginas: 4 (838 palabras)
Publicado: 18 de enero de 2014
// Declaración de importaciones
//(No modificar las proporcionadas. Se pueden agregar mas)
import java_cup.runtime.Symbol;
import java.util.*;
importes.uned.lsi.compiler.lexical.*;
import es.uned.lsi.compiler.code.*;
import es.uned.lsi.compiler.intermediate.*;
import es.uned.lsi.compiler.semantic.*;
import es.uned.lsi.compiler.semantic.symbol.*;
importes.uned.lsi.compiler.semantic.type.*;
import es.uned.lsi.compiler.syntax.*;
import compiler.CompilerContext;
import compiler.lexical.*;
import compiler.syntax.nonTerminal.*;
importcompiler.semantic.*;
import compiler.semantic.symbol.*;
import compiler.semantic.type.*;
import compiler.intermediate.*;
import compiler.code.*;
// Declaración del código de usuario
action code {:SyntaxErrorManager syntaxErrorManager = CompilerContext.getSyntaxErrorManager();
SemanticErrorManager semanticErrorManager = CompilerContext.getSemanticErrorManager ();
ScopeManagerIF scopeManager =CompilerContext.getScopeManager ();
FinalCodeFactoryIF finalCodeFactory = CompilerContext.getFinalCodeFactory ();
:}
parser code {:
SyntaxErrorManager syntaxErrorManager =CompilerContext.getSyntaxErrorManager();
public void syntax_error(Symbol symbol)
{
Token token = (Token) symbol.value;
syntaxErrorManager.syntaxError ("Error sintactico", token);
}
public voidunrecovered_syntax_error(java_cup.runtime.Symbol symbol)
{
Token token = (Token) symbol.value;
syntaxErrorManager.syntaxFatalError ("Error fatal", token);
}
:}
// Declaración de terminales (Ejemplo)terminal Token ABRE_PARENTESIS;
terminal Token ASIGNACION;
terminal Token BEGIN;
terminal Token BOOLEAN;
terminal Token CIERRA_PARENTESIS;
terminal Token COMA;
terminal Token CONSTANT;
terminalToken CONSTANTE_CADENA;
terminal Token CONSTANTE_NUMERICA;
terminal Token DECLARACION;
terminal Token PUNTOPUNTO;
terminal Token ELSE;
terminal Token END;
terminal Token FALSE;
terminal Token...
Leer documento completo
Regístrate para leer el documento completo.