From 857809afbeda1930eeb1be66ddee2a537987e31d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 14 Jan 2016 12:18:45 -0500 Subject: [PATCH] LR0: Added parse algorithm --- src/LR0.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/LR0.cpp b/src/LR0.cpp index 9fdbe6d1..76b5087c 100644 --- a/src/LR0.cpp +++ b/src/LR0.cpp @@ -232,6 +232,36 @@ void LR0::createParseTable (States& states) } //////////////////////////////////////////////////////////////////////////////// +// "Compilers. Principles, Techniques, and Tools", Aho/Sethi/Ullman. p219. +// +// set ip to point to the first symbol of w$ +// repeat forever begin +// let s be the state on top of the stack +// let a be the symbol pointed to by ip +// +// if action[s,a] = shift s' then begin +// push a then s' on top of the stack +// advance ip to the next input symbol +// end +// +// else if action[s,a] = reduce A --> B then begin +// pop 2 * [B] symbols off the stack +// let s' be the state now at the top of the stack +// push A, then goto[s',A] on top of the stack +// output the production A --> B +// end +// +// else if then begin +// if action[s,a] = accept then begin +// return +// end +// end +// +// else +// error +// end +// end +// void LR0::parse (const std::string& input) { Lexer l (input);