Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2024_compilation_seck_wendy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SECK Idrissa
2024_compilation_seck_wendy
Commits
7b7ee1b3
Commit
7b7ee1b3
authored
1 year ago
by
SECK Idrissa
Browse files
Options
Downloads
Patches
Plain Diff
tp1
parent
9aedd869
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/l.cfg
+130
-7
130 additions, 7 deletions
src/l.cfg
src/sa.cfg
+174
-108
174 additions, 108 deletions
src/sa.cfg
with
304 additions
and
115 deletions
src/l.cfg
+
130
−
7
View file @
7b7ee1b3
Package
lParser
;
Package
sc
;
Helpers
Helpers
...
@@ -11,22 +11,145 @@ Tokens
...
@@ -11,22 +11,145 @@ Tokens
espaces
=
(' ' | 13 | 10)+;
espaces
=
(' ' | 13 | 10)+;
commentaire
=
'#'
[[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
commentaire
=
'#'
[[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
plus
=
'
+
'
;
virgule
=
'
,
'
;
nombre = chiffre+;
nombre = chiffre+;
ecrire
=
'ecrire'
;
retour = 'retour';
ptvirgule
=
';'
;
parenthouvrante = '(';
parenthfermante
=
')'
;
crochetouvrant = '[';
crochetfermant
=
']'
;
accolateouvrant = '{';
accolatefermant
=
'}'
;
egal
=
'='
;
plus = '+';
moins
=
'-'
;
mult = '*';
div
=
'/'
;
modulo = '%';
ou
=
'|'
;
et = '&';
negation
=
'!'
;
inferieur = '<';
superieur
=
'>'
;
vrai
=
'vrai'
;
faux = 'faux';
si
=
'si'
;
sinon = 'sinon';
alors
=
'alors'
;
tantque = 'tantque';
faire
=
'faire'
;
lire = 'lire';
entier
=
'entier'
;
bool = 'bool';
concat
=
' '
;
identif
=
alpha alphanum*;
Ignored
Tokens
Ignored
Tokens
espaces,
commentaire
;
espaces,
commentaire
;
Productions
Productions
//
l'axiome
programme
=
listedecvar listedecfonc;
listedecvar
=
{liste_des_variables}
decvar
listedecvarp
|
{vide}
;
listedecvarp
=
{liste_des_variables_prime}
virgule
decvar
listedecvarp
|
{vide}
;
decvar
=
{type1}
type
identif
|
{type2}
type
identif
crochetouvrant
nombre
crochetfermant
;
listedecfonc
=
{liste_des_fonctions}
decfonc
listedecfonc
|
{vide}
;
decfonc
=
typeop
identif
parenthouvrante
[parametre]
:listedecvar
parenthfermante
[varloc]
:listedecvar
blocinst
;
type
=
{entier}
entier
|
{boolean}
bool
;
typeop
=
{type}
type
|
{vide}
;
blocinst
=
accolateouvrant
listeinst
accolatefermant
;
listeinst
=
{liste_instruction}
inst
listeinst
|
{vide}
;
inst
=
{variable}
var
egal
expr
ptvirgule
|
{condition_si}
si
expr
alors
blocinst
|
{condition_sinon}
si
expr
alors
[blocinstsi]
:
blocinst
sinon
[blocinstsinon]
:
blocinst
|
{condition_tantque}
tantque
expr
faire
blocinst
|
{condition_appelle_de_fonction}
identif
parenthouvrante
listeexpr
parenthfermante
ptvirgule
|
{ecrire}
ecrire
parenthouvrante
expr
parenthfermante
ptvirgule
|
{condition_return}
retour
expr
ptvirgule
;
listeexpr
=
{liste_expression}
expr
listeexprp
|
{vide}
;
listeexprp
=
{liste_expression_prime}
virgule
expr
listeexprp
|
{vide}
;
expr
=
{condition_ou}
expr
ou
expr1
|
{expr1}
expr1
;
expr1
=
{condition_et}
expr1
et
expr2
|
{expr2}
expr2
;
expr2
=
{condition_egal}
expr2
egal
expr3
|
{condition_inf}
expr2
inferieur
expr3
|
{expr3}
expr3
;
expr3
=
{condtion_plus}
expr3
plus
expr4
|
{condition_moins}
expr3
moins
expr4
|
{expr4}
expr4
;
expr4
=
{condition_mult}
expr4
mult
expr5
|
{condition_div}
expr4
div
expr5
|
{expr5}
expr5
;
expr5
=
{condition_negation}
negation
expr5
|
{expr6}
expr6
;
expr6
=
{expr}
parenthouvrante
expr
parenthfermante
|
{nombre}
nombre
|
{vrai}
vrai
|
{faux}
faux
|
{identifiant}
identif
parenthouvrante
listeexpr
parenthfermante
|
{lire}
lire
parenthouvrante
parenthfermante
|
{variable}
var
;
expr7
=
{condition_concat} expr7 concat expr8 | {expr} expr8;
expr8
=
{identif} identif | parenthouvrante expr7 parenthfermante ;
programme
=
exp ;
var
=
{id1}
identif
|
{id2}identif
crochetouvrant
expr
crochetfermant
;
exp
=
{plus}
exp
plus
nombre
|
{nb}
nombre
;
This diff is collapsed.
Click to expand it.
src/sa.cfg
+
174
−
108
View file @
7b7ee1b3
Package
s
aParser
;
Package
s
c
;
Helpers
Helpers
...
@@ -9,54 +9,37 @@ alphanum = [lettre + chiffre];
...
@@ -9,54 +9,37 @@ alphanum = [lettre + chiffre];
Tokens
Tokens
espaces
=
(' ' | 13 | 10
| 9
)+;
espaces
=
(' ' | 13 | 10)+;
commentaire
=
'#'
[[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
commentaire
=
'#'
[[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
virgule
=
','
;
divise = '/';
po
=
'('
;
point_virgule
=
';'
;
pf = ')';
fois = '*';
saappel
=
'SaAppel'
;
moins
=
'-'
;
sadecfonc = 'SaDecFonc';
parenthese_ouvrante = '(';
sadectab
=
'SaDecTab'
;
parenthese_fermante
=
')'
;
sadecvar = 'SaDecVar';
crochet_ouvrant = '[';
sadecvarsimple
=
'SaDecVarSimple'
;
crochet_fermant
=
']'
;
saexpadd = 'SaExpAdd';
accolade_ouvrante = '{';
saexpand
=
'SaExpAnd'
;
accolade_fermante
=
'}'
;
saexpappel = 'SaExpAppel';
egal = '=';
saexpdiv
=
'SaExpDiv'
;
inferieur
=
'<'
;
saexpequal = 'SaExpEqual';
et = '&';
saexpfaux
=
'SaExpFaux'
;
ou
=
'|'
;
saexpinf = 'SaExpInf';
non = '!';
saexpint
=
'SaExpInt'
;
plus
=
'+'
;
saexplire = 'SaExpLire';
nonnull = '?';
saexpmult
=
'SaExpMult'
;
si
=
'si'
;
saexpnot = 'SaExpNot';
alors = 'alors';
saexpor
=
'SaExpOr'
;
sinon
=
'sinon'
;
saexpsub = 'SaExpSub';
tantque = 'tantque';
saexpvar
=
'SaExpVar'
;
faire
=
'faire'
;
saexpvrai = 'SaExpVrai';
sainstaffect
=
'SaInstAffect'
;
sainstbloc = 'SaInstBloc';
sainstecriture
=
'SaInstEcriture'
;
sainstretour = 'SaInstRetour';
sainstsi
=
'SaInstSi'
;
sainsttantque = 'SaInstTantQue';
saldecfonc
=
'SaLDecFonc'
;
saldecvar = 'SaLDecVar';
salexp
=
'SaLExp'
;
salinst = 'SaLInst';
saprog
=
'SaProg'
;
savarindicee = 'SaVarIndicee';
savarsimple
=
'SaVarSimple'
;
faux = 'faux';
vrai
=
'vrai'
;
lire = 'lire';
null
=
'null'
;
entier = 'entier';
entier = 'entier';
bool
=
'bool'
;
retour
=
'retour'
;
nul = 'nul';
lire = 'lire';
integer
=
chiffre+;
ecrire
=
'ecrire'
;
id
=
alpha alphanum*;
nombre = chiffre+;
identif
=
alpha alphanum*;
Ignored
Tokens
Ignored
Tokens
...
@@ -64,64 +47,147 @@ espaces, commentaire;
...
@@ -64,64 +47,147 @@ espaces, commentaire;
Productions
Productions
prog
=
po saprog ldecvar ldecfonc pf;
programme
=
{decvarldecfonc}
optdecvar
listedecfonc
|
{ldecfonc}
listedecfonc
;
exp
=
{add} po saexpadd [op1]:exp [op2]:exp pf
|
{and}
po
saexpand
[op1]
:exp
[op2]
:exp
pf
optdecvar
=
listedecvar point_virgule;
|
{div}
po
saexpdiv
[op1]
:exp
[op2]
:exp
pf
|
{equal}
po
saexpequal
[op1]
:exp
[op2]
:exp
pf
listedecvar
=
|
{inf}
po
saexpinf
[op1]
:exp
[op2]
:exp
pf
{decvarldecvar}
decvar
listedecvarbis
|
|
{mult}
po
saexpmult
[op1]
:exp
[op2]
:exp
pf
{decvar}
decvar
;
|
{or}
po
saexpor
[op1]
:exp
[op2]
:exp
pf
|
{sub}
po
saexpsub
[op1]
:exp
[op2]
:exp
pf
|
{not}
po
saexpnot
exp
pf
listedecvarbis
=
|
{appel}
po
saexpappel
appel
pf
{decvarldecvar}
virgule
decvar
listedecvarbis|
|
{var}
po
saexpvar
var
pf
{decvar}
virgule
decvar
;
|
{faux}
faux
|
{vrai}
vrai
decvar
=
|
{int}
integer
{decvarentier}
entier
identif
|
|
{lire}
lire
{decvartableau}
entier
identif
crochet_ouvrant
nombre
crochet_fermant
;
;
listedecfonc
=
inst
=
{affect} po sainstaffect var exp pf
{ldecfoncrec}
decfonc
listedecfonc
|
|
{bloc}
po
sainstbloc
linst
pf
{ldecfoncfinal}
;
|
{ecriture}
po
sainstecriture
exp
pf
|
{retour}
po
sainstretour
exp
pf
decfonc
=
|
{si}
po
sainstsi
exp
[alors]
:inst
[sinon]
:inst
pf
{decvarinstr}
identif
listeparam
optdecvar
instrbloc
|
|
{si2}
po
sainstsi
exp
[alors]
:inst
null
pf
{instr}
identif
listeparam
instrbloc
;
|
{tantque}
po
sainsttantque
exp
inst
pf
|
{appel}
appel
listeparam
=
;
{sansparam}
parenthese_ouvrante
parenthese_fermante
|
{avecparam}
parenthese_ouvrante
listedecvar
parenthese_fermante
;
ldecfonc
=
{rec} po saldecfonc decfonc ldecfonc pf
|
{fin}
null
instr
=
;
{instraffect}
instraffect
|
{instrbloc
}
instrbloc
|
ldecvar
=
{rec} po saldecvar decvar ldecvar pf
{instrsi
}
instrsi
|
|
{fin}
null
{instrtantque
}
instrtantque
|
;
{instrappel
}
instrappel
|
{instrretour
}
instrretour
|
lexp
=
{rec} po salexp exp lexp pf
{instrecriture
}
instrecriture
|
|
{fin}
null
{instrvide}
instrvide
|
;
{instnonnull}
instnonnull
;
linst
=
{rec} po salinst inst linst pf
instraffect
=
var egal exp point_virgule ;
|
{fin}
null
;
instrbloc
=
accolade_ouvrante listeinst accolade_fermante ;
decfonc
=
po sadecfonc id type [param]:ldecvar [variables]:ldecvar inst pf;
//
listeinst
=
instr*;
decvar
=
{tab} po sadectab id type integer pf
listeinst
=
|
{simple}
po
sadecvarsimple
id
type
pf
{linstrec}
instr
listeinst
|
;
{linstfinal}
;
var
=
{indicee} po savarindicee id exp pf
|
{simple}
po
savarsimple
id
pf
;
instrsi
=
appel
=
po saappel id lexp pf;
{avecsinon}
si
exp
alors
instrbloc
instrsinon
|
{sanssinon}
si
exp
alors
instrbloc
;
type
=
{entier} entier
|
{bool}
bool
instopetern
=
|
{null}
nul
{sanssinon}
si
exp
nonnull
alors
instrbloc
instopetern
|
;
{avecsinon}
si
exp2
alors
instrbloc
instnonnull
;
\ No newline at end of file
instnonnull
=
nonnull instrbloc ;
instrsinon
=
sinon instrbloc ;
instrtantque
=
tantque exp faire instrbloc ;
instrappel
=
appelfct point_virgule ;
instrretour
=
retour exp point_virgule ;
instrecriture
=
ecrire parenthese_ouvrante exp parenthese_fermante point_virgule ;
instrvide
=
point_virgule ;
//
################################################################################
//
exp
(booléennes,
arithmétiques)
avec
implémentation
des
priorités.
//
ordre
croissant
de
priorités
comme
suit
(le
|
a
la
plus
petite
priorité)=
//
7.
|
(ou)
//
6.
&
(et)
//
5.
<
=
//
4.
+
-
//
3.
*
/
//
2.
!
(non)
//
1.
(exp)
appelfct
var
[exp]
//
###############################################################################*/
exp
=
{ou}
exp
ou
exp1
|
{exp1}
exp1
;
exp1
=
{et}
exp1
et
exp2
|
{exp2}
exp2
;
exp2
=
{inf}
exp2
inferieur
exp3
|
{egal}
exp2
egal
exp3
|
{exp3}
exp3
;
exp3
=
{plus}
exp3
plus
exp4
|
{moins}
exp3
moins
exp4
|
{exp4}
exp4
;
exp4
=
{fois}
exp4
fois
exp5
|
{divise}
exp4
divise
exp5
|
{exp5}
exp5
;
exp5
=
{non}
non
exp5
|
{exp6}
exp6
;
exp6
=
{nonnull}
nonnull
exp6
|
{exp7}
exp7
;
exp7
=
{nombre}
nombre
|
{appelfct}
appelfct
|
{var}
var
|
{parentheses}
parenthese_ouvrante
exp
parenthese_fermante
|
{lire}
lire
parenthese_ouvrante
parenthese_fermante
;
//
accès
à
une
variable,
case
d'un
tableau
ou
appel
à
fonction
var
=
{vartab}
identif
crochet_ouvrant
exp
crochet_fermant
|
{varsimple}
identif
;
listeexp
=
{recursif}
exp
listeexpbis|
{final}
;
listeexpbis
=
{recursif}
virgule
exp
listeexpbis
|
{final}
;
appelfct
=
identif parenthese_ouvrante listeexp parenthese_fermante ;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment