Update analyseur syntaxyque
This commit is contained in:
@@ -210,6 +210,16 @@ void nom_token( int token, char *nom, char *valeur ) {
|
||||
else if(token == FIN) strcpy(valeur, "FIN");
|
||||
else if(token == VIRGULE) strcpy(valeur, "VIRGULE");
|
||||
|
||||
else if(token == SI) strcpy(valeur, "SI");
|
||||
else if(token == ALORS) strcpy(valeur, "ALORS");
|
||||
else if(token == SINON) strcpy(valeur, "SINON");
|
||||
else if(token == TANTQUE) strcpy(valeur, "TANTQUE");
|
||||
else if(token == FAIRE) strcpy(valeur, "FAIRE");
|
||||
else if(token == ENTIER) strcpy(valeur, "ENTIER");
|
||||
else if(token == RETOUR) strcpy(valeur, "RETOUR");
|
||||
else if(token == LIRE) strcpy(valeur, "LIRE");
|
||||
else if(token == ECRIRE) strcpy(valeur, "ECRIRE");
|
||||
|
||||
else if( token == ID_VAR ) {
|
||||
strcpy( nom, "id_variable" );
|
||||
strcpy( valeur, yytext );
|
||||
|
||||
@@ -3,202 +3,721 @@
|
||||
int uniteCourante;
|
||||
extern char yytext[100];
|
||||
|
||||
void ou (void){
|
||||
affiche_balise_ouvrante("ou", 1);
|
||||
|
||||
et();
|
||||
ouBis();
|
||||
|
||||
affiche_balise_fermante("ou", 1);
|
||||
void openSection( const char * section )
|
||||
{
|
||||
affiche_balise_ouvrantexpression( section, 1 );
|
||||
}
|
||||
|
||||
void ouBis(void){
|
||||
affiche_balise_ouvrante("ouBis", 1);
|
||||
void closeSection( const char * section )
|
||||
{
|
||||
affiche_balise_fermantexpression( section, 1 );
|
||||
}
|
||||
|
||||
if(uniteCourante == OU){
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
ou();
|
||||
void programme()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _optDecVariables_, uniteCourante ) ) {
|
||||
optDecVariables();
|
||||
listeDecFonctions();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
affiche_balise_fermante("ouBis", 1);
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void et(void){
|
||||
affiche_balise_ouvrante("et", 1);
|
||||
void optDecVariables()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
non();
|
||||
etBis();
|
||||
if( est_premier( _listeDecVariables_, uniteCourante ) )
|
||||
{
|
||||
listeDecVariables();
|
||||
|
||||
affiche_balise_fermante("et", 1);
|
||||
}
|
||||
|
||||
void etBis(void){
|
||||
affiche_balise_ouvrante("etBis", 1);
|
||||
|
||||
if(uniteCourante == ET){
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
et();
|
||||
} else {
|
||||
syntaxErrorMsg( "';' été attendu" );
|
||||
}
|
||||
} else if ( !est_suivanterme( _optDecVariables_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
affiche_balise_fermante("etBis", 1);
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void non(void){
|
||||
affiche_balise_ouvrante("non", 1);
|
||||
nonBis();
|
||||
egal();
|
||||
void listeDecVariables()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
affiche_balise_fermante("non", 1);
|
||||
}
|
||||
|
||||
void nonBis(void){
|
||||
affiche_balise_ouvrante("nonBis", 1);
|
||||
if(uniteCourante == NON){
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
nonBis();
|
||||
if( est_premier( _declarationVariable_, uniteCourante ) ) {
|
||||
declarationVariablisteExpressions();
|
||||
listeDecVariablesBis();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
affiche_balise_fermante("nonBis", 1);
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void egal(void){
|
||||
affiche_balise_ouvrante("egal", 1);
|
||||
void listeDecVariablesBis()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
expArith();
|
||||
egalBis();
|
||||
|
||||
affiche_balise_fermante("egal", 1);
|
||||
}
|
||||
|
||||
void egalBis(void){
|
||||
affiche_balise_ouvrante("egalBis", 1);
|
||||
|
||||
if(uniteCourante == EGAL || uniteCourante == INFERIEUR){
|
||||
if( uniteCourante == VIRGULE ) {
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
egal();
|
||||
|
||||
declarationVariablisteExpressions();
|
||||
listeDecVariablesBis();
|
||||
} else if( !est_suivanterme( _listeDecVariablesBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
affiche_balise_fermante("egalBis", 1);
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void expArith (void) {
|
||||
affiche_balise_ouvrante("expArith", 1);
|
||||
void declarationVariablisteExpressions()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == ENTIER ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == ID_VAR ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
optTailleTableau();
|
||||
} else {
|
||||
syntaxErrorMsg( "Un identificateur de variable été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'ENTIER' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void optTailleTableau()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == CROCHET_OUVRANT ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == NOMBRE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == CROCHET_FERMANT ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "']' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "Un nombre été attendu" );
|
||||
}
|
||||
} else if( !est_suivanterme( _optTailleTableau_, uniteCourante ) )
|
||||
{
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void listeDecFonctions()
|
||||
{
|
||||
/// LDF -> DF LDF | Ø
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _declarationFonction_, uniteCourante ) ) {
|
||||
declarationFonction();
|
||||
listeDecFonctions();
|
||||
} else if( !est_suivanterme( _listeDecFonctionss_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void declarationFonction()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == ID_FCT ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
listeParam();
|
||||
optDecVariables();
|
||||
instructionBloc();
|
||||
} else {
|
||||
syntaxErrorMsg( "Un identificateur de fonction été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void listeParam()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == PARENTHESE_OUVRANTE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
optListeDecVariables();
|
||||
|
||||
if( uniteCourante == PARENTHESE_FERMANTE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "')' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'(' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void optListeDecVariables()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _listeDecVariables_, uniteCourante ) ) {
|
||||
listeDecVariables();
|
||||
} else if( !est_suivanterme( _optListeDecVariables_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instruction()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _instructionAffect_, uniteCourante ) ) {
|
||||
instructionAffecterme();
|
||||
} else if( est_premier( _instructionBloc_, uniteCourante ) ) {
|
||||
instructionBloc();
|
||||
} else if( est_premier( _instructionSi_, uniteCourante ) ) {
|
||||
instructionSi();
|
||||
} else if( est_premier( _instructionTantque_, uniteCourante ) ) {
|
||||
instructionTantquexpression();
|
||||
} else if( est_premier( _instructionAppel_, uniteCourante ) ) {
|
||||
instructionAppel();
|
||||
} else if( est_premier( _instructionRetour_, uniteCourante ) ) {
|
||||
instructionRetour();
|
||||
} else if( est_premier( _instructionEcriture_, uniteCourante ) ) {
|
||||
instructionEcriturexpression();
|
||||
} else if( est_premier( _instructionVide_, uniteCourante ) ) {
|
||||
instructionVidexpression();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instructionAffecterme()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _var_, uniteCourante ) ) {
|
||||
var();
|
||||
|
||||
if( uniteCourante == EGAL ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "';' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'=' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instructionBloc()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == ACCOLADE_OUVRANTE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
listeInstructions();
|
||||
|
||||
if( uniteCourante == ACCOLADE_FERMANTE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "'}' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'{' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void listeInstructions()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _instruction_, uniteCourante ) ) {
|
||||
instruction();
|
||||
listeInstructions();
|
||||
} else if( !est_suivanterme( _listeInstructions_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instructionSi()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == SI ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
|
||||
if( uniteCourante == ALORS ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionBloc();
|
||||
optSinon();
|
||||
} else {
|
||||
syntaxErrorMsg( "'alors' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'si' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
// ICI
|
||||
|
||||
void optSinon()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == SINON ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionBloc();
|
||||
} else if( !est_suivanterme( _optSinon_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instructionTantquexpression()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == TANTQUE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
|
||||
if( uniteCourante == FAIRE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionBloc();
|
||||
} else {
|
||||
syntaxErrorMsg( "'faire' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'tantque' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instructionAppel()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _instructionAppel_, uniteCourante ) ) {
|
||||
appelFct();
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "';' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instructionRetour()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == RETOUR ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "';' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'retour' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instructionEcriturexpression()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == ECRIRE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == PARENTHESE_OUVRANTE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
|
||||
if( uniteCourante == PARENTHESE_FERMANTE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "')' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'(' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'ecrire' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void instructionVidexpression()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "';' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void expression()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _conjonction_, uniteCourante ) ) {
|
||||
conjonction();
|
||||
expressionBis();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void expressionBis()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == OU ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
conjonction();
|
||||
expressionBis();
|
||||
} else if( !est_suivanterme( _expressionBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void conjonction()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _negation_, uniteCourante ) ) {
|
||||
negation();
|
||||
conjonctionBis();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void conjonctionBis()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == ET ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
negation();
|
||||
conjonctionBis();
|
||||
} else if( !est_suivanterme( _conjonctionBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void negation()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == NON ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
comparaison();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void comparaison()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _expression_, uniteCourante ) ) {
|
||||
expression();
|
||||
comparaisonBis();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void comparaisonBis()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == EGAL || uniteCourante == INFERIEUR) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
comparaisonBis();
|
||||
} else if( !est_suivanterme( _comparaisonBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void expression()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _terme_, uniteCourante ) ) {
|
||||
terme();
|
||||
expArithBis();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void expArithBis()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == PLUS || uniteCourante == MOINS) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
terme();
|
||||
expArithBis();
|
||||
|
||||
affiche_balise_fermante("expArith", 1);
|
||||
}
|
||||
|
||||
void expArithBis (void) {
|
||||
affiche_balise_ouvrante("expArithBis", 1);
|
||||
|
||||
if(uniteCourante == PLUS || uniteCourante == MOINS ) {
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
|
||||
expArith();
|
||||
} else if( !est_suivanterme( _expArithBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
affiche_balise_fermante("expArithBis", 1);
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void terme (void) {
|
||||
affiche_balise_ouvrante("terme", 1);
|
||||
void terme()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _facteur_, uniteCourante ) ) {
|
||||
facteur();
|
||||
termeBis();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void termeBis()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == FOIS || ylval == DIVISE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
facteur();
|
||||
termeBis();
|
||||
} else if( !est_suivanterme( _termeBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
affiche_balise_fermante("terme", 1);
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void termeBis (void) {
|
||||
affiche_balise_ouvrante("termeBis", 1);
|
||||
void facteur()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if(uniteCourante == FOIS || uniteCourante == DIVISE) {
|
||||
if( uniteCourante == PARENTHESE_OUVRANTE ) {
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
|
||||
terme();
|
||||
expression();
|
||||
|
||||
if( uniteCourante == PARENTHESE_FERMANTE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "')' été attendu" );
|
||||
}
|
||||
} else if( uniteCourante == NOMBRE ) {
|
||||
uniteCourante = yylex();
|
||||
} else if( est_premier( _appelFct_, uniteCourante ) ) {
|
||||
appelFct();
|
||||
} else if( est_premier( _var_, uniteCourante ) ) {
|
||||
var();
|
||||
} else if( uniteCourante == LIRE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == PARENTHESE_OUVRANTE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == PARENTHESE_FERMANTE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "')' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'(' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
affiche_balise_fermante("termeBis", 1);
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void facteur (void) {
|
||||
affiche_balise_ouvrante("facteur", 1);
|
||||
void var()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if(uniteCourante == PARENTHESE_OUVRANTE) {
|
||||
if( uniteCourante == ID_VAR ) {
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
|
||||
ou();
|
||||
|
||||
if(uniteCourante != PARENTHESE_FERMANTE) {
|
||||
printf("Erreur de syntaxe");
|
||||
exit(-1);
|
||||
}
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
|
||||
} else if(uniteCourante == NOMBRE) {
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
} else if(uniteCourante == ID_VAR) {
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
} else if(uniteCourante == CROCHET_OUVRANT){
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
|
||||
ou();
|
||||
if(uniteCourante != CROCHET_FERMANT) {
|
||||
printf("Erreur de syntaxe");
|
||||
exit(-1);
|
||||
}
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
|
||||
}
|
||||
else if(uniteCourante == ID_FCT){
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
if(uniteCourante != PARENTHESE_OUVRANTE){
|
||||
printf("Erreur de syntaxe");
|
||||
exit(-1);
|
||||
}
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
if(uniteCourante != PARENTHESE_FERMANTE){
|
||||
ou();
|
||||
while(uniteCourante == VIRGULE){
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
ou();
|
||||
|
||||
}
|
||||
}
|
||||
if(uniteCourante != PARENTHESE_FERMANTE){
|
||||
printf("Erreur de syntaxe");
|
||||
exit(-1);
|
||||
}
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
if(uniteCourante != POINT_VIRGULE){
|
||||
printf("Erreur de syntaxe");
|
||||
exit(-1);
|
||||
}
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
}
|
||||
else {
|
||||
printf("Erreur de syntaxe");
|
||||
exit(-1);
|
||||
optIndice();
|
||||
} else {
|
||||
syntaxErrorMsg( "Indice de variable été attendu" );
|
||||
}
|
||||
|
||||
affiche_balise_fermante("facteur", 1);
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void optIndice()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == CROCHET_OUVRANT ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
|
||||
if( uniteCourante == CROCHET_FERMANT ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "']' été attendu" );
|
||||
}
|
||||
} else if( !est_suivanterme( _optIndice_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void appelFct()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == ID_FCT ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == PARENTHESE_OUVRANTE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
listeExpressions();
|
||||
|
||||
if( uniteCourante == PARENTHESE_FERMANTE ) {
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "')' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "'(' été attendu" );
|
||||
}
|
||||
} else {
|
||||
syntaxErrorMsg( "Identificateur de fonction été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void listeExpressions()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( est_premier( _expression_, uniteCourante ) ) {
|
||||
expression();
|
||||
listeExpressionsBis(();
|
||||
} else if( !est_suivanterme( _listeexpressions_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void listeExpressionsBis(()
|
||||
{
|
||||
openSection( __FUNCTION__ );
|
||||
|
||||
if( uniteCourante == VIRGULE ) {
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
listeExpressionsBis(();
|
||||
} else if( !est_suivanterme( _listeexpressionsBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __FUNCTION__ );
|
||||
}
|
||||
@@ -19,9 +19,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
// test_yylex_internal(yyin);
|
||||
uniteCourante = yylex();
|
||||
affiche_xml_texte(yytext);
|
||||
|
||||
ou();
|
||||
programme();
|
||||
|
||||
uniteCourante = yylex();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user