Professional Documents
Culture Documents
PROYECTO
1
2007-15008
PROYECTO 1:
OBJETIVOS:
Realizar un compilador de un lenguaje parecido al php para generar
un archivo html.
Aplicar lo aprendido en clases y laboratorio sobre tipos de
gramaticas y como llegar a una gramatica sin ambigedad.
Utilizar las herramientas jlex y cup.
Comenzar a utilizar el sistema operativo linux.
1) ;
2) :
3) ,
4) +
5)
6) *
7) /
8) <
9) >
10) =
11)
12) [
13) ]
14)
15) %
16) (
17) )
18)
EXPRESIONES REGULARES
1) numero = ([0-9])+
2) comi = \"
3) id = ([a-zA-Z])(([a-zA-Z]|[0-9])*)
4) real=({numero})+({punto})({numero})+
5) entero=({numero})+
6) char=("\"")([a-zA-Z])("\"")
7) comentario="/*"[^*]*"*/"
8) comentario2="//"[^\n]*
9) array=("[")([0-9]|[a-zA-Z])+("]")
10) string=("\"")([^\"]*)+("\"")
PALABRAS RESERVADAS
1) integer
2) real
3) bolean
4) var
5) and
6) char
7) or
8) and
9) trae
10) false
11) if
12) then
13) begin
14) else
15) end_if
16) case
17) echo
18) break
19) default
20) end_case
21) for
22) end_for
23) while
24) end_while
25) table
26) begin_fila
27) begin_columna
28) end_tabla
29) fin_fila
30) fin_columna
31) array
32) to
terminal
DOSPUNTOS,COMA,MENOS,MAS,ASTERISCO,MENORQ,IGUAL,MAYORQ,
ADMIRACION;
terminal
CORCHETEA,DIVISION,CORCHETEC,PUNTOYCOMA,COMILLA,ABRIRARCHIVO,FIN
ARCHIVO;
terminal
PARENTESISA, PARENTESISC, ENTERO, REAL, COMENTARIO, CHAR, ID,
ARRAY, INTEGER;
terminal
PALABRAREAL,BOOLEAN,VAR,PALABRACHAR,AND,OR,TRUE,FALSE,IF,THEN,BEGIN
,ELSE;
terminal
ENDIF,CASE,ECHO,BREAK,DEFAULT,ENDCASE,FOR,ENDFOR,WHILE,ENDWHILE,
TABLA;
terminal
BEGINFILA,BEGINCOLUMNA,ENDTABLA,ENDFILA,ENDCOLUMNA,PALABRAARRAY,
TO,STRING;
non terminal
inicio,tipoVar,tipoVar2,asignacionI,evaluacionExpresiones,s5,s7,s8,s9,s11;
non terminal
asignacionC,asignacionR,asignacionB,valoresB,declaracionVariables;
non terminal
evaluaciones, evaluacionGenerica, operadores1,
operadoresBooleanos;
non terminal
operadorConcatenacion,operadorMultiplicacion,
operadoresAritmeticos;
non terminal
operadorAgrupacion, operadores2, operandos, operandosNumericos,
masOperaciones2;
non terminal
operandos1, operandos2, operandosM, masOperaciones,
masOperaciones3;
non terminal
operandos5, masOperaciones4, operandosNumericosC,masMenos, for,
evaluacionExpresiones2;
non terminal
asignacion, array, echo,if, condicion, else, valoresIf, while, yy, igual;
non terminal
comparadores, case, expresion, tipoDato, elecciones, default;
non Terminal
tabla, ifTabla, forTabla, whileTabla, caseTabla, datos3, creacionFila,
creacionColumna;
non Terminal
expre, eleccionesTabla, defaultTabla, elseTabla,filasColumnas;
operandosNumericos ::=ID
|REAL
|ENTERO
;
masOperaciones3 ::= MAS operandosNumericos masOperaciones
|MENOS operandosNumericos masOperaciones
|ASTERISCO operandosNumericos masOperaciones
;
forTabla ::= FOR ID DOSPUNTOS IGUAL ENTERO TO ENTERO BEGIN expre
ENDFOR
;
expre ::= creacionFila
| creacionColumna
;
creacionFila ::= BEGINFILA forTabla ENDFILA
;
creacionColumna ::= BEGINCOLUMNA echo ENDCOLUMNA
;