[英]“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. 由于针对该错误的所有Google结果都指出,解决方法位于方括号中,因此我不知所措。 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 }
}
}
you are using //AND }
for comment which will comment every thing in same line, results }
to be commented. 您正在使用//AND }
用于将评论每一件事在同一直线上,结果注释}
进行评论。
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
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;
It looks like the closing braces of the if
statements are accidentally commented out: 好像if
语句的右花括号被意外注释掉了:
if ( _op3 == 00000001 ){
//AND }
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. 尝试使用/*AND*/
等。
If that doesn't cure the problem, please post preprocessed source code, which you can get with gcc -E
. 如果那不能解决问题,请发布预处理的源代码,您可以使用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. 警告:这将产生一个非常大的文件,您应该将其缩减为可以解决问题的最小文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.