我想修改以下图表中的元件定义,即宣布乙醇为胎体,但是,在编造带有胶卷的立体时有错误。
gcc *.c -ly
tp.l: In function ‘yylex’:
tp.l:12: error: request for member ‘sum’ in something not a structure or union
y.tab.c:1035: error: conflicting types for ‘yylval’
tp.y:11: note: previous declaration of ‘yylval’ was here
the yacc file:
%{
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int val;
int cpt;
} str;
str yylval;
%}
%start start
%token number
%%
start : number + number
;
%%
int main(void)
{
yyparse();
return 0;
}
弹性文件:
%option noyywrap
%{
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include"y.tab.h"
%}
%%
[0-9]+ {
yylval = atoi(yytext);
return number;
}
"+" return + ;
return
;
" " ;
%%