Modifications while a faire

This commit is contained in:
Nahom 2021-04-12 22:54:52 +02:00
parent f6d265e641
commit 17419e1663
17 changed files with 2473 additions and 1951 deletions

BIN
.DS_Store vendored

Binary file not shown.

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
*.tab.c
*.tab.h
*.yy.c
a.out
poubelle/

8
.idea/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

13
.idea/misc.xml Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MakefileSettings">
<option name="linkedExternalProjectsSettings">
<MakefileProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="version" value="2" />
</MakefileProjectSettings>
</option>
</component>
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/projet_systeme.iml" filepath="$PROJECT_DIR$/.idea/projet_systeme.iml" />
</modules>
</component>
</project>

2
.idea/projet_systeme.iml Normal file
View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="External" type="CPP_MODULE" version="4" />

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

BIN
a.out

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,14 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* A Bison parser, made by GNU Bison 2.3. */
/* Bison interface for Yacc-like parsers in C
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -15,7 +16,9 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@ -30,21 +33,12 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED
# define YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token type. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
tENTIER = 258,
tENTIEREXP = 259,
tADD = 260,
@ -79,28 +73,57 @@ extern int yydebug;
tNOT = 289
};
#endif
/* Tokens. */
#define tENTIER 258
#define tENTIEREXP 259
#define tADD 260
#define tSUB 261
#define tMUL 262
#define tDIV 263
#define tPO 264
#define tPF 265
#define tAO 266
#define tAF 267
#define tERROR 268
#define tPV 269
#define tVIRGULE 270
#define tAFFECTATION 271
#define tEGAL 272
#define tDIFF 273
#define tLT 274
#define tGT 275
#define tGTE 276
#define tLTE 277
#define tMAIN 278
#define tINT 279
#define tPRINT 280
#define tRETURN 281
#define tOR 282
#define tAND 283
#define tIF 284
#define tELSE 285
#define tWHILE 286
#define tCONST 287
#define tVAR 288
#define tNOT 289
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
typedef union YYSTYPE
#line 1 "analyse_syntaxique.y"
{
#line 1 "analyse_syntaxique.y" /* yacc.c:1909 */
int nombre;
char id[30];
#line 94 "analyse_syntaxique.tab.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
}
/* Line 1529 of yacc.c. */
#line 122 "analyse_syntaxique.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED */

View file

@ -12,6 +12,7 @@ enum Initialised_Variable init;
enum Symbole_Type type;
Table_Symboles table;
instructions_array array;
int whileCondition;
%}
@ -23,12 +24,13 @@ instructions_array array;
%type<nombre> Cond
%token tADD
%token tSUB
%token tMUL
%token tDIV
%token tPO
%token<nombre> tPO
%token tPF
%token tAO
%token tAF
@ -52,7 +54,7 @@ instructions_array array;
%token tAND
%token<nombre> tIF
%token tELSE
%token tWHILE
%token<nombre> tWHILE
%token tCONST
%token<id> tVAR
%token tNOT
@ -110,12 +112,15 @@ Valeur : tVAR {add_symbole_top(&table, $1, type, NOT_INITIALISED, table.depth);}
Aff : tVAR tAFFECTATION E tPV {printf("Affectation : %s\n", $1); free_temp(&table);};
E : tENTIER {int vt = gen_entier(&table, &array, $1); $$ = vt;};
E : tVAR {int vt = gen_var(&table, &array, $1); $$ = vt;};
E : E tADD E {gen_arithmetique(&array, ADD, $1, $3); free_temp(&table); $$ = $1;} ;
E : E tMUL E {gen_arithmetique(&array, MUL, $1, $3); free_temp(&table); $$ = $1;} ;
E : E tSUB E {gen_arithmetique(&array, SOU, $1, $3); free_temp(&table); $$ = $1;} ;
E : E tDIV E {gen_arithmetique(&array, DIV, $1, $3); free_temp(&table); $$ = $1;} ;
//E : tENTIER {int vt = gen_entier(&table, &array, $1); $$ = vt;};
E : tENTIER {int vt = new_temp(&table); generate_instruction_2(&array, AFC, vt, $1); $$ = vt;};
//E : tVAR {int vt = gen_var(&table, &array, $1); $$ = vt;};
E : tVAR {int vt = new_temp(&table); int varAddr = variable_exists(&table, $1); generate_instruction_2(&array, CPY, vt, varAddr); $$ = vt;};
//E : E tADD E {gen_arithmetique(&array, ADD, $1, $3); free_temp(&table); $$ = $1;} ;
E : E tADD E {generate_instruction_3(&array, ADD, $1, $1, $3); free_temp(&table); $$ = $1;} ;
E : E tMUL E {generate_instruction_3(&array, MUL, $1, $1, $3); free_temp(&table); $$ = $1;} ;
E : E tSUB E {generate_instruction_3(&array, SOU, $1, $1, $3); free_temp(&table); $$ = $1;} ;
E : E tDIV E {generate_instruction_3(&array, DIV, $1, $1, $3); free_temp(&table); $$ = $1;} ;
E : tSUB E {printf("Variable negative\n");} ;
E : Invocation {$$ = 1234;};
E : tPO E tPF {printf("Parenthèse\n"); $$ = $2; } ;
@ -128,38 +133,59 @@ SuiteArgs : tVIRGULE tVAR SuiteArgs ;
SuiteArgs : ;
If : tIF tPO Cond tPF {
gen_jmpf(&table, &array, $3);
//gen_jmpf(&table, &array, $3, -1);
generate_instruction_2(&array, JMF, $3, -1);
free_temp(&table);
$1 = array.index;
}
tAO Instructions tAF
{
int adr_jmp = array.index;
update_jump(&array, $1, adr_jmp);
update_jmf(&array, $1, adr_jmp);
}
Else {printf("Dans if\n");};
Else {};
Else : tELSE tAO Instructions tAF {printf("else\n");} ;
Else : ;
Else : tELSE tIF tPO Cond tPF tAO Instructions tAF Else {printf("elsif\n");} ;
While : tWHILE tPO Cond tPF tAO Instructions tAF {printf("Dans while\n");};
/*While : tWHILE tPO {
$2 = array.index + 1 ;
} Cond tPF {*/
While : tWHILE tPO Cond tPF {
//gen_jmpf(&table, &array, $3, -1);
generate_instruction_2(&array, JMF, $3, -1);
free_temp(&table);
$1 = array.index;
}
tAO Instructions tAF {
int adr_jmp = array.index;
update_jmf(&array, $1, adr_jmp);
//gen_jmpf(&table, &array, $1, $2);
generate_instruction_1(&array, JMP, $2);
};
//Cond : E tEGAL E {int vt = gen_condition(&table, &array, EQ, $1, $3); $$ = vt;} ;
Cond : E tEGAL E {generate_instruction_3(&array, EQ, $1, $1, $3); free_temp(&table); $$ = $3;};
Cond : E tDIFF E {generate_instruction_3(&array, NEQ, $1, $1, $3); free_temp(&table); $$ = $3;} ;
Cond : E tLT E {generate_instruction_3(&array, LT, $1, $1, $3); free_temp(&table); $$ = $3;} ;
Cond : E tGT E {generate_instruction_3(&array, GT, $1, $1, $3); free_temp(&table); $$ = $3;} ;
Cond : E tLTE E {generate_instruction_3(&array, LTE, $1, $1, $3); free_temp(&table); $$ = $3;} ;
Cond : E tGTE E {generate_instruction_3(&array, GTE, $1, $1, $3); free_temp(&table); $$ = $3;} ;
Cond : E tAND E {generate_instruction_3(&array, AND, $1, $1, $3); free_temp(&table); $$ = $3;} ;
Cond : E tOR E {generate_instruction_3(&array, OR, $1, $1, $3); free_temp(&table); $$ = $3;} ;
Cond : tNOT Cond {generate_instruction_2(&array, NOT, $2, $2); $$ = $2;} ;
Cond : E {$$ = $1; };
Cond : E tEGAL E {printf("Cond ==\n");} ;
Cond : E tDIFF E {printf("Cond !=\n");} ;
Cond : E tLT E {printf("Cond <\n");} ;
Cond : E tGT E {printf("Cond >\n");} ;
Cond : E tLTE E {printf("Cond <=\n");} ;
Cond : E tGTE E{printf("Cond >=\n");} ;
Cond : E tAND Cond {printf("Cond &&\n");} ;
Cond : E tOR Cond {printf("Cond ||\n");} ;
Cond : tNOT Cond {printf("Cond !\n");} ;
Cond : E;
Invocation : tVAR tPO Args tPF {printf("Dans invocation\n");};
Print : tPRINT tPO tVAR tPF tPV {printf("printf de %s\n", $3);};
//Print : tPRINT tPO E tPF tPV {gen_print(&table, &array, $3);};
Print : tPRINT tPO E tPF tPV {generate_instruction_1(&array, PRI, $3); free_temp(&table);};
Return : tRETURN E tPV {$$= gen_return(&table, &array, $2);};
//Return : tRETURN E tPV {$$ = gen_return(&table, &array, $2);};
Return : tRETURN E tPV {$$ = generate_instruction_1(&array, RET, $2); free_temp(&table);};
%%
#include <stdio.h>
@ -171,5 +197,6 @@ void main(void){
print_table(&table);
//remove_symboles(&table, 0);
//print_table(&table);
exportInstructions(&array);
}

View file

@ -1,5 +1,66 @@
#include "gen_assembleur.h"
#include <stdio.h>
#include <stdlib.h>
char * operationName(enum operation op){
switch(op){
case EQ:
return "EQ";
case NEQ:
return "NEQ";
case LT:
return "LT";
case GT:
return "GT";
case LTE:
return "LTE";
case GTE:
return "GTE";
case ADD:
return "ADD";
case SOU:
return "SOU";
case DIV:
return "DIV";
case MUL:
return "MUL";
case CPY:
return "CPY";
case AFC:
return "AFC";
case RET:
return "RET";
case JMF:
return "JPF";
case JMP:
return "JPM";
case AND:
return "AND";
case OR:
return "OR";
case NOT:
return "NOT";
case PRI:
return "PRI";
default:
break;
}
return "";
}
void initialise_asm(instructions_array * array){
array->index = 0;
}
int add_instruction(instructions_array * array, instruction * instru){
if (array->index >= INSTRUCTION_TABLE_SIZE){
return 1;
}
array->array[array->index] = *instru;
array->index++;
return 0;
}
int new_temp(Table_Symboles * table){
int ret_addr ;
@ -10,40 +71,135 @@ int new_temp(Table_Symboles * table){
return ret_addr;
}
void gen_arithmetique(instructions_array * array, enum operation op, int arg1, int arg2){
int generate_instruction_1(instructions_array * array, enum operation op, int arg1){
instruction instru;
char * opName = operationName(op);
instru.operation = op;
instru.reg1 = arg1;
printf("%d\t %s %d\n", array->index, opName, instru.reg1);
if (add_instruction(array, &instru) != 0){
//TODO: Error handling
exit(1);
}
return 0;
}
int generate_instruction_2(instructions_array * array, enum operation op, int arg1, int arg2){
instruction instru;
char * opName = operationName(op);
instru.operation = op;
instru.reg1 = arg1;
instru.reg2 = arg2;
printf("%d\t %s %d %d\n", array->index, opName, instru.reg1, instru.reg2);
if (add_instruction(array, &instru) != 0){
//TODO: Error handling
exit(1);
}
return 0;
}
int generate_instruction_3(instructions_array * array, enum operation op, int arg1, int arg2, int arg3){
instruction instru;
char * opName = operationName(op);
instru.operation = op;
instru.reg1 = arg1;
instru.reg2 = arg2;
instru.reg3 = arg3;
printf("%d\t %s %d %d %d\n", array->index, opName, instru.reg1, instru.reg2, instru.reg3);
if (add_instruction(array, &instru) != 0){
//TODO: Error handling
exit(1);
}
return 0;
}
void update_jmf(instructions_array * array, int instru_index, int adr_jmp){
array->array[instru_index - 1].reg2 = adr_jmp;
printf("%d\t JMP %d %d\n", (instru_index - 1), array->array[instru_index].reg1, array->array[instru_index].reg2);
}
void exportInstructions(instructions_array * array){
FILE *file;
file = fopen("instructions.txt", "w");
instruction instru;
enum operation op;
for (int i = 0; i < array->index; i++){
instru = array->array[i];
op = instru.operation;
switch (op) {
//1 parameter
case JMP:
case PRI:
case RET:
fprintf(file, "%d\t %s %d\n", i, operationName(op), instru.reg1);
break;
//2 parameters
case JMF:
case NOT:
case AFC:
case CPY:
fprintf(file, "%d\t %s %d %d\n", i, operationName(op), instru.reg1, instru.reg2);
break;
//3 parameters
case ADD:
instru.operation = ADD;
instru.reg1 = arg1;
instru.reg2 = arg1;
instru.reg3 = arg2;
printf("%d ADD %d %d %d\n", array->index, arg1, arg1, arg2);
break;
case DIV:
instru.operation = DIV;
instru.reg1 = arg1;
instru.reg2 = arg1;
instru.reg3 = arg2;
printf("%d DIV %d %d %d\n", array->index, arg1, arg1, arg2);
break;
case SOU:
instru.operation = SOU;
instru.reg1 = arg1;
instru.reg2 = arg1;
instru.reg3 = arg2;
printf("%d SOU %d %d %d\n", array->index, arg1, arg1, arg2);
break;
case DIV:
case MUL:
instru.operation = MUL;
instru.reg1 = arg1;
instru.reg2 = arg1;
instru.reg3 = arg2;
printf("%d MUL %d %d %d\n", array->index, arg1, arg1, arg2);
case AND:
case OR:
case EQ:
case NEQ:
case LT:
case LTE:
case GT:
case GTE:
fprintf(file, "%d\t %s %d %d %d\n", i, operationName(op), instru.reg1, instru.reg2, instru.reg3);
break;
default:
break;
}
}
fclose(file);
}
/*int gen_print(Table_Symboles * table, instructions_array * array, int arg1){
instruction instru;
instru.operation = PRI;
instru.reg1 = arg1;
printf("%d\t PRI %d\n", array->index, instru.reg1);
if (array->index < INSTRUCTION_TABLE_SIZE){
array->array[array->index] = instru;
array->index++;
}
free_temp(table);
}*/
/*void gen_arithmetique(instructions_array * array, enum operation op, int arg1, int arg2){
instruction instru;
instru.reg1 = arg1;
instru.reg2 = arg1;
instru.reg3 = arg2;
char * opName = operationName(op);
printf("%d\t %s %d %d %d\n", array->index, opName, arg1, arg1, arg2);
if (array->index < INSTRUCTION_TABLE_SIZE){
array->array[array->index] = instru;
array->index++;
@ -61,7 +217,7 @@ int gen_var(Table_Symboles * table, instructions_array * array, char * varName){
instru.reg1 = vt;
instru.reg2 = varAddr;
printf("%d CPY %d %d\n", array->index, vt, varAddr);
printf("%d\t CPY %d %d\n", array->index, vt, varAddr);
if (array->index < INSTRUCTION_TABLE_SIZE){
array->array[array->index] = instru;
@ -81,7 +237,7 @@ int gen_entier(Table_Symboles * table, instructions_array * array, int entier){
instru.reg1 = vt;
instru.reg2 = entier;
printf("%d AFC %d %d\n", array->index, vt, entier);
printf("%d\t AFC %d %d\n", array->index, vt, entier);
if (array->index < INSTRUCTION_TABLE_SIZE){
array->array[array->index] = instru;
@ -91,6 +247,30 @@ int gen_entier(Table_Symboles * table, instructions_array * array, int entier){
return vt;
}
int gen_condition(Table_Symboles * table, instructions_array * array, enum operation op, int arg1, int arg2){
char * opName = operationName(op);
instruction instru;
instru.operation = op;
instru.reg1 = arg1;
instru.reg2 = arg1;
if (op != NOT){
instru.reg3 = arg2;
printf("%d\t %s %d %d %d\n", array->index, opName, instru.reg1, instru.reg2, instru.reg3);
free_temp(table);
} else {
printf("%d\t %s %d %d \n", array->index, opName, instru.reg1, instru.reg2);
}
if (array->index < INSTRUCTION_TABLE_SIZE){
array->array[array->index] = instru;
array->index++;
}
return instru.reg1;
}
int gen_return(Table_Symboles * table, instructions_array * array, int adr){
//vérifier que non null
@ -98,42 +278,37 @@ int gen_return(Table_Symboles * table, instructions_array * array, int adr){
instru.operation = RET;
instru.reg1 = adr;
printf("%d RET %d\n", array->index, adr);
printf("%d\t RET %d\n", array->index, adr);
if (array->index < INSTRUCTION_TABLE_SIZE){
array->array[array->index] = instru;
array->index++;
}
free_temp(table);
//free_temp(table);
return adr;
}
int gen_jmpf(Table_Symboles * table, instructions_array * array, int cond){
int gen_jmpf(Table_Symboles * table, instructions_array * array, int cond, int dest){
//vérifier que non null
instruction instru;
instru.operation = JMPF;
instru.operation = JMF;
instru.reg1 = cond;
instru.reg2 = -1;
instru.reg2 = dest;
printf("%d JMPF %d %d\n", array->index, cond, -1);
printf("%d\t JMPF %d %d\n", array->index, instru.reg1 , instru.reg2);
if (array->index < INSTRUCTION_TABLE_SIZE){
array->array[array->index] = instru;
array->index++;
}
free_temp(table);
//free_temp(table);
return cond;
}
void update_jump(instructions_array * array, int if_value, int adr_jmp){
array->array[if_value].reg2 = adr_jmp;
printf("%d JMPF %d %d\n", array->index, array->array[if_value].reg1, array->array[if_value].reg2);
}
*/
void initialise_asm(instructions_array * array){
array->index = 0;
}

View file

@ -5,7 +5,7 @@
#include "table_symboles.h"
enum operation{ADD, SOU, MUL, DIV, CPY, AFC, RET, JMPF};
enum operation{ADD, SOU, MUL, DIV, CPY, AFC, RET, JMF, JMP, EQ, NEQ, LT, GT, LTE, GTE, AND, OR, NOT, PRI};
typedef struct instruction{
enum operation operation;
@ -20,8 +20,80 @@ typedef struct instructions_array{
int index;
} instructions_array;
/**
*
* @param op operation
* @return returns the string that corresponds to the enum operation op
*/
char * operationName(enum operation op);
/**
* Initialises the instructions array
* @param array
*/
void initialise_asm(instructions_array * array);
//renvoie l'index (ou valeur?) de la premiere @ dispo
/**
* Fetch address of a temporary variable
* @param table
* @return first available temp address
*/
int new_temp(Table_Symboles * table);
/**
* Adds intruction to instruction array
* @param array
* @param intru
* @return 0 if instruction was added successfully, -1 if not
*/
int add_instruction(instructions_array * array, instruction * intru);
/**
* Generates intruction with one parameter
* @param array
* @param op
* @param arg1
* @return
*/
int generate_instruction_1(instructions_array * array, enum operation op, int arg1);
/**
* Generates intruction with two parameters
* @param array
* @param op
* @param arg1
* @param arg2
* @return
*/
int generate_instruction_2(instructions_array * array, enum operation op, int arg1, int arg2);
/**
* Generates intruction with three parameters
* @param array
* @param op
* @param arg1
* @param arg2
* @param arg3
* @return
*/
int generate_instruction_3(instructions_array * array, enum operation op, int arg1, int arg2, int arg3);
/**
* Updates the JMF instruction with the correct jump destination address
* @param array
* @param instru_index
* @param adr_jmp
*/
void update_jmf(instructions_array * array, int instru_index, int adr_jmp);
void exportInstructions(instructions_array * array);
/*
void gen_arithmetique(instructions_array * array, enum operation op, int arg1, int arg2);
int gen_var(Table_Symboles * table, instructions_array * array, char * varName);
@ -30,11 +102,10 @@ int gen_entier(Table_Symboles * table, instructions_array * array, int entier);
int gen_return(Table_Symboles * table, instructions_array * array, int adr);
int gen_jmpf(Table_Symboles * table, instructions_array * array, int cond);
int gen_jmpf(Table_Symboles * table, instructions_array * array, int cond, int dest);
void update_jump(instructions_array * array, int if_value, int adr_jmp);
//renvoie l'index (ou valeur?) de la premiere @ dispo
int new_temp(Table_Symboles * table);
int gen_condition(Table_Symboles * table, instructions_array * array, enum operation op, int arg1, int arg2);
int gen_print(Table_Symboles * table, instructions_array * array, int arg1);
*/
#endif

15
instructions.txt Normal file
View file

@ -0,0 +1,15 @@
0 AFC 49 1
1 AFC 49 2
2 AFC 48 3
3 ADD 49 49 48
4 AFC 49 4
5 CPY 49 1
6 NOT 49 49
7 JPF 49 10
8 AFC 49 1
9 AFC 49 4
10 JPM 4
11 CPY 49 1
12 PRI 49
13 AFC 49 5
14 RET 49

314
lex.yy.c
View file

@ -7,8 +7,8 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 4
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@ -46,6 +46,7 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
typedef uint64_t flex_uint64_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
@ -53,6 +54,7 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
@ -83,61 +85,63 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
#ifndef SIZE_MAX
#define SIZE_MAX (~(size_t)0)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
/* begin standard C++ headers. */
#ifdef __cplusplus
/* TODO: this is always defined, so inline it */
/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST
#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yyconst const
#if defined(__GNUC__) && __GNUC__ >= 3
#define yynoreturn __attribute__((__noreturn__))
#else
#define yynoreturn
#define yyconst
#endif
/* Returned upon end-of-file. */
#define YY_NULL 0
/* Promotes a possibly negative, possibly signed char to an
* integer in range [0..255] for use as an array index.
/* Promotes a possibly negative, possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative,
* we want to instead treat it as an 8-bit unsigned char, hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN (yy_start) = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START (((yy_start) - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE yyrestart(yyin )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@ -154,7 +158,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
typedef size_t yy_size_t;
#endif
extern int yyleng;
extern yy_size_t yyleng;
extern FILE *yyin, *yyout;
@ -163,7 +167,6 @@ extern FILE *yyin, *yyout;
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
@ -178,6 +181,7 @@ extern FILE *yyin, *yyout;
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_STRUCT_YY_BUFFER_STATE
@ -192,12 +196,12 @@ struct yy_buffer_state
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
int yy_buf_size;
yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@ -248,7 +252,7 @@ struct yy_buffer_state
/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
@ -259,6 +263,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
? (yy_buffer_stack)[(yy_buffer_stack_top)] \
: NULL)
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
@ -266,11 +271,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
int yyleng;
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
yy_size_t yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = NULL;
static char *yy_c_buf_p = (char *) 0;
static int yy_init = 0; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
@ -290,17 +295,19 @@ void yypop_buffer_state ( void );
static void yyensure_buffer_stack (void );
static void yy_load_buffer_state (void );
static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
void yyfree (void * );
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
@ -310,6 +317,7 @@ void yyfree ( void * );
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
@ -319,38 +327,39 @@ void yyfree ( void * );
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
typedef flex_uint8_t YY_CHAR;
FILE *yyin = NULL, *yyout = NULL;
typedef unsigned char YY_CHAR;
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
typedef int yy_state_type;
extern int yylineno;
int yylineno = 1;
extern char *yytext;
#ifdef yytext_ptr
#undef yytext_ptr
#endif
#define yytext_ptr yytext
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
static void yynoreturn yy_fatal_error ( const char* msg );
static void yy_fatal_error (yyconst char msg[] );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
yyleng = (int) (yy_cp - yy_bp); \
yyleng = (yy_size_t) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 34
#define YY_END_OF_BUFFER 35
/* This struct is not used in this scanner,
@ -360,7 +369,7 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[70] =
static yyconst flex_int16_t yy_accept[70] =
{ 0,
0, 0, 35, 34, 10, 11, 20, 34, 5, 6,
3, 1, 12, 2, 4, 31, 9, 16, 13, 17,
@ -371,7 +380,7 @@ static const flex_int16_t yy_accept[70] =
33, 33, 30, 33, 33, 29, 23, 24, 0
} ;
static const YY_CHAR yy_ec[256] =
static yyconst flex_int32_t yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -403,7 +412,7 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[39] =
static yyconst flex_int32_t yy_meta[39] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1, 2, 2,
@ -411,7 +420,7 @@ static const YY_CHAR yy_meta[39] =
2, 2, 2, 2, 2, 1, 1, 1
} ;
static const flex_int16_t yy_base[71] =
static yyconst flex_int16_t yy_base[71] =
{ 0,
0, 0, 79, 80, 80, 80, 61, 71, 80, 80,
80, 80, 80, 80, 80, 25, 80, 59, 58, 57,
@ -422,7 +431,7 @@ static const flex_int16_t yy_base[71] =
17, 24, 0, 21, 15, 0, 0, 0, 80, 40
} ;
static const flex_int16_t yy_def[71] =
static yyconst flex_int16_t yy_def[71] =
{ 0,
69, 1, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 70, 69, 69, 69, 69,
@ -433,7 +442,7 @@ static const flex_int16_t yy_def[71] =
70, 70, 70, 70, 70, 70, 70, 70, 0, 69
} ;
static const flex_int16_t yy_nxt[119] =
static yyconst flex_int16_t yy_nxt[119] =
{ 0,
4, 5, 6, 5, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 21,
@ -450,7 +459,7 @@ static const flex_int16_t yy_nxt[119] =
69, 69, 69, 69, 69, 69, 69, 69
} ;
static const flex_int16_t yy_chk[119] =
static yyconst flex_int16_t yy_chk[119] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -488,8 +497,7 @@ int yywrap(void){
return 1;
}
#line 492 "lex.yy.c"
#line 493 "lex.yy.c"
#line 501 "lex.yy.c"
#define INITIAL 0
@ -522,19 +530,19 @@ void yyset_extra ( YY_EXTRA_TYPE user_defined );
FILE *yyget_in (void );
void yyset_in ( FILE * _in_str );
void yyset_in (FILE * in_str );
FILE *yyget_out (void );
void yyset_out ( FILE * _out_str );
void yyset_out (FILE * out_str );
int yyget_leng ( void );
yy_size_t yyget_leng (void );
char *yyget_text (void );
int yyget_lineno (void );
void yyset_lineno ( int _line_number );
void yyset_lineno (int line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@ -548,21 +556,18 @@ extern int yywrap ( void );
#endif
#endif
#ifndef YY_NO_UNPUT
static void yyunput (int c,char *buf_ptr );
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy ( char *, const char *, int );
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen ( const char * );
static int yy_flex_strlen (yyconst char * );
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void );
#else
@ -573,12 +578,7 @@ static int input ( void );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@ -586,7 +586,7 @@ static int input ( void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
#define ECHO fwrite( yytext, yyleng, 1, yyout )
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -597,7 +597,7 @@ static int input ( void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
int n; \
yy_size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@ -610,7 +610,7 @@ static int input ( void );
else \
{ \
errno=0; \
while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@ -665,7 +665,7 @@ extern int yylex (void);
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK /*LINTED*/break;
#define YY_BREAK break;
#endif
#define YY_RULE_SETUP \
@ -675,9 +675,14 @@ extern int yylex (void);
*/
YY_DECL
{
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
#line 53 "analyse_lexicale.lex"
#line 686 "lex.yy.c"
if ( !(yy_init) )
{
@ -705,13 +710,7 @@ YY_DECL
yy_load_buffer_state( );
}
{
#line 53 "analyse_lexicale.lex"
#line 713 "lex.yy.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
while ( 1 ) /* loops until end-of-file is reached */
{
yy_cp = (yy_c_buf_p);
@ -727,7 +726,7 @@ YY_DECL
yy_match:
do
{
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -737,9 +736,9 @@ yy_match:
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 70 )
yy_c = yy_meta[yy_c];
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 80 );
@ -937,7 +936,7 @@ YY_RULE_SETUP
#line 98 "analyse_lexicale.lex"
ECHO;
YY_BREAK
#line 941 "lex.yy.c"
#line 940 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -1068,7 +1067,6 @@ case YY_STATE_EOF(INITIAL):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
@ -1080,9 +1078,9 @@ case YY_STATE_EOF(INITIAL):
*/
static int yy_get_next_buffer (void)
{
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = (yytext_ptr);
int number_to_move, i;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = (yytext_ptr);
register int number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@ -1111,7 +1109,7 @@ static int yy_get_next_buffer (void)
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@ -1124,21 +1122,21 @@ static int yy_get_next_buffer (void)
else
{
int num_to_read =
yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@ -1147,12 +1145,11 @@ static int yy_get_next_buffer (void)
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yyrealloc( (void *) b->yy_ch_buf,
(yy_size_t) (b->yy_buf_size + 2) );
yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
}
else
/* Can't grow it, we don't own it. */
b->yy_ch_buf = NULL;
b->yy_ch_buf = 0;
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
@ -1194,15 +1191,12 @@ static int yy_get_next_buffer (void)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
/* "- 2" to take care of EOB's */
YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}
(yy_n_chars) += number_to_move;
@ -1218,14 +1212,14 @@ static int yy_get_next_buffer (void)
static yy_state_type yy_get_previous_state (void)
{
yy_state_type yy_current_state;
char *yy_cp;
register yy_state_type yy_current_state;
register char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -1235,9 +1229,9 @@ static int yy_get_next_buffer (void)
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 70 )
yy_c = yy_meta[yy_c];
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
}
return yy_current_state;
@ -1250,10 +1244,10 @@ static int yy_get_next_buffer (void)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
int yy_is_jam;
char *yy_cp = (yy_c_buf_p);
register int yy_is_jam;
register char *yy_cp = (yy_c_buf_p);
YY_CHAR yy_c = 1;
register YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -1263,19 +1257,17 @@ static int yy_get_next_buffer (void)
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 70 )
yy_c = yy_meta[yy_c];
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 69);
return yy_is_jam ? 0 : yy_current_state;
}
#ifndef YY_NO_UNPUT
static void yyunput (int c, char * yy_bp )
static void yyunput (int c, register char * yy_bp )
{
char *yy_cp;
register char *yy_cp;
yy_cp = (yy_c_buf_p);
@ -1285,10 +1277,10 @@ static int yy_get_next_buffer (void)
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
int number_to_move = (yy_n_chars) + 2;
char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
register yy_size_t number_to_move = (yy_n_chars) + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
char *source =
register char *source =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
@ -1297,7 +1289,7 @@ static int yy_get_next_buffer (void)
yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
(yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
@ -1310,8 +1302,6 @@ static int yy_get_next_buffer (void)
(yy_c_buf_p) = yy_cp;
}
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
@ -1336,7 +1326,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@ -1466,7 +1456,7 @@ static void yy_load_buffer_state (void)
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@ -1496,6 +1486,10 @@ static void yy_load_buffer_state (void)
yyfree((void *) b );
}
#ifndef __cplusplus
extern int isatty (int );
#endif /* __cplusplus */
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF.
@ -1616,7 +1610,7 @@ static void yyensure_buffer_stack (void)
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
num_to_alloc = 1;
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
@ -1633,7 +1627,7 @@ static void yyensure_buffer_stack (void)
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
yy_size_t grow_size = 8 /* arbitrary grow size */;
int grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
@ -1663,16 +1657,16 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return NULL;
return 0;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
b->yy_input_file = 0;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
@ -1692,28 +1686,27 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
YY_BUFFER_STATE yy_scan_string (const char * yystr )
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
{
return yy_scan_bytes( yystr, (int) strlen(yystr) );
return yy_scan_bytes(yystr,strlen(yystr) );
}
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param bytes the byte buffer to scan
* @param len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
yy_size_t n, i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = (yy_size_t) (_yybytes_len + 2);
n = _yybytes_len + 2;
buf = (char *) yyalloc(n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@ -1739,9 +1732,9 @@ YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
#define YY_EXIT_FAILURE 2
#endif
static void yynoreturn yy_fatal_error (const char* msg )
static void yy_fatal_error (yyconst char* msg )
{
fprintf( stderr, "%s\n", msg );
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@ -1792,7 +1785,7 @@ FILE *yyget_out (void)
/** Get the length of the current token.
*
*/
int yyget_leng (void)
yy_size_t yyget_leng (void)
{
return yyleng;
}
@ -1807,29 +1800,29 @@ char *yyget_text (void)
}
/** Set the current line number.
* @param _line_number line number
* @param line_number
*
*/
void yyset_lineno (int _line_number )
void yyset_lineno (int line_number )
{
yylineno = _line_number;
yylineno = line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param _in_str A readable stream.
* @param in_str A readable stream.
*
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * _in_str )
void yyset_in (FILE * in_str )
{
yyin = _in_str ;
yyin = in_str ;
}
void yyset_out (FILE * _out_str )
void yyset_out (FILE * out_str )
{
yyout = _out_str ;
yyout = out_str ;
}
int yyget_debug (void)
@ -1837,9 +1830,9 @@ int yyget_debug (void)
return yy_flex_debug;
}
void yyset_debug (int _bdebug )
void yyset_debug (int bdebug )
{
yy_flex_debug = _bdebug ;
yy_flex_debug = bdebug ;
}
static int yy_init_globals (void)
@ -1848,10 +1841,10 @@ static int yy_init_globals (void)
* This function is called from yylex_destroy(), so don't allocate here.
*/
(yy_buffer_stack) = NULL;
(yy_buffer_stack) = 0;
(yy_buffer_stack_top) = 0;
(yy_buffer_stack_max) = 0;
(yy_c_buf_p) = NULL;
(yy_c_buf_p) = (char *) 0;
(yy_init) = 0;
(yy_start) = 0;
@ -1860,8 +1853,8 @@ static int yy_init_globals (void)
yyin = stdin;
yyout = stdout;
#else
yyin = NULL;
yyout = NULL;
yyin = (FILE *) 0;
yyout = (FILE *) 0;
#endif
/* For future reference: Set errno on error, since we are called by
@ -1897,19 +1890,18 @@ int yylex_destroy (void)
*/
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, const char * s2, int n )
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
int i;
register int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (const char * s )
static int yy_flex_strlen (yyconst char * s )
{
int n;
register int n;
for ( n = 0; s[n]; ++n )
;
@ -1919,12 +1911,11 @@ static int yy_flex_strlen (const char * s )
void *yyalloc (yy_size_t size )
{
return malloc(size);
return (void *) malloc( size );
}
void *yyrealloc (void * ptr, yy_size_t size )
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@ -1932,7 +1923,7 @@ void *yyrealloc (void * ptr, yy_size_t size )
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
return realloc(ptr, size);
return (void *) realloc( (char *) ptr, size );
}
void yyfree (void * ptr )
@ -1945,6 +1936,7 @@ void yyfree (void * ptr )
#line 98 "analyse_lexicale.lex"
//int main(void){
// yylex();
//}

View file

@ -6,9 +6,11 @@ echo "
const int var1 = 1, var2;
int var2 = 2 + 3;
int var3, var4 = 4;
if( 4){
var2 = 6;
while (!var2){
var2 = 1;
var3 = 4;
}
printf(var2);
return 5;
}
" | ./a.out