UNIVERSIDAD NACIONAL DE
LOJA
ÁREA DE LA ENERGÍA, LAS INDUSTRIAS Y LOS
RECURSOS NATURALES NO RENOVABLES.
CARRERA DE INGENIERIA EN SISTEMAS
MODULO IX
“PROYECTOS FINAL”
TEMA:
Análisis semántico
INTEGRANTES :
CatalinaCobos
CarlaEspinosa
LOJA 2010
Desarrollo del Ejercicio
Paraunamejorcomprensiónyelaboracióndelas
reglassemánticascomenzaremosconstruyendoun
árbolapartirdeunacadenavalida.
CadenaFloatx , y
Para irnos ayudando podemos ir realizando las derivaciones
como se muestra a continuación
Decla
Type Var-List
decl
var-listtype
2. Construimos el árbol a partir de la cadena:
Float x , y
1. Partimos de la gramática
Dtype =real
Decla
Type Var-List
Float
decl id, var-list
float
type
id var-list
var-listtype
,
dtype
type = int Integer
type = float Real
Dtype =real
Decla
Type Var-List
Float
Necesita
encontrar
este valor
Tomamos el
valor del
hermano Type
Dtype =real
decl id, var-list
float
type
id var-list
var-listtype
,
Dtype =real
Decla
Type Var-List
Float
Necesita
encontrar
este valor
Tomamos el
valor del
hermano Type
decl id, var-list
float
type
id var-list
id id
var-listtype
float
,
,
Dtype =real
Dtype =real
Decla
Type Var-List
Float
Dtype =real
decl id, var-list
float
type
id var-list
id id
var-listtype
float
,
,
Dtype =real
Decla
Type Var-List1
Float
id , Var-list2
Necesita encontrar
estos valores
Heredamos del
atributo padre
Var-list
Dtype =real
Dtype =real
Dtype =real
Decla
Type Var-List1
Float
id , Var-list2
Dtype =realDtype =real
Dtype =real
Dtype =real
Decla
Type Var-List1
Float
id , Var-list2
decl id, var-list
float
type
id var-list
id id
var-listtype
X Y
float
float
,
,
,
Dtype =real
Dtype =realDtype =real
Dtype =real
Dtype =real
Decla
Type
Var-List1
Float
id ,
Var-list2
id
Dtype =real
Dtype =realDtype =real
Dtype =real
Dtype =real
Decla
Type
Var-List1
Float
id ,
Var-list2
id
Float x , y
Finalmentela tabla nos quedaría
así:
ReglaGramatical Reglas Semánticas
decltype var-list
type int
type float
var-list1id, var-list2
var-listid
var-list.dtype= type.dtype
type.dtype=integer
type.dtype= real
id.dtype= var-list1.dtype
var-list2.dtype = var-list1.dtype
id.dtype= var-list.dtype