viernes, 10 de febrero de 2017

Parseo simple



El siguiente ejercicio proviene del mismo lugar que uno publicado unos días atrás. Los datos del ejercicio que se mantienen igual, no se vuelven a exponer. En particular, la Parsing Action y Goto table son los mismos que en dicho artículo.


Lo que cambia es el input string, y obviamente el seguimiento del parser, manteniéndose iguales la pa (parsing action), la goto (goto table) y las reglas gramaticales.


Input string: a,,b
Acción
Raíces del árbol de derivación (y estado asociado)*
Input remanente
Inicialización: 0
(0)
a,,b $end
pa(0, ‘a’) => apilar
(0), ‘a’
,,b $end
goto(0, ‘a’) => 3
(0), ‘a’ (3)
,,b $end
pa(3, ‘,’) => reducir (3)
(0), ‘ELEMENT’
,,b $end
goto(0, ‘ELEMENT’) => 2
(0), ‘ELEMENT’ (2)
,,b $end
pa(2, ‘,’) => reducir (2)
(0), ‘LIST’
,,b $end
goto(0, ‘LIST’) => 1
(0), ‘LIST’ (1)
,,b $end
pa(1, ‘,’) => apilar
(0), ‘LIST’ (1), ‘,’
,b $end
goto(1, ‘,’) => 5
(0), ‘LIST’ (1), ‘,’ (5)
,b $end
pa(5, ‘,’) => error
(0), ‘LIST’ (1), ‘,’ (5)
,b $end

* Solamente el estado inicial (0) no está asociado a ninguna raíz.

No hay comentarios: