From 379c2f806ecbbc7aae7dc358cf7c698222475674 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 3 Jan 2016 16:42:13 -0500 Subject: [PATCH] LR0: Documented the ::initialize algorithm --- src/LR0.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/LR0.cpp b/src/LR0.cpp index 62175161..014e8c97 100644 --- a/src/LR0.cpp +++ b/src/LR0.cpp @@ -35,18 +35,11 @@ LR0::LR0 () } //////////////////////////////////////////////////////////////////////////////// -// Aho/Sethi/Ullman, p224 -// The sets-of-items construction: -// -// procedure items(G'); -// begin -// C := {closure ({[S' --> . S]})}; -// repeat -// for each set of items I in C and each grammar symbol X such that -// goto (I, X) is not empty and not in C do -// add goto (I, X) to C -// until no more sets of items can be added to C -// end +// Given a grammar: +// - Obtain the augmented grammar +// - Create the first state from the first augmented grammar rule +// - Expand the first state +// - Recursively create and expand all the other states void LR0::initialize (const Grammar& grammar) { // Obtain the augmented grammar.