Documentos de Académico
Documentos de Profesional
Documentos de Cultura
import java.io.*;
import java_cup.runtime.*;
parser code
{:
public static void main(String args[]) throws Exception{
//new parser(new Yylex(new FileInputStream(args[0]))).parse();
new parser(new Yylex(System.in)).parse();
}
public void syntax_error(Symbol s){
String resultado="Error de sintaxis. Linea: " + (s.right + 1) +
" Columna: " + s.left + ". Texto: \"" + s.value + "\"";
report_error("Error de sintaxis. Linea: " + (s.right + 1) +
" Columna: " + s.left + ". Texto: \"" + s.value + "\"", null);
}
:}
Escaneo ::= SCANF PARIZQ COMI PORCE ID COMI COMA AMPER ID PARDER PYCOMA{:
System.out.println("Sentencia analizada correctamente. Sin errores); :}
;
E1 ::= Inicializacion
|
;
E2 ::= Condicion2
|
;
E3 ::= Incremento
|
;
Inicializacion ::= Inicializacion COMA INT ID IGUAL NUMERO
| INT ID IGUAL NUMERO
;
Condicion2 ::= Condicion2 COMA ID Comp NUMERO
| ID Comp NUMERO
;
Comp ::= DIFERENTE
| MAYORIGUAL
| MENORIGUAL
| MAYOR
| MENOR
| IGUAL
;
Incremento ::= Incremento COMA ID Inc
| ID Inc
;
Inc ::= MENOSNUM NUMERO
| MENOSUNO
| MASNUM NUMERO
| MASUNO
;