У меня проблема с компиляцией кода Bison, я пытаюсь скомпилировать этот код:
%{
#include <stdio.h>
#include <stdlib.h>
#include <stdstring.h>
//#include "list.h"
int yylex();
int errore = 0;
void yyerror(char const *s);
%}
%union{
char *stringa;
double reale;
int intero;
}
%start Input
%token <stringa> MATR
%token <reale> CFU COD_M
%token <intero> ANNO_C VOTO
%token AA DATA MATERIA SEP1 SEP2 VIR LANC PEV PAR_I PAR_F TRAT NOME
%define parse.error verbose
%%
Input : AA DATA SEP1 Corsi SEP2 Studenti
;
Corsi : El_Materie
;
El_Materie : Materie
El_Materie Materie
;
Materie : PAR_I COD_M VIR MATERIA VIR ANNO_C VIR CFU PAR_F
;
Studenti : El_Studenti
;
El_Studenti : Studente Lista_M
El_Studenti Studente Lista_M
;
Studente : MATR LANC NOME PEV ANNO_C PEV
;
Lista_M : Esame
Lista_M Esame
;
Esame : COD_M VIR VOTO TRAT
;
%%
void yyerror(char const *s){
fprintf(stderr, "Errore: %s\n", s);
}
int main(void){
if(yyparse() == 0){
print();
}
return 0;
}
он возвращает мне эту ошибку:
Carriera1.y: warning: 10 nonterminals useless in grammar [-Wother]
Carriera1.y: warning: 10 rules useless in grammar [-Wother]
Carriera1.y:16.8-13: fatal error: no phrase is derived from the initial symbol Start
16 | %start Input
как я могу исправить эту ошибку ? та же ошибка в windows CMD и в Linux Bash. Я пробую использовать другой начальный символ, но ошибка та же.
Заранее спасибо
ОБНОВЛЕНИЕ:
У меня новая ошибка, скомпилированная с помощью «-Wall -Werror»
ошибка:
Carriera.fl: In function ‘yylex’:
Carriera.fl:38:17: error: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Werror=int-conversion]
38 | {Matr} {yylval.stringa = strdup(yytext); return(MATR);}
| ^
At top level:
lex.yy.c:1251:16: error: ‘input’ defined but not used [-Werror=unused-function]
1251 | static int input (void)
| ^~~~~
lex.yy.c:1208:17: error: ‘yyunput’ defined but not used [-Werror=unused-function]
1208 | static void yyunput (int c, char * yy_bp )
| ^~~~~~~
спасибо