0

I'm pretty sure my brackets are matched up correctly, but I'm getting the error "parse error at end of input" No matter how many or few brackets I attach to the end of this program. Since all of the Google results for this error say that the fix lies in the brackets, I'm at a loss for what else it could be. Could someone point out my silly little mistake for me? :)

#include <stdio.h>
#include "/user/cse320/Projects/project06.support.h"
#include "/user/cse320/Projects/project06.hardware.h"

void execute()
{
  unsigned long int IRdecode;
  IRdecode = IR;
  IRdecode >> 30;

  if ( IRdecode == 0 )
  {

    unsigned int _reg = IR;
    unsigned int _imm = IR;

    _reg << 2;
    _reg >> 27;

    _imm << 9;

    write_reg_file( _reg, _imm );
  }

  if ( IRdecode == 00000002 )
  {

    unsigned int _op3 = IR;
    unsigned int _rd = IR;
    unsigned int _rs1 = IR;
    _op3 << 7;
    _op3 >> 26;

    _rd << 2;  
    _rd >> 30;

    _rs1 << 13;
    _rs1 >> 27;

    if ( _op3 == 00000001 ){
      //AND }
    if ( _op3 == 00000002 ){
      //OR } 
    if ( _op3 == 00000003 ){
      //XOR } 
    if ( _op3 == 00000005 ){
      //ANDN }
    if ( _op3 == 00000006 ){
      //ORN } 
    if ( _op3 == 00000007 ){
      //XNOR }
  } 
} 
Megan Rose
  • 23
  • 1
  • 3
  • 5

4 Answers4

2

you are using //AND } for comment which will comment every thing in same line, results } to be commented.

CODE:

if ( _op3 == 00000001 ){
  //AND }                //here } will be commented.

You should use like this

 if ( _op3 == 00000001 ){
  //AND 
 }                          //now OK

OR

 if ( _op3 == 00000001 ){
  /*AND*/  }               //OK, as well
Javed Akram
  • 15,024
  • 26
  • 81
  • 118
1

Unless there is something strange going on, I think there is also another problem with your code (other than the problem with the comments):

_op3 << 7;
_op3 >> 26;

_rd << 2;  
_rd >> 30;

_rs1 << 13;
_rs1 >> 27;

These bitshift operations are completely useless because the result is discarded. The << operator is just like the + operator in the way that it takes two operands and produces a result. What would you expect the following to do?

i + 4;
2 + 4;
1 + 9;

I think what you want is the compound operators:

_op3 <<= 7;

This is equivalent to:

_op3 = op3 << 7;
dreamlax
  • 93,976
  • 29
  • 161
  • 209
0

It looks like the closing braces of the if statements are accidentally commented out:

if ( _op3 == 00000001 ){
  //AND }
Josh Rosen
  • 13,511
  • 6
  • 58
  • 70
0

This may not be your only problem (since you say adding lots of braces at the end of the program does not help) but in the statements like this ...

if ( _op3 == 00000001 ){
  //AND }

// comments run to the end of the line, therefore you have commented out the close brace. Try using /*AND*/ and so forth, instead.

If that doesn't cure the problem, please post preprocessed source code, which you can get with gcc -E. Warning: this will produce a very large file, which you should cut down to the smallest thing you can manage that still causes the problem.

zwol
  • 135,547
  • 38
  • 252
  • 361