Understanding Lemon Generated Parser Finalvivekanandan r
This document describe how the Lemon generated LALR(1) parser code works step by step using the transition table.it also describe how the Shift Reduce done in the parser stack .
Kickstart your data science journey with this Python cheat sheet that contains code examples for strings, lists, importing libraries and NumPy arrays.
Find more cheat sheets and learn data science with Python at www.datacamp.com.
Understanding Lemon Generated Parser Finalvivekanandan r
This document describe how the Lemon generated LALR(1) parser code works step by step using the transition table.it also describe how the Shift Reduce done in the parser stack .
Kickstart your data science journey with this Python cheat sheet that contains code examples for strings, lists, importing libraries and NumPy arrays.
Find more cheat sheets and learn data science with Python at www.datacamp.com.
Programmation fonctionnelle en JavaScriptLoïc Knuchel
La programmation fonctionnelle permet de faire du code plus modulaire, avec moins de bugs et de manière plus productive !!!
Cette présentation montre comment la programmation fonctionnelle peut tenir se promesse et comment l'appliquer avec JavaScript.
I am Elias M. I am a Python Homework Expert at pythonhomeworkhelp.com. I hold a Master's in Computer Science from, the University of Calgary, Canada. I have been helping students with their homework for the past 7 years. I solve homework related to Python.
Visit pythonhomeworkhelp.com or email support@pythonhomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with Python Homework.
An introduction to functional programming with goEleanor McHugh
A crash course in functional programming concepts using Go. Heavy on code, light on theory.
You can find the examples at https://github.com/feyeleanor/intro_to_fp_in_go
Slides from my talk at Reversim 2021 convention (also passed a talk with the same slide at PyWeb-IL, 2022-03) in Tel-Aviv, Israel.
The recording of the talk is on youtube, here: https://www.youtube.com/watch?v=ahGLUdW3cqk&ab_channel=Reversim.
You can find more information, and services to help you get started on my website, https://propertybasedtesting.com.
The talk introduces property-based testing, a software testing technique that improves the ROI of automated tests.
While with standard tests, we need to work hard, hand-coding many examples - with property-based tests the computer generates hundreds or thousands of tests for us.
The random generation saves us a lot of effort, and also has a surprising tendency to come up with edge cases we would have never thought to test.
This helps us find bugs sooner and more easily, and have more confidence in our code.
The talk covered the basics of property-based tests.
It also gave the feeling for the power and variety of real-world use cases, by taking a CRUD web application and letting our test explore the application’s external API and find bugs in edge cases we didn’t know.
See the last slides for extra resources.
A Skeptics guide to functional style javascriptjonathanfmills
Modern JavaScript seems to be split between the object oriented devs of Angular and the more functional style devs of the redux world. Many OO devs struggle with seeing the value in the functional style and all of the paradigms that go with it. This talk will work to explain those paradigms.
Merge sort: illustrated step-by-step walk throughYoshi Watanabe
A step-by-step illustration of Merge sort to help you walk through a series of operations. Illustration is accompanied by actual code with bold line indicating the current operation.
EXPLAIN ANALYZE is a new query profiling tool first released in MySQL 8.0.18. This presentation covers how this new feature works, both on the surface and on the inside, and how you can use it to better understand your queries, to improve them and make them go faster.
This presentation is for everyone who has ever had to understand why a query is executed slower than anticipated, and for everyone who wants to learn more about query plans and query execution in MySQL.
PHP and MySQL Tips and tricks, DC 2007Damien Seguy
Like opening a long hidden treasure chest, this session will bring many jewels back to the programming light. We'll cover a number of lesser known PHP function and MySQL functionalities, that will help at daily tasks. They will be applied in various fields, including security, performances, standard compliance and simply fun to program.
Programmation fonctionnelle en JavaScriptLoïc Knuchel
La programmation fonctionnelle permet de faire du code plus modulaire, avec moins de bugs et de manière plus productive !!!
Cette présentation montre comment la programmation fonctionnelle peut tenir se promesse et comment l'appliquer avec JavaScript.
I am Elias M. I am a Python Homework Expert at pythonhomeworkhelp.com. I hold a Master's in Computer Science from, the University of Calgary, Canada. I have been helping students with their homework for the past 7 years. I solve homework related to Python.
Visit pythonhomeworkhelp.com or email support@pythonhomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with Python Homework.
An introduction to functional programming with goEleanor McHugh
A crash course in functional programming concepts using Go. Heavy on code, light on theory.
You can find the examples at https://github.com/feyeleanor/intro_to_fp_in_go
Slides from my talk at Reversim 2021 convention (also passed a talk with the same slide at PyWeb-IL, 2022-03) in Tel-Aviv, Israel.
The recording of the talk is on youtube, here: https://www.youtube.com/watch?v=ahGLUdW3cqk&ab_channel=Reversim.
You can find more information, and services to help you get started on my website, https://propertybasedtesting.com.
The talk introduces property-based testing, a software testing technique that improves the ROI of automated tests.
While with standard tests, we need to work hard, hand-coding many examples - with property-based tests the computer generates hundreds or thousands of tests for us.
The random generation saves us a lot of effort, and also has a surprising tendency to come up with edge cases we would have never thought to test.
This helps us find bugs sooner and more easily, and have more confidence in our code.
The talk covered the basics of property-based tests.
It also gave the feeling for the power and variety of real-world use cases, by taking a CRUD web application and letting our test explore the application’s external API and find bugs in edge cases we didn’t know.
See the last slides for extra resources.
A Skeptics guide to functional style javascriptjonathanfmills
Modern JavaScript seems to be split between the object oriented devs of Angular and the more functional style devs of the redux world. Many OO devs struggle with seeing the value in the functional style and all of the paradigms that go with it. This talk will work to explain those paradigms.
Merge sort: illustrated step-by-step walk throughYoshi Watanabe
A step-by-step illustration of Merge sort to help you walk through a series of operations. Illustration is accompanied by actual code with bold line indicating the current operation.
EXPLAIN ANALYZE is a new query profiling tool first released in MySQL 8.0.18. This presentation covers how this new feature works, both on the surface and on the inside, and how you can use it to better understand your queries, to improve them and make them go faster.
This presentation is for everyone who has ever had to understand why a query is executed slower than anticipated, and for everyone who wants to learn more about query plans and query execution in MySQL.
PHP and MySQL Tips and tricks, DC 2007Damien Seguy
Like opening a long hidden treasure chest, this session will bring many jewels back to the programming light. We'll cover a number of lesser known PHP function and MySQL functionalities, that will help at daily tasks. They will be applied in various fields, including security, performances, standard compliance and simply fun to program.
An Introduction to Part of C++ STL for OI. Introduced the common use of STL algorithms and containers, especially those are helpful to OI.
Also with some examples.
C++ Searching & Sorting5. Sort the following list using the select.pdfRahul04August
C++ Searching & Sorting
5. Sort the following list using the selection sort algorithm. Show the list after each iteration of
the outerforloop.
36, 55, 17, 35, 63, 85, 12, 48, 3, 66
6. Consider the following list: 5, 18, 21, 10, 55, 20
The first three keys are in order. To move 10 to its proper position using the insertion sort as
described in this chapter, exactly how many key comparisons are executed?
7. Consider the following list: 7, 28, 31, 40, 5, 20
The first four keys are in order. To move 5 to its proper position using the insertion sort as
described in this chapter, exactly how many key comparisons are executed?
8. Consider the following list: 28, 18, 21, 10, 25, 30, 12, 71, 32, 58, 15
This list is to be sorted using the insertion sort algorithm. Show the resulting list after six
passes of the sorting phase – that is, after six iterations of the for loop.
9. Perform the insertion sort algorithm using the following list of keys: 18, 8, 11, 9, 15, 20, 32,
61, 22, 48, 75, 83, 35, 3
Show the list after each iteration. Exactly how many key comparisons are executed to sort this
list using insertion sort?
10. a. The performance of bubble sort can be improved if we stop the sorting process as soon as
we find that in an iteration, no swapping of elements takes place. Write a function that
implements bubble sort algorithm using this fact.
b. Using the algorithm that you designed in part (a), find the number of iterations that are needed
to sort the list: 65, 14, 52, 43, 75, 25, 80, 90, 95.
11. Suppose that L is a sorted list of 4096 elements. What is the maximum number of
comparisons made by binary search to determine whether an item is in L?
12. Suppose that the elements of a list are in descending order, and they need to be put in
ascending order. Write a C++ function that takes as input an array of items in descending order
and the number of elements in the array. The function must not incorporate any sorting
algorithms, that is, no item comparisons should take place.
Solution
# include
# include
# include
#include
#include
#include
#include
// Function related to sorting in class sorting
class sorting
{
int array[50],array1[50],final[100],i,n,m,j;
public:
// Function to read an array
void read();
// Function to read arrays for merge sort
void read_mer();
// Function to display an array
void display();
// Function to perform bubble sort
void bub_sort();
// Function to perform selection sort
void Sel_sort();
// Function to perform insertion sort
void Ins_sort();
// Function to perform quick sort
void Qui_sort();
// Function to perform heap sort
void Heap_sort();
// Function to build a heap
void heap(int array[], int n);
// Function to interchange the value of root node with a
// child node in heap sort
void below_heap(int array[], int first, int last);
// Function to perform merges sort
void Mer_sort();
// Function to perform shell sort
void Shell_sort();
// Function to split the array into two halves during quick sort
void partition(int arra.
Slides from GR8 Conf EU 2019 talk - "Groovy Refactoring Patterns". In this talk, I share the refactoring patterns I observed during Groovy development.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
1. Understanding Lemon generated Parser.
When the parser receive the input Token, it also reads previous State number from the Parser stack. Using
this Token and State number Parser process with the pre calculated Tables like yy_action, yy_shift_ofst,
yy_reduce_ofst , Depends upon the values the corresponding action shift or Reduce is performed .
Current Token with Previous State Number => Action
Parser Action :
Shift : The Current Token with value is pushed at the top of the stack
Reduce : The corresponding rule is applied & Parser Stack is poped. Depends upon the rule number of
The number symbols is poped from stack.
Parser Stack:
it is associated with 4 elements :
Parser Stack Index: It is the parser index value.
State Number : it holds state number ,which is used for the calculating with next State.
Symbol Index: Symbol Index, The integer unique Symbol id.
Token Value: Token Value.
Initially Parser Stack is initializes by $ symbol
Parser Stack Index State No Symbol Index Token Value
0 0 $ 0
Parser Tables:
yy_action: A single table containing all the possible state number
yy_shift_ofst: For each state, the offset into yy_action for shifting terminals into the parser stack
yy_reduce_ofst: For each state, the offset into yy_action holds for the reducing the parse Stack
yyRuleInfo : From the Rule Index value , we can map this array index value
a. LHS Symbol Index : Symbol of the LHS of the given Rule Index
b. NRHS: Number of RHS in that Rule
Algorthim:
Get current token ,token value
Do {
get action value
if(value > totalstate){
reduce rule of (value –totalstate)
}
else{
push current token with value on stack
do the Rule Action
}
While(push current token);
We will take a simple example of Context free Grammar(CFG) arithmetic calculator
Example1.y
program ::= expr(A) . { printf ("Result=%dn", A); }
expr(A) ::= INTEGER(B) PLUS INTEGER(C). { A = B + C ; }
expr(A) ::= INTEGER(B) TIMES INTEGER(C).{ A = B * C ; }
expr(A) ::= INTEGER(B) .
2. TotalState = YYNState = 7 (more info can be seen in .out file )
TotalRules = YYNRulee= 4
This CFG rules and symbol index vales as follows
Rule Index Value Rules
0 program ::= expr
1 expr ::= expr PLUS expr
2 expr ::= expr TIMES expr
3 expr ::= INTEGER
Rules Index values are follows :
Symbol Index Symbol Name
0 $
1 INTEGER
2 PLUS
3 TIMES
4 error:
5 expr: INTEGER
6 program: INTEGER
The Expression are evaluates as follows
=3+4*5+6
=3 +20+6
=23+6
=29;
This Expression is given in code of 8 steps as follows
1. Parse(p,INTEGER,3);
2. Parse(p,PLUS,0);
3. Parse(p,INTEGER,4);
4. Parse(p,TIMES,0);
5. Parse(p,INTEGER,5);
6. Parse(p,PLUS,0);
7. Parse(p,INTEGER,6);
8. Parse(p,0,0);
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 7, 5, 2, 1, 10, 13, 10, 10, 8, 13,
/* 10 */ 8, 1, 9, 13, 9, 9, 6, 12, 4, 13,
/* 20 */ 3,
};
static const signed char yy_shift_ofst[] = {
/* 0 */ 17, 17, 17, 12, 4, 8, 0,
};
static const signed char yy_reduce_ofst[] = {
3. /* 0 */ 11, 15, -4, 1, 1, 1, 1,
};
}
yyRuleInfo[] = {
{ 6, 1 }, => program = INTEGER (Total RHS =1)
{ 5, 3 }, => expr = expr +expr (Total RHS =3)
{ 5, 3 },=> expr =expr *expr (Total RHS =3)
{ 5, 1 }, expr = INTEGER(Total RHS =1)
};
1.Parse(p,INTEGER,3);
Calculate Action :
Current Token = INTEGER = 1, Previous State = 0
Action = yy_action[ yy_shift_ofst[Previous State]+Current Token ]
= yy_action[yy_shift_ofst[0]+1]
= yy_action[17+1] => 4
4 < 7 then shift Shift this token in Parser stack
Parser Stack Index State No Symbol Value
1 4 INTEGER 3
0 0 $ 0
2.Parse(p,PLUS,0);
1.Calculate Action
Current Token = PLUS = 2, Previous State = 4
Action = yy_action[ yy_shift_ofst[4]+2 ]
= yy_action[4+2] =>10
Action value > YYNState then Reduce
10 > 7
1.Reduce Action:
Reduce Rule Index =action value – TotalState => 10-7= 3 => expr ::= INTEGER
ReduceToken = yyRuleinfo[3].lhs => 5 (expr : integer)
TotalRHSSymbol = yyRuleinfo[3].nrhs => 1
Stateno :
get Previous Stack Index = Current Stack Index – TotalRHSSymbol
= 1-1 => 0
PreviousStateno = stack[Previous Stack Index].stateno => 0
=yy_action[yy_reduce_ofst[PreviousStateno] +Token]
=yy_action[yy_reduce_ofst[0] +Token]
= yy_action[11+5] => 6
Parser Stack Index State No Symbol Value
1 6 Expr=INTEGER(5) 3
4. 0 0 $ 0
2.Calculate Action
Current Token = PLUS = 2, Previous State = 6
Action = yy_action[ yy_shift_ofst[6]+2 ]
= yy_action[0+2] =>2
Action value< yyNState then push to stack push(2,PLUS,0)
Parser Stack Index State No Symbol Value
2 2 PLUS(2) 0
1 6 Expr=INTEGER(5) 3
0 0 $ 0
3.Parse(p,INTEGER,4);
Calculate Action:
Current Token = INTEGER =1, Previous State = 2
=yy_action[ yy_shift_ofst[2]+1 ]
= yy_action[17+1] =>4
Action value< yyNState then push to stack push(4,INTEGER,4)
Parser Stack Index State No Symbol Value
3 4 INTEGER(1) 4
2 2 PLUS(2) 0
1 6 Expr=INTEGER(5) 3
0 0 $ 0
4.Parse(p,TIMES,0);
Calculate Action
Current Token = TIMES =3, Previous State = 4
Action = yy_action[ yy_shift_ofst[4]+3 ]
= yy_action[4+3] =>10
1.Reduce Action :
Reduce Rule Index =action value – TotalState => 10-7= 3 => expr ::= INTEGER
ReduceToken = yyRuleinfo[3].lhs => 5(expr : integer)
TotalRHSSymbol = yyRuleinfo[3].nrhs => 1
Stateno :
get Previous Stack Index: Current Stack Index – TotalRHSSymbol
=3-1 => 2
PreviousStateno= stack[2].stateno => 2
=yy_action[yy_reduce_ofst[PreviousStateno] +Token]
=yy_action[yy_reduce_ofst[2] +5]
= yy_action[-4+5] => 5
Reduce stack index 3 & apply rule 3
Parser Stack Index State No Symbol Value
5. 3 5 Expr=INTEGER(5) 4
2 2 PLUS(2) 0
1 6 Expr=INTEGER(5) 3
0 0 $ 0
Calculate Action
Current Token = TIMES =3, Previous State = 5
=yy_action[ yy_shift_ofst[5]+3 ]
= yy_action[8+3] =>1
Push stack (1,Times,0);
Parser Stack Index State No Symbol Value
4 1 TIMES 0
3 5 Expr=INTEGER(5) 4
2 2 PLUS(2) 0
1 6 Expr=INTEGER(5) 3
0 0 $ 0
5.Parse(p,INTEGER,5);
Calculate Action
Current Token = INTEGER =1, Previous State = 1
=yy_action[ yy_shift_ofst[1]+1 ]
= yy_action[17+1] =>4
Action value< yyNState then push to stack push(4,INTEGER,5)
Parser Stack Index State No Symbol Value
5 4 INTEGER 5
4 1 TIMES 0
3 5 Expr=INTEGER(5) 4
2 2 PLUS(2) 0
1 6 Expr=INTEGER(5) 3
0 0 $ 0
6.Parse(p,PLUS,0);
1.Calculate Action
Current Token = PLUS =2, Previous State = 4
=yy_action[ yy_shift_ofst[4]+2 ]
= yy_action[4+1] =>10
10 > 7 then reduce
1.Reduce Action :
Reduce Rule Index =action value – TotalState => 10-7= 3 => expr ::= INTEGER
ReduceToken = yyRuleinfo[3].lhs => 5
TotalRHSSymbol = yyRuleinfo[3].nrhs => 1
Stateno :
get Previous Stack Index: Current Stack Index – TotalRHSSymbol
=5-1 => 4
PreviousStateno= stack[4].stateno => 1
=yy_action[yy_reduce_ofst[PreviousStateno] +Token]
=yy_action[yy_reduce_ofst[1] +5]
= yy_action[15+5] => 3
apply rule 3 at stack index 5
6. Parser Stack Index State No Symbol Value
5 3 Expr=INTEGER(5) 5
4 1 TIMES 0
3 5 Expr=INTEGER(5) 4
2 2 PLUS(2) 0
1 6 Expr=INTEGER(5) 3
0 0 $ 0
2. Calculate Action
Current Token = PLUS =2, Previous State = 3
=yy_action[ yy_shift_ofst[3]+2 ]
= yy_action[12+2] =>9
9> 7 then
2.Reduce Action :
Reduce Rule Index =action value – TotalState => 9-7= 2 => expr ::= expr TIMES expr
ReduceToken = yyRuleinfo[2].lhs => 5
TotalRHSSymbol = yyRuleinfo[2].nrhs => 3
Stateno :
get Previous Stack Index: Current Stack Index – TotalRHSSymbol
=5-3 => 2
PreviousStateno= stack[2].stateno => 2
=yy_action[yy_reduce_ofst[PreviousStateno] +Token]
=yy_action[yy_reduce_ofst[2] +5]
= yy_action[-4+5] => 5
Parser Stack Index State No Symbol Value
3 5 Expr=INTEGER(5) 20
2 2 PLUS(2) 0
1 6 Expr=INTEGER(5) 3
0 0 $ 0
3.Calculate Action
Current Token = PLUS =2,Previous State = 5
=yy_action[ yy_shift_ofst[5]+2 ]
= yy_action[8+2] =>8
8> 7 then
3.Reduce Action :
Reduce Rule Index =action value – TotalState => 8-7= 1=> expr ::= exprPLUS expr
ReduceToken = yyRuleinfo[2].lhs => 5
TotalRHSSymbol = yyRuleinfo[2].nrhs => 3
Stateno :
get Previous Stack Index: Current Stack Index – TotalRHSSymbol
=3-3 => 0
PreviousStateno= stack[2].stateno => 2
=yy_action[yy_reduce_ofst[PreviousStateno] +Token]
=yy_action[yy_reduce_ofst[0] +5]
= yy_action[11+5] => 6
7. Parser Stack Index State No Symbol Value
1 6 Expr=INTEGER(5) 23
0 0 $ 0
3.Calculate Action
Current Token = PLUS =2
Previous State = 6
=yy_action[ yy_shift_ofst[6]+2 ]
= yy_action[0+2] =>2
2> 7 then push stack (2,PLUS,0)
Parser Stack Index State No Symbol Value
2 2 PLUS 0
1 6 Expr=INTEGER(5) 23
0 0 $ 0
7.Parse(p,INTEGER,6);
Calculate Action :
Current Token = INTEGER =1, Previous State =2
=yy_action[ yy_shift_ofst[2]+1 ]
= yy_action[17+1] =>4
Push stack(4,INTEGER,6);
Parser Stack Index State No Symbol Value
3 4 INTEGER 6
2 2 PLUS 0
1 6 Expr=INTEGER(5) 23
0 0 $ 0
8.Parse(p,0,0);
Calculate Action :
Current Token = $ =0,Previous State =4
=yy_action[ yy_shift_ofst[4]+0 ]
= yy_action[4+0] =>10
1.Reduce Action :
Reduce Rule Index =action value – TotalState => 10-7= 3=> expr ::= INTEGER
ReduceToken = yyRuleinfo[3].lhs => 5
TotalRHSSymbol = yyRuleinfo[3].nrhs => 1
Stateno :
get Previous Stack Index: Current Stack Index – TotalRHSSymbol
=3-1 => 2
PreviousStateno= stack[2].stateno => 2
=yy_action[yy_reduce_ofst[PreviousStateno] +Token]
=yy_action[yy_reduce_ofst[2] +5]
= yy_action[-4+5] => 5
Parser Stack Index State No Symbol Value
3 5 Expr=INTEGER(5) 6
2 2 PLUS 0
1 6 Expr=INTEGER(5) 23
8. 0 0 $ 0
1.Calculate Action :
Current Token = $ =0 , Previous State =5
=yy_action[ yy_shift_ofst[5]+0 ]
= yy_action[8+0] =>8
8-7 => rule 1
Reduce Rule Index =action value – TotalState =>8-7= 1=> expr ::= expr PLUS expr
ReduceToken = yyRuleinfo[1].lhs => 5
TotalRHSSymbol = yyRuleinfo[1].nrhs => 3
Stateno :
get Previous Stack Index: Current Stack Index – TotalRHSSymbol
=3-3 => 0
PreviousStateno= stack[0].stateno => 0
=yy_action[yy_reduce_ofst[PreviousStateno] +Token]
=yy_action[yy_reduce_ofst[0] +5]
= yy_action[11+5] => 6
Reduce Rule 1
Parser Stack Index State No Symbol Value
1 6 Expr=INTEGER(5) 29
0 0 $ 0
2. Calculate Action :
Current Token = $ =0 , Previous State =6
=yy_action[ yy_shift_ofst[6]+0 ]
= yy_action[0+0] =>7
7>7 =>
1.Reduce Action :
Reduce Rule Index =action value – TotalState => 7-7= 0=> program ::= INTEGER
ReduceToken = yyRuleinfo[0].lhs => 6
TotalRHSSymbol = yyRuleinfo[0].nrhs => 1
Stateno :
get Previous Stack Index: Current Stack Index – TotalRHSSymbol
=1-1 => 0
PreviousStateno= stack[0].stateno => 0
=yy_action[yy_reduce_ofst[PreviousStateno] +Token]
=yy_action[yy_reduce_ofst[0] +6]
= yy_action[11+6] =>12
Parser Stack Index State No Symbol Value
1 12 program=INTEGER(5) 29
0 0 $ 0
program accept = Totalstate+totalrule+1
=7 + 4 +1 =>12
Hence program accept