Search code examples
cparsingcurly-brackets

"parse error at end of input", but I'm sure my brackets are correct. (in C)


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 }
  } 
} 

Solution

  • 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