A bottom-up parse corresponds to the construction of a parse tree for an input string beginning at the leaves (the bottom) and working up towards the root (the top).
We can think of bottom-up parsing as the process of “reducing” a string w to the start symbol of the grammar. At each reduction step, a specific substring matching the body of a production is replaced by the nonterminal at the head of that production.
The key decisions during bottom-up parsing are about when to reduce and about what production to apply, as the parse proceeds.
Right Most Derivation উল্টা করলে bottom up parsing tree পাওয়া যাই।
a “handle” is a substring that matches the body of a production, and whose reduction represents one step along the reverse of a rightmost derivation. যে substring গ্র্যামারের সাথে ম্যাচ খাই তাকে handle বলে। আর handle গুলোকে প্রোডাকশন হেডে কনভার্ট করে আস্তে আস্তে start symbol এ নিয়ে যেতে হবে।
Shift-reduce parsing is a form of bottom-up parsing in which a stack holds grammar symbols and an input buffer holds the rest of the string to be parsed.
We use $ to mark the bottom of the stack and also the right end of the input.
Initially the stack is empty and after doing everything the input will be empty and stack will have the starting symbol
এই ছবিটা লেকচার নোট থেকে কর। বেটার হবে।
there are actually four possible actions a shift-reduce parser can make: (1) shift, (2) reduce, (3) accept, and (4) error.