SlideShare a Scribd company logo
Grammaire ETF fichier lex
%{
%}
let [a-zA-Z]
ch [0-9]
%%
[ tn]+ ;
{let}({let}|{ch}|_)* return (IDENT);
{ch}+ {yylval=atoi(yytext);return (N_I);}
"+" return (ADD);
"*" return (MUL);
"-" return (MOINS);
( return (P_O);
) return (P_F);
"#" return (DIEZE);
%%
//_______________________________________________________________________
Grammaire ETF fichier bison
%{
#include <stdio.h>
%}
%token ADD
%token MOINS
%token MUL
%token SUB
%token IDENT
%token N_I
%token P_O
%token P_F
%token DIEZE
%start L
%%
L : L Ep {printf("r01n");}| ;
Ep: E DIEZE {$$=$1; printf("r0");printf("=%d ",$$);}
;
E: E ADD T {$$=$1+$3; printf("r1,");}
| E MOINS T {$$=$1-$3; printf("r11,");}
| T {$$=$1; printf("r2,");}
;
T: T MUL F {$$=$1*$3; printf("r3,");}
| F {$$=$1; printf("r4,");}
;
F: P_O E P_F {$$=$2; printf("r5,");}
| N_I {$$=$1; printf("r6,");}
;
%%
#include "lex.yy.c"
int yywrap(void){
return 1;
}
int main (int argc, char *argv[]){
yyin = fopen(argv[1], "r");
yyparse();
fclose(yyin);
return 0;
}
advanced_cal.l
%{
#include <stdio.h>
%}
ch [0-9]
%%
[ t]+ ;
{ch}+ {sscanf(yytext,"%lf",&yylval);return (NB);}
"#" {return (DIEZE);}
n|. {return(yytext[0]);}
%%
//_____________________________________________________________________
advanced_calc.y
%{
#include <ctype.h>
#include <stdio.h>
#define YYSTYPE double /* type de la pile de yacc*/
%}
%token NB DIEZE
%left '+' '-'
%left '*' '/'
%right moins_unaire
%%
L : L Ep 'n' {printf("r01nn");}| {printf("r02nn") ;}
;
Ep: E DIEZE {$$=$1; printf("r0");printf("=%lfn",$$);}
;
E: E '+' E {$$=$1+$3;printf("r4n");}
|E '-' E {$$=$1-$3;printf("r5n");}
|E '*' E {$$=$1*$3;printf("r6n");}
|E '/' E {$$=$1/$3;printf("r7n");}
|'(' E ')' {$$=$2;printf("r8n");}
| '-' E %prec moins_unaire {$$= -$2;printf("r9n");}
| NB {printf("r10n");}
;
%%
#include "lex.yy.c"
int yywrap(void){return 1;}
int main (int argc, char *argv[]){
yyin = fopen(argv[1], "r");
yyparse();
fclose(yyin);
return 0;
}
/*
flex nom.l
bison nom.y -d -v
cc -o nom nom.tab.c -ly -ll*/
Grammaire expressions régulières
%{
#include <stdio.h>
%}
let [a-z]
%%
[ t]+ ;
{let}+ {return (ID);}
"#" {return (DIEZE);}
n|. {return(yytext[0]);}
%%
fichier.y
%{
#include <ctype.h>
#include <stdio.h>
#define YYSTYPE double /* type de la pile de yacc*/
%}
%token ID DIEZE
%left '|'
%left '.'
%left '*'
%%
L : L Ep 'n' {printf("r01nn");}
|{printf("r02n");}
;
Ep: E DIEZE {printf("r0n");}
;
E: E '|' E {printf("r1n");}
|E '.' E {printf("r2n");}
|E'*' {printf("r3n");}
|'(' E ')' {printf("r4n");}
| ID {printf("r5n");}
;
%%
#include "lex.yy.c"
int yywrap(void){return 1;}
int main (int argc, char *argv[]){
yyin = fopen(argv[1], "r");
yyparse();
fclose(yyin);
return 0;
}
/*
flex nom.l
bison nom.y -d -v
cc -o nom nom.tab.c -ly -ll*/
si alors sinon
%{
#include <stdio.h>
%}
%%
[ t]+ ;
"a" {return (A);}
"i" {return (IF);}
"e" {return (ELSE);}
"#" {return (DIEZE);}
n|. {return(yytext[0]);}
%%
//_____________ grammaire ambigue____________________
%{
#include <stdio.h>
%}
%token IF ELSE A DIEZE
%%
L : IS L { printf("r1n");}
| { printf("r0n");}
IS :I DIEZE 'n'{ printf("r2n");}
;
I : IF I { printf("r3n");}
|IF I ELSE I { printf("r4n");}
| A { printf("r5n");}
;
%%
si alors sinon priorité au décalge % à la réduction____________________
%{
#include <stdio.h>
%}
%token A IF DIEZE
%nonassoc REDUCE
%nonassoc ELSE
%%
L : IS L { printf("r1n");}
|{ printf("r0n");}
;
IS :I DIEZE 'n'{ printf("r2n");}
;
I : IF I ELSE I { printf("r3n");}
| IF I %prec REDUCE { printf("r4n");}
| A { printf("r5n");}
;
%%

More Related Content

What's hot

1346
13461346
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Hazrat Bilal
 
week-6x
week-6xweek-6x
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
Chhom Karath
 
オレオレSecurityバンドル作っちゃいました
オレオレSecurityバンドル作っちゃいましたオレオレSecurityバンドル作っちゃいました
オレオレSecurityバンドル作っちゃいました
Katsuhiro Ogawa
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
rohit kumar
 
Twigエクステンションの作り方
Twigエクステンションの作り方Twigエクステンションの作り方
Twigエクステンションの作り方
Katsuhiro Ogawa
 
F# intro
F# introF# intro
F# intro
Alexey Raga
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
Chhom Karath
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
rohit kumar
 
week-18x
week-18xweek-18x
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
Hazrat Bilal
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
Rumman Ansari
 
basic shell_programs
 basic shell_programs basic shell_programs
basic shell_programs
madhugvskr
 
C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시
Junha Jang
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++
Arun Nair
 
Tu1
Tu1Tu1
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
Laravel collections an overview - Laravel SP
Laravel collections an overview - Laravel SPLaravel collections an overview - Laravel SP
Laravel collections an overview - Laravel SP
Matheus Marabesi
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
argusacademy
 

What's hot (20)

1346
13461346
1346
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
 
week-6x
week-6xweek-6x
week-6x
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
オレオレSecurityバンドル作っちゃいました
オレオレSecurityバンドル作っちゃいましたオレオレSecurityバンドル作っちゃいました
オレオレSecurityバンドル作っちゃいました
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
 
Twigエクステンションの作り方
Twigエクステンションの作り方Twigエクステンションの作り方
Twigエクステンションの作り方
 
F# intro
F# introF# intro
F# intro
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
 
week-18x
week-18xweek-18x
week-18x
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
basic shell_programs
 basic shell_programs basic shell_programs
basic shell_programs
 
C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++
 
Tu1
Tu1Tu1
Tu1
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
 
Laravel collections an overview - Laravel SP
Laravel collections an overview - Laravel SPLaravel collections an overview - Laravel SP
Laravel collections an overview - Laravel SP
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
 

Similar to tp_bison.pdf

Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
Kandarp Tiwari
 
Array Programs.pdf
Array Programs.pdfArray Programs.pdf
Array Programs.pdf
RajKamal557276
 
Vcs17
Vcs17Vcs17
5th Sem SS lab progs
5th Sem SS lab progs5th Sem SS lab progs
5th Sem SS lab progs
Nagarjun Pakka Kannadiga
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
Arkadeep Dey
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
Nithin Kumar,VVCE, Mysuru
 
My C proggram is having trouble in the switch in main. Also the a co.pdf
My C proggram is having trouble in the switch in main. Also the a co.pdfMy C proggram is having trouble in the switch in main. Also the a co.pdf
My C proggram is having trouble in the switch in main. Also the a co.pdf
meerobertsonheyde608
 
C questions
C questionsC questions
C questions
mohamed sikander
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
Mazedurr rahman
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdf
mhande899
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
happycocoman
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
Export Promotion Bureau
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
領一 和泉田
 
programs
programsprograms
programs
Vishnu V
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
Syed Ahmed Zaki
 
#2
#2#2
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Ch4c
Ch4cCh4c
array.ppt
array.pptarray.ppt
array.ppt
DeveshDewangan5
 

Similar to tp_bison.pdf (20)

Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
 
Array Programs.pdf
Array Programs.pdfArray Programs.pdf
Array Programs.pdf
 
Vcs17
Vcs17Vcs17
Vcs17
 
5th Sem SS lab progs
5th Sem SS lab progs5th Sem SS lab progs
5th Sem SS lab progs
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
My C proggram is having trouble in the switch in main. Also the a co.pdf
My C proggram is having trouble in the switch in main. Also the a co.pdfMy C proggram is having trouble in the switch in main. Also the a co.pdf
My C proggram is having trouble in the switch in main. Also the a co.pdf
 
C questions
C questionsC questions
C questions
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdf
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
programs
programsprograms
programs
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
#2
#2#2
#2
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Ch4c
Ch4cCh4c
Ch4c
 
array.ppt
array.pptarray.ppt
array.ppt
 

Recently uploaded

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 

Recently uploaded (20)

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 

tp_bison.pdf

  • 1. Grammaire ETF fichier lex %{ %} let [a-zA-Z] ch [0-9] %% [ tn]+ ; {let}({let}|{ch}|_)* return (IDENT); {ch}+ {yylval=atoi(yytext);return (N_I);} "+" return (ADD); "*" return (MUL); "-" return (MOINS); ( return (P_O); ) return (P_F); "#" return (DIEZE); %% //_______________________________________________________________________ Grammaire ETF fichier bison %{ #include <stdio.h> %} %token ADD %token MOINS %token MUL %token SUB %token IDENT %token N_I %token P_O %token P_F %token DIEZE %start L %% L : L Ep {printf("r01n");}| ; Ep: E DIEZE {$$=$1; printf("r0");printf("=%d ",$$);} ; E: E ADD T {$$=$1+$3; printf("r1,");} | E MOINS T {$$=$1-$3; printf("r11,");} | T {$$=$1; printf("r2,");} ; T: T MUL F {$$=$1*$3; printf("r3,");} | F {$$=$1; printf("r4,");} ; F: P_O E P_F {$$=$2; printf("r5,");} | N_I {$$=$1; printf("r6,");} ; %% #include "lex.yy.c" int yywrap(void){ return 1; } int main (int argc, char *argv[]){ yyin = fopen(argv[1], "r"); yyparse(); fclose(yyin); return 0; }
  • 2. advanced_cal.l %{ #include <stdio.h> %} ch [0-9] %% [ t]+ ; {ch}+ {sscanf(yytext,"%lf",&yylval);return (NB);} "#" {return (DIEZE);} n|. {return(yytext[0]);} %% //_____________________________________________________________________ advanced_calc.y %{ #include <ctype.h> #include <stdio.h> #define YYSTYPE double /* type de la pile de yacc*/ %} %token NB DIEZE %left '+' '-' %left '*' '/' %right moins_unaire %% L : L Ep 'n' {printf("r01nn");}| {printf("r02nn") ;} ; Ep: E DIEZE {$$=$1; printf("r0");printf("=%lfn",$$);} ; E: E '+' E {$$=$1+$3;printf("r4n");} |E '-' E {$$=$1-$3;printf("r5n");} |E '*' E {$$=$1*$3;printf("r6n");} |E '/' E {$$=$1/$3;printf("r7n");} |'(' E ')' {$$=$2;printf("r8n");} | '-' E %prec moins_unaire {$$= -$2;printf("r9n");} | NB {printf("r10n");} ; %% #include "lex.yy.c" int yywrap(void){return 1;} int main (int argc, char *argv[]){ yyin = fopen(argv[1], "r"); yyparse(); fclose(yyin); return 0; } /* flex nom.l bison nom.y -d -v cc -o nom nom.tab.c -ly -ll*/
  • 3. Grammaire expressions régulières %{ #include <stdio.h> %} let [a-z] %% [ t]+ ; {let}+ {return (ID);} "#" {return (DIEZE);} n|. {return(yytext[0]);} %% fichier.y %{ #include <ctype.h> #include <stdio.h> #define YYSTYPE double /* type de la pile de yacc*/ %} %token ID DIEZE %left '|' %left '.' %left '*' %% L : L Ep 'n' {printf("r01nn");} |{printf("r02n");} ; Ep: E DIEZE {printf("r0n");} ; E: E '|' E {printf("r1n");} |E '.' E {printf("r2n");} |E'*' {printf("r3n");} |'(' E ')' {printf("r4n");} | ID {printf("r5n");} ; %% #include "lex.yy.c" int yywrap(void){return 1;} int main (int argc, char *argv[]){ yyin = fopen(argv[1], "r"); yyparse(); fclose(yyin); return 0; } /* flex nom.l bison nom.y -d -v cc -o nom nom.tab.c -ly -ll*/
  • 4. si alors sinon %{ #include <stdio.h> %} %% [ t]+ ; "a" {return (A);} "i" {return (IF);} "e" {return (ELSE);} "#" {return (DIEZE);} n|. {return(yytext[0]);} %% //_____________ grammaire ambigue____________________ %{ #include <stdio.h> %} %token IF ELSE A DIEZE %% L : IS L { printf("r1n");} | { printf("r0n");} IS :I DIEZE 'n'{ printf("r2n");} ; I : IF I { printf("r3n");} |IF I ELSE I { printf("r4n");} | A { printf("r5n");} ; %% si alors sinon priorité au décalge % à la réduction____________________ %{ #include <stdio.h> %} %token A IF DIEZE %nonassoc REDUCE %nonassoc ELSE %% L : IS L { printf("r1n");} |{ printf("r0n");} ; IS :I DIEZE 'n'{ printf("r2n");} ; I : IF I ELSE I { printf("r3n");} | IF I %prec REDUCE { printf("r4n");} | A { printf("r5n");} ; %%