Question

implement the construction of Simple LR parsing table

Asked by: majinharish

I have to implement the construction of Simple LR parsing table, given the grammar productions in a file and then write the SLR table in another file and if possible parse a given string using the table.
I have attached the file specifying the Grammar for which the SLR parsing table has to be constructed
The implementation can be in C or Java
I have the compiler design  2 edition aho lam ullman sethi book where algorithms are given from page 241 to 255 and 1 edition aho sethi ullman from page 217 to 228
if anybody wants soft copy of these books i will be pleased to give
Please help me in this
I have also attached the algorithms necessary.
Simple Googling of SLR parsing construction yields algorithms which are very clear.  
 please help

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-04-05 at 04:15:47ID24295918
Topic

C Programming Language

Participating Experts
2
Points
500
Comments
28

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. par file
    Waht is a file with .par used for and what does this extension mean? Can I list the parameters for import in a .par file and use this file in imp, like imp file=filename.par Please suggest.
  2. par io err laserjet 4 plus
    Every time I start my computer my old laserjet 4 plus comes up with an error message on the control panel "err par io" the work around is to cycle power on the printer after the computer is loaded. This problem started when I got a new computer. I have tried chan...
  3. PAR Protocol
    How has the PAR Protocol been extended for use in the Internet?
  4. Converting from PERL to Executable using PAR
    I have a PERL script that begins with the following: use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; When I convert my PERL script to an executable using pp -o file.exe file.pl, there is no problem. But, when I run file.exe I receive the following pop-...
  5. What does the /par in a .bat file mean?
    I am learning to do batch files, and came across this /par in my .bat file. I dont know really how it got there, as I was just manually creating the batch. I did just install easy batch creator, but I didnt use that prog. Anyway here is the code that I have in my batch, but ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: mrjoltcolaPosted on 2009-04-05 at 14:28:18ID: 24073050

The way I see it, you have things to accomplish other than building the parsing table. You need to parse a grammar yourself and convert it to discrete token values, because a parsing table works (at least traditionally) on integer tokens, not strings.

Which part do you need help with? We cannot do the assignment for you, due to EE rules, but we can answer questions. Have you started a program? Have you an idea of the different phases? Do you even have a program that will read your grammar file?

 

by: majinharishPosted on 2009-04-05 at 19:31:10ID: 24074067

I have an idea I can do it by hand but i am not able to implement via program
I need help with construction of Simple LR parsing table given the grammar productions in a file
I am not able to implement the closure, goto and to find the sets of items construction my main problem is the position of parser that is . how to implement this.

please help me I am ready to forgo anything for this. please get me started my posting some code for these functions and combining them for building the slr parsing table

if anybody needs the algorithms simple google of construction of slr parsing table will give the algorithms clearly if anybody wants the dragon book that is compilers book I am pleased to upload.

I know how to separate identifiers ,keywords,operators from a file given the productions in a file.I have posted the code.

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char exp[500];
char op[21]={'+','-','*','/','%','^','[',']','(',')','{','}','=',';','<','>','#',',','&','"','|'};
char keys[30][30]={"if","while","for","do","include","printf","main","void","scanf","getch","int","char","break","continue","case","const","default","else","double","float","void","isaplha","isdigit","strcmp"};
char token[20];
int i,j,pos,k,h,m,len,c=0,g;
FILE *fp;
FILE *fp1;
int p=0;
clrscr();
fp=fopen("C:\\users\\nasch\\data.c","r");
fp1=fopen("C:\\users\\nasch\\result.txt","w");
while(!feof(fp))
{
p++;
if(fgets(exp,500,fp)!=NULL)
{
len=strlen(exp);
for(i=0;i<=len;i++)
{
if(isalpha(exp[i]))
{
pos=i;
g=i;
while(isalpha(exp[g])||isdigit(exp[g]))
g++;
for(j=0;j<20;j++)
token[j]=NULL;
k=0;
for(j=pos;j<g;j++)
{
3
token[k]=exp[j];
k++;
}
c=0;
if((strcmp(token,"stdio")==0)||(strcmp(token,"conio")==0)||(strcmp(token,"string")==0))
{
fprintf(fp1,"%s.h is a header file\n",token);
g=g+2;
}
else
{
fprintf(fp1,"%s",token);
for(m=0;m<30;m++)
{
if(strcmp(token,keys[m])==0)
c++;
}
if(c==0)
fprintf(fp1," - It is a identifier\n");
else
fprintf(fp1," - It is a key word\n");
}
i=g-1;
}
else if(isdigit(exp[i]))
{
while(isdigit(exp[i+1]))
{
fprintf(fp1,"%c",exp[i]);
i++;
}
fprintf(fp1,"%c",exp[i]);
fprintf(fp1," - It is a digit\n");
}
else
{
if(exp[i]=='+'||exp[i]=='-'||exp[i]=='='||exp[i]=='|'||exp[i]=='<'||exp[i]=='>'||exp[i]=='!')
{
4
i++;
if(exp[i]=='+'||exp[i]=='-'||exp[i]=='='||exp[i]=='|')
fprintf(fp1,"%c%c - It is an operator\n",exp[i-1],exp[i]);
else
{
fprintf(fp1,"%c - It is an operator\n",exp[i-1]);
i--;
}
}
else
{
for(h=0;h<21;h++)
{
if(exp[i]==op[h])
{
fprintf(fp1,"%c - It is an operator\n",op[h]);
break;
}
}
}
}
}
}
}
getch();
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:

Select allOpen in new window

 

by: mrjoltcolaPosted on 2009-04-05 at 19:45:00ID: 24074095

This is completely unformatted code.  It does not even compile.

You are asking for help on an advanced subject, LR parser generators, and you are posting code that has no indentation code and does not compile.
 

 

by: majinharishPosted on 2009-04-05 at 20:55:12ID: 24074272

It compiles i just forgot to add <ctype.h> and just a typo mistake was there i corrected now I post after correcting

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
{
char exp[500];
char op[21]={'+','-','*','/','%','^','[',']','(',')','{','}','=',';','<','>','#',',','&','"','|'};
char keys[30][30]={"if","while","for","do","include","printf","main","void","scanf","getch","int","char","break","continue","case","const","default","else","double","float","void","isaplha","isdigit","strcmp"};
char token[20];
int i,j,pos,k,h,m,len,c=0,g;
FILE *fp;
FILE *fp1;
int p=0;
clrscr();
fp=fopen("C:\\users\\nasch\\data.c","r");
fp1=fopen("C:\\users\\nasch\\result.txt","w");
  while(!feof(fp))
{
  p++;
	  if(fgets(exp,500,fp)!=NULL)
	{
	  len=strlen(exp);
 for(i=0;i<=len;i++)
{
	if(isalpha(exp[i]))
  {
	pos=i;
	g=i;
	  while(isalpha(exp[g])||isdigit(exp[g]))
			g++;
		 for(j=0;j<20;j++)
		 token[j]=NULL;
	k=0;
		 for(j=pos;j<g;j++)
	 {
		 token[k]=exp[j];
		 k++;
	 }
		c=0;
	  if((strcmp(token,"stdio")==0)||(strcmp(token,"conio")==0)||(strcmp(token,"string")==0))
	  {
		 fprintf(fp1,"%s.h is a header file\n",token);
		 g=g+2;
	  }
	  else
	  {
		fprintf(fp1,"%s",token);
		for(m=0;m<30;m++)
	  {
		 if(strcmp(token,keys[m])==0)
		  c++;
	  }
 if(c==0)
	fprintf(fp1," - It is a identifier\n");
 else
	fprintf(fp1," - It is a key word\n");
	 }
 i=g-1;
  }
			else if(isdigit(exp[i]))
		{
			  while(isdigit(exp[i+1]))
			{
			  fprintf(fp1,"%c",exp[i]);
			  i++;
			}
	fprintf(fp1,"%c",exp[i]);
	fprintf(fp1," - It is a digit\n");
  }
	else
  {
	 if(exp[i]=='+'||exp[i]=='-'||exp[i]=='='||exp[i]=='|'||exp[i]=='<'||exp[i]=='>'||exp[i]=='!')
	  {
		  i++;
			  if(exp[i]=='+'||exp[i]=='-'||exp[i]=='='||exp[i]=='|')
			  fprintf(fp1,"%c%c - It is an operator\n",exp[i-1],exp[i]);
			  else
			 {
			  fprintf(fp1,"%c - It is an operator\n",exp[i-1]);
			  i--;
			 }
	  }
  else
 {
	for(h=0;h<21;h++)
  {
	  if(exp[i]==op[h])
	 {
		fprintf(fp1,"%c - It is an operator\n",op[h]);
		  break;
	 }
  }
 }
}
}
}
}
getch();
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:

Select allOpen in new window

 

by: majinharishPosted on 2009-04-05 at 20:57:40ID: 24074280

please don't forgot my fopen function arguments refers to my system so u have to create a new file and give the new pathname in the arguments same for the other


 

by: Infinity08Posted on 2009-04-06 at 01:38:10ID: 24075275

I'm sorry. I gave up trying to read your code about half way through. It's impossible to read, as the indentation changes with each line in a completely inconsistent way. Please clean up your code - you'll do yourself (and us) a big favor, and make your code a lot easier to read/maintain.

From what I did read, it seems like you have to be able to parse C code. Are you sure that that's what you need to do (not just a small subset of C for example) ? Writing a parser for C is by no means a simple task (especially if you can't make use of parser generators like yacc and lexer generators like lex).

Can you post the exact wording of your assignment ? And also give us a bit of background on your C programming experience ?

 

by: majinharishPosted on 2009-04-06 at 18:48:28ID: 24083394

In my assignment there is no need to parse C code, All I have to do is construct Simple LR parsing table for a given Grammar production in a file and parse the input string given using the table

I posted the code in reply to expert mrjoltcola who asked to parse a grammer production.

I have modified and again i am posting i have also hand coded the table and parsed the given string that i have attached in a different file I have attached also the grammar productions for which I have to construct Simple LR parsing table.I am not very good in C programming I know the syntax of C well
Please help me in constructing the Simple LR parsing table.

  • strparse.txt
    • 2 KB

    parsing string from hand coded SLR parsing table

  • input.txt
    • 101 bytes

    Grammar for which Simple LR parsing table has to be Constructed

  • lexC.txt
    • 2 KB

    seperate tokens,operators from grammar productions

 

by: mrjoltcolaPosted on 2009-04-06 at 19:09:04ID: 24083439

It looks like you are making progress. Since you aren't really asking any specific questions, I don't know what to answer.

Constructing it by hand is tedious, but maybe that is the assignment? Can you clarify for us? Is the assignment to hand-code the parser or to write a parser generator like yacc?

I see you have created the ACTION and GOTO tables, so that is a good start. The approach looks correct. Key is, does it run, and when it does, what does it do?

ACTION table

The action table is for deciding, for the current state and input token, what to do?
a) Should you shift the token?
If shifting (pushing the current input onto the parse stack) allows the parser to keep matching rules and consume tokens, then shift is the choic; shift-reduce parsers are greedy (shift when possible).
b) Should you reduce? That means you leave the input token in the input stream while you pop all off the tokens off the stack that equate to a production. You then push the production's left hand side "token" onto the stack, and consult the GOTO table to find out which state to move to. Then start over, with the same token on the input, which might mean yet another reduce, or might mean a shift.

GOTO table:
Contains the state to move to after executing a reduce (production), given the state that was stored on the stack immediately under the tokens that were popped off for the reduction. Its simply keeping track of where it was when it started the latest set of "shifting".

How are you implementing your stack?

 

by: majinharishPosted on 2009-04-06 at 19:26:25ID: 24083509

Actually what I have done is I saw the productions i worked in my note how to construct the table though it is there in the book and without constructing the Simple LR parsing table using a C program I have parsed the string using those arrays which I have to actually implement using C program

Could I get back on Friday evening in India time because I have two exams on Thursday and Friday.

 

by: majinharishPosted on 2009-04-06 at 19:28:34ID: 24083515

There is still the problem of constructing the closure, goto and to find the sets of items construction.
I have not constructed the parsing table i have just used the table in the book and parsed the string

I hope i am clear

 

by: majinharishPosted on 2009-04-06 at 19:30:28ID: 24083524

I probably need the yacc source code or some Simple LR parser table construction source code

 

by: mrjoltcolaPosted on 2009-04-06 at 19:33:30ID: 24083538

Well my question is still:

Must you hand-construct a parser, or must you write a parser generator, like yacc?

 

by: majinharishPosted on 2009-04-06 at 19:53:27ID: 24083610

I can't use Yacc parser. but probably the source code might help me to construct Simple LR parsing table

 

by: mrjoltcolaPosted on 2009-04-06 at 19:55:22ID: 24083613

Thats not my question.

Which must you implement for your project?
1) A hand-coded parser?
2) A yacc? (parser generator)

 

by: majinharishPosted on 2009-04-06 at 19:59:47ID: 24083630

I don't get what is hand-coded parser if you mean it is a slr parser which we have to implement on our own  in some programming language then yes

I can't use yacc ( parser generator)

 

by: mrjoltcolaPosted on 2009-04-06 at 20:04:46ID: 24083656

I didn't ask if you could USE yacc, I asked if you had to _write_ a yacc.

A parser and a parser generator are not the same thing. Believe it or not, some 4th and 5th year students actually do implement "yacc".

But, it sounds like you have to hand-code a parser. I'm glad, at least, as its a much more reasonable task. :)

 

by: majinharishPosted on 2009-04-06 at 20:18:55ID: 24083723

I am in second year engineering, could you help me now how to proceed in this SLR table construction

 

by: Infinity08Posted on 2009-04-07 at 03:57:55ID: 24085819

Maybe if you posted the exact wording of your assignment (like I asked earlier), we could avoid all this confusion about what actually needs to be done.

Could you do that ?


You mention that you don't have to parse C, but the code you posted starts out by doing exactly that (it seems to try to parse C standard headers like stdio.h etc., and try to match C specific keywords like if, while, etc.) ... So, you can understand my confusion.

 

by: majinharishPosted on 2009-04-07 at 06:40:06ID: 24087183

I actually have done that in response to expert mrjoltcola who asked me if i could parse a general grammar that's what i understood so I took C generally and i did that

I told my madam that i am unable to do and i showed her what i had done so she now asks me to do using YACC.
I have never used it, I just know it is a parser generator I will try to find information on it with the books available with me i have to do it on Friday as i have two exams

Sorry if i am not clear with my question,as well with YACC as I didn't know what it was sorry for my ignorance.I have posted again the question.

Implement the construction of SLR Parsing table for a given Grammar productions given in a file and then parse the input string using the table.You can use YACC that's what she told me today.
I think YACC uses LALR parsing table so please forgive me if there is anything wrong with my understanding of the question.
 

 

by: Infinity08Posted on 2009-04-07 at 06:52:30ID: 24087323

>> Implement the construction of SLR Parsing table for a given Grammar productions given in a file and then parse the input string using the table.

Is this file of "grammar productions" fixed, or does your program have to be able to support any such file that is passed to it as argument ?
If it's fixed, then can you post it ? If not, then you need to at least know the format of the file.

If I understand the assignment correctly, then I'm not sure whether yacc would help you here, as it seems this is simply an exercise of implementing a few simple grammar rules as an SLR  parser.


Now, I'll assume (correct me if I'm wrong) that you need to implement it for these rules :

        E'->E              //This is augmentation for this grammar
        E->E+T
        E->T
        T->T*F
        T->F
        F->(E)
        F->id

and that 'id' is defined as an easily recognizable series of characters (like alphanumeric "words", separated by whitespace). Is that right ?

If so, what you have to do, is construct the parse table for the above rules, and implement it so it can be used by your code. Then you simply read the input data, get the different tokens from it (id's), and use the parse table to match the rules.

 

by: majinharishPosted on 2009-04-07 at 08:16:32ID: 24088209

Actually my problem is i am not experienced to implement the construction of SLR parsing table even for the fixed productions in a file the same productions you have given and let id be defined as only digits.
the problem of constructing the closure, goto and to find the sets of items construction is proving difficult for me because of use of recursive functions and finding insufficient time because of other subjects.

So I have asked madam to do something and I asked her if i could use YACC, she replied yes. Now if i am using YACC and if the productions are fixed then i don't think the project will be worth so i assume they are not fixed and they could give any grammar production in the file.



 

by: mrjoltcolaPosted on 2009-04-07 at 08:25:19ID: 24088318

>>So I have asked madam to do something and I asked her if i could use YACC, she replied yes. Now if i am using YACC and if the productions are fixed then i don't think the project will be worth so i assume they are not fixed and they could give any grammar production in the

She may mean that you may use YACC to construct the parser for the grammar file itself, but not the target input. But you still have to create the parsing table. What do you think? Can you she clarify?

 

by: majinharishPosted on 2009-04-07 at 08:41:40ID: 24088517

I do not know anything about YACC to be frank and I am not able to understand your question forgive me if i am ignorant, Actually thanks to you that is why i asked if i could use YACC and she told yes though she did not agree first.

 

by: mrjoltcolaPosted on 2009-04-07 at 08:52:59ID: 24088661

>>I do not know anything about YACC to be frank and I am not able to understand your question forgive me if i am ignorant

Nothing wrong with ignorance, we are all ignorant of many things.

However, I feel that this subject level is overly advanced for your current skill level in C and Yacc. I am surprised that you are given such an advanced task as a year 2 engineering student. I do not suggest that you should give up, but given the constraints of Experts Exchange, I cannot give you code to start with. So I advise you to seek assistance from your Professor or Madam on this, and return to us when you have a clearer understanding of both the problem and the tools to use to accomplish it, and give us a place to start so that we can help you.

Good luck.

 

by: Infinity08Posted on 2009-04-07 at 09:54:30ID: 24089400

>> Actually my problem is i am not experienced to implement the construction of SLR parsing table

You mentioned earlier that you could do it on paper.
If you know how to do it on paper, then you know how to do it in code. Just take it step by step. Start by constructing the parse table based on the given rules. Can you do that, and post it here ?

 

by: majinharishPosted on 2009-04-08 at 06:35:58ID: 24096998

Sorry I had exam so could not reply quicker, Doing them by hand is easy the book tells first compute closure, In paper we follow the steps , there is initialization , we list the productions the .(dot) means the position of parser and recursive means we do it again and again till some condition. It is easy, Now you try to implement this using C code I know for you experts it is piece of cake but for me I have a mind block to be frank no time also and then combining each of these type functions so that they produce the table for me looks very tough, I know we have to split them into modules ,etc but still.

So that's why I think i'l use YACC. First i will read about it and then come back here

I have another exam so i will read on Friday. Please remember me when I get back here.

 

by: Infinity08Posted on 2009-04-08 at 06:41:05ID: 24097046

>> Doing them by hand is easy
>> In paper we follow the steps

It's not harder in code than on paper :) You follow the same steps, in the same way. The only difference is that you use the C language.


>> no time also

Time is something we can't give you. So, you'll have to find/make the time to do this. We're here to assist you.


>> but for me I have a mind block

That's why you need to do things one small step at a time. As I suggested earlier. Can you start by constructing the parse table based on the given rules, and post it here ? Once you have that, you can start putting it in code.

 

by: majinharishPosted on 2009-04-10 at 07:43:48ID: 24115905

the advice helps a lot and i am surely going to give a try in the summer.
I have to submit it by Monday so now i don't think i can start from scratch. I have downloaded parser generator from the link     http://www.bumblebeesoftware.com/downloads.htm

the readme file i have attached the two things it says is this
the Parser Generator versions of YACC and Lex
"      Generate C, C++ and Java parsers and lexical analysers.
"      AYACC can generate LALR(1), CLR(1) and SLR(1) parsers

i didn't understand much.I am still reading lex and yacc orielly book

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...