1 / 9

CI-1322 Autómatas y Compiladores Sebastián Argüello Carné: A60490

Construcción de una gramática LL(1), construcción de la tabla y análisis de una hilera de la gramática. CI-1322 Autómatas y Compiladores Sebastián Argüello Carné: A60490. Gramática. E -> Ex E -> yB E -> yA B -> bA B -> bbA A -> ε Esta gramática no es LL(1), se debe convertir.

ohio
Télécharger la présentation

CI-1322 Autómatas y Compiladores Sebastián Argüello Carné: A60490

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Construcción de una gramática LL(1), construcción de la tabla y análisis de una hilera de la gramática CI-1322 Autómatas y Compiladores Sebastián Argüello Carné: A60490

  2. Gramática • E -> Ex • E -> yB • E -> yA • B -> bA • B -> bbA • A -> ε • Esta gramática no es LL(1), se debe convertir

  3. 1. Factorizar la gramática • E -> Ex • E -> yE’ • E’ -> A │B • B -> bB’ • B’ -> A │ bA • A -> ε • Esta es una gramática factorizada pero tiene recursividad izquierda.

  4. 2. Eliminar recursividad izquierda • E -> y E’ E’’ • E’’ -> xE’’ │ ε • E’ -> A │B • B -> bB’ • B’ -> A │ bA • A -> ε • Así obtenemos una nueva gramática que no tiene recursividad izquierda

  5. 3. Obtener el conjunto PRIMERO (Pr) • Pr (E) = {y} • Pr (E’) = {ε, b} • Pr (E’’) = {x, ε} • Pr (B) = {b} • Pr (B’) = {ε, b} • Pr (A) = {ε} • Conjunto PRIMERO de todos las producciones no terminales de la gramática.

  6. 4. Obtener el conjunto SIGUIENTE (Sg) • Sg (S) = {$} • Sg (S’) = {$} • Sg (S’’) = {x , $} • Sg (B) = {x , $} • Sg (B’) = {x , $} • Sg (A) = { x, $} • Conjunto SIGUIENTE de los no terminales de la gramática.

  7. 4.Obtener la tabla LL(1) Algunas reglas generales • El ε se coloca en la fila del símbolo del lado izquierdo de la gramática, en la columna del carácter que sigue al símbolo del lado izquierdo en la parte derecha de alguna producción. • Cuando un no terminal está al final de una producción se agrega al Siguiente del no terminal del lado izquierdo de la producción.

  8. 4. Obtener la Tabla LL(1) (cont)

  9. Paso 5. Realizar un análisis de una hilera ybxx

More Related