Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old October 10th, 2006, 11:20 AM
ringo_shells ringo_shells is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 32 m 18 sec
Reputation Power: 0
Send a message via ICQ to ringo_shells Send a message via AIM to ringo_shells Send a message via MSN to ringo_shells Send a message via Yahoo to ringo_shells
Lex/Yacc (shift | reduce)/reduce conflicts

hi everyone, i posted this in the archives forum foolishly. however, moving on, i am complete novice at lex, yacc, and the whole compiler thing, but i was wondering, if i go ahead and post my yacc file, will anyone be able to help identify some of my...

yacc: 14 shift/reduce conflicts
yacc: 42 reduce/reduce conflicts

??

I'm sorry if this is some massive task but i have been at this for hours, and i'm really not sure what i'm doing, so i apologise if this is a jerk move on my part

Code:
%{
   #include <stdio.h>
   #include <stdlib.h>
   FILE *fp;
   char *fname;
   extern int lastentry;
%}
%token IDENTIFIER INTCONSTANT BOOLCONSTANT ASSIGNMENT NOTEQUAL LESSTHANOREQUAL
%token GREATERTHANOREQUAL WHITESPACE COMMENT INTEGER BOOLEAN BEGINN END WHILE
%token DO IF THEN READ WRITE PROGRAM
%left '+' '-'
%left '*' '/'
%%
program: PROGRAM IDENTIFIER ';' declarationlist statementlist '.'
;
declarationlist: declarationlist declaration
               |
;
declaration: type identifierlist ';'
;
identifierlist: IDENTIFIER ',' identifierlist
              |
;
type: INTEGER
    | BOOLEAN
;
statementlist: BEGINN statements END
;
statements: statements statement
          |
;
statement: assignmentstatement
         | ifstatement
         | whilestatement
         | writestatement
         | readstatement
;
assignmentstatement: IDENTIFIER ASSIGNMENT expression ';'
;
ifstatement: IF expression THEN statementlist ';'
;
whilestatement: WHILE expression DO statementlist ';'
;
writestatement: WRITE expressionlist ';'
;
readstatement: READ identifierlist ';'
;
expressionlist: expression ',' expressionlist
              |
;
expression: relation relationallist
;
relationallist: relationallist relationaloperator relation
              |
;
relationaloperator: '='
                  | NOTEQUAL
                  | '<'
                  | LESSTHANOREQUAL
                  | '>'
                  | GREATERTHANOREQUAL
;
relation: term addingoplist
;
addingoplist: addingoplist addingop term
            |
;
addingop: '+'
        | '-'
;
term: factor multioplist
;
multioplist: multioplist multiop factor
           |
;
multiop: '*'
       | '/'
;
factor: IDENTIFIER
      | INTEGER
      | expression
;
%%
int main(void)
{
   yyparse();
   return 0;
}


Any help any of you can give me will be hugely appreciated. if this isnt enough info to be able to do anything, i apologise and will tell you what i can.

<-- this guy articulates my feelings well :P

Thanks in advance!

Reply With Quote
  #2  
Old October 10th, 2006, 03:07 PM
ringo_shells ringo_shells is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 32 m 18 sec
Reputation Power: 0
Send a message via ICQ to ringo_shells Send a message via AIM to ringo_shells Send a message via MSN to ringo_shells Send a message via Yahoo to ringo_shells
worry not ive resolved them. can somwone lock this plz?

Reply With Quote
  #3  
Old October 10th, 2006, 04:11 PM
LinuxPenguin's Avatar
LinuxPenguin LinuxPenguin is offline
fork while true;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2005
Location: England, UK
Posts: 5,535 LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)  Folding Points: 11590 Folding Title: Novice Folder
Time spent in forums: 1 Month 3 Weeks 1 Day 19 h 23 m 58 sec
Reputation Power: 1008
Only if you post your solution

We don't lock threads here.

Reply With Quote
  #4  
Old October 11th, 2006, 12:31 PM
ringo_shells ringo_shells is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level)ringo_shells User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 32 m 18 sec
Reputation Power: 0
Send a message via ICQ to ringo_shells Send a message via AIM to ringo_shells Send a message via MSN to ringo_shells Send a message via Yahoo to ringo_shells
the sloution was that for example:
Code:
declarationlist: declarationlist declaration
                            | declaration
                            |


should be:

Code:
declarationlist: declarationlist declaration
                            |


i updated the original post.....just in case anyone spotted anything else is wrong.....seeing as its still not functioning coorectly (but the yacc conflicts are gone....and thats why i started this)
Comments on this post
LinuxPenguin agrees: Thanks for posting the solution

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Lex/Yacc (shift | reduce)/reduce conflicts


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway