flex 扫描仪推回溢出

问题描述 投票:0回答:0

最近在学习编译,写了这段代码: ``

`%{
#include <stdio.h>
#include <stdlib.h>
%}

CHIFFRE [0-9]
LETTRE [a-zA-Z]
ID {LETTRE}({CHIFFRE}|{LETTRE})*
NOMBRE {CHIFFRE}+  
FACTEUR ({NOMBRE}|{ID}|'('{EXPRESSION}')')
TERME {FACTEUR}('*'{FACTEUR}|'/'{FACTEUR})*
EXPRESSION {TERME}('+'{TERME}|'-'{TERME})*
AFFECTATION {ID}'='{EXPRESSION} ';'
INSTRUCTION ({AFFECTATION}|{EXPRESSION})';'
DECLARATION "var"{ID}'='{EXPRESSION}';'
LISTE_INST {INSTRUCTION}+
LISTE_DEC {DECLARATION}+

%%

{CHIFFRE} {printf("Chiffre: %s\n", yytext);}
{LETTRE} {printf("Lettre: %s\n", yytext);}
{ID} {printf("Identificateur: %s\n", yytext);}
{NOMBRE} {printf("Nombre: %s\n", yytext);}
{FACTEUR} {printf("Facteur: %s\n", yytext);}
{TERME} {printf("Terme: %s\n", yytext);}
{EXPRESSION} {printf("Expression: %s\n", yytext);}
{AFFECTATION} {printf("Affectation: %s\n", yytext);}
{INSTRUCTION} {printf("Instruction: %s\n", yytext);}
{DECLARATION} {printf("Déclaration: %s\n", yytext);}
{LISTE_INST} {printf("Liste d'instructions: %s\n", yytext);}
{LISTE_DEC} {printf("Liste de déclarations: %s\n", yytext);}

%%``

当我使用命令 flex Name.flex 时,它显示了这个错误:flex scanner push-back overflow 谁能告诉我问题出在哪里,我尝试在 google 上搜索并询问 chatgpt 但它没有帮助我,谢谢!

我本来打算编译这个程序的,这是我大学必须做的工作,我必须今晚提交。非常感谢

compilation bison flex4.5
© www.soinside.com 2019 - 2024. All rights reserved.