SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
1.
Traducción Dirigida por la Sintaxis Capítulo 5 Sección 5.1 Leonel Morales Díaz [email_address] Copyright 2008 by Leonel Morales Díaz – Ingeniería Simple. Derechos reservados Disponible en: http://www.ingenieriasimple.com/compiladores
2.
Traducción dirigida por la sintaxis <ul><li>Asocia información a la construcción del lenguaje </li></ul><ul><ul><li>Atributos en los símbolos de la gramática </li></ul></ul><ul><li>Definiciones dirigidas por la sintaxis </li></ul><ul><li>Esquemas de traducción </li></ul>
3.
Proceso Cadena de entrada Arbol de análisis sintáctico Grafo de dependencias Orden de evaluación de las reglas semánticas
4.
Definiciones dirigidas por la sintaxis - DDpS <ul><li>Ocultan detalles de la implementación </li></ul><ul><li>Generalizan la gramática </li></ul><ul><li>Símbolos tienen atributos </li></ul><ul><ul><li>Atributos representan cualquier cosa </li></ul></ul><ul><ul><li>Valor de atributo por regla semántica </li></ul></ul><ul><ul><li>Atributo sintetizado: a partir de los hijos </li></ul></ul><ul><ul><li>Atributo heredado: a partir de padre y hermanos </li></ul></ul>
5.
Forma de DDpS <ul><li>Para cada producción A => α </li></ul><ul><ul><li>Reglas semánticas b = f(c 1 ,c 2 ,...,c k ) </li></ul></ul><ul><ul><li>b es atributo sintetizado de A </li></ul></ul><ul><ul><ul><li>c 1 ,c 2 ,...,c k son atributos de simbolos en la producción </li></ul></ul></ul><ul><ul><li>b es atributo heredado </li></ul></ul><ul><ul><ul><li>de algún símbolo del lado derecho (α) </li></ul></ul></ul><ul><ul><ul><li>c 1 ,c 2 ,...,c k son atributos de simbolos en la producción </li></ul></ul></ul>
6.
Ejemplo calculadora <ul><li>Producciones </li></ul><ul><li>L => E n </li></ul><ul><li>E => E 1 + T </li></ul><ul><li>E => T </li></ul><ul><li>T => T 1 * F </li></ul><ul><li>T => F </li></ul><ul><li>F => (E) </li></ul><ul><li>F => dígito </li></ul><ul><li>Reglas semánticas </li></ul><ul><li>Print(E.val) </li></ul><ul><li>E.val = E 1 .val + T.val </li></ul><ul><li>E.val = T.val </li></ul><ul><li>T.val = T 1 .val * F.val </li></ul><ul><li>T.val = F.val </li></ul><ul><li>F.val = E.val </li></ul><ul><li>F.val = dígito .valex </li></ul>
7.
Ejemplo declaración de tipos <ul><li>Producciones </li></ul><ul><li>D => T L </li></ul><ul><li>T => int </li></ul><ul><li>T => real </li></ul><ul><li>L => L 1 , id </li></ul><ul><li>L => id </li></ul><ul><li>Reglas semánticas </li></ul><ul><li>L.her = T.tipo </li></ul><ul><li>T.tipo = entero </li></ul><ul><li>T.tipo = real </li></ul><ul><li>L 1 .her = L.her </li></ul><ul><li>AgregarTipo( id .entrada,L.her) </li></ul><ul><li>AgregarTipo( id .entrada,L.her) </li></ul>
0 likes
Be the first to like this
Views
Total views
3,594
On SlideShare
0
From Embeds
0
Number of Embeds
45
You have now unlocked unlimited access to 20M+ documents!
Unlimited Reading
Learn faster and smarter from top experts
Unlimited Downloading
Download to take your learnings offline and on the go
You also get free access to Scribd!
Instant access to millions of ebooks, audiobooks, magazines, podcasts and more.
Read and listen offline with any device.
Free access to premium services like Tuneln, Mubi and more.