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
Branches
Branches containing commit
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
...
...
@@ -11,22 +11,145 @@ Tokens
espaces
=
(' ' | 13 | 10)+;
commentaire
=
'#'
[[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
plus
=
'
+
'
;
virgule
=
'
,
'
;
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
espaces,
commentaire
;
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
...
...
@@ -9,54 +9,37 @@ alphanum = [lettre + chiffre];
Tokens
espaces
=
(' ' | 13 | 10
| 9
)+;
espaces
=
(' ' | 13 | 10)+;
commentaire
=
'#'
[[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
po
=
'('
;
pf = ')';
saappel
=
'SaAppel'
;
sadecfonc = 'SaDecFonc';
sadectab
=
'SaDecTab'
;
sadecvar = 'SaDecVar';
sadecvarsimple
=
'SaDecVarSimple'
;
saexpadd = 'SaExpAdd';
saexpand
=
'SaExpAnd'
;
saexpappel = 'SaExpAppel';
saexpdiv
=
'SaExpDiv'
;
saexpequal = 'SaExpEqual';
saexpfaux
=
'SaExpFaux'
;
saexpinf = 'SaExpInf';
saexpint
=
'SaExpInt'
;
saexplire = 'SaExpLire';
saexpmult
=
'SaExpMult'
;
saexpnot = 'SaExpNot';
saexpor
=
'SaExpOr'
;
saexpsub = 'SaExpSub';
saexpvar
=
'SaExpVar'
;
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'
;
virgule
=
','
;
divise = '/';
point_virgule
=
';'
;
fois = '*';
moins
=
'-'
;
parenthese_ouvrante = '(';
parenthese_fermante
=
')'
;
crochet_ouvrant = '[';
crochet_fermant
=
']'
;
accolade_ouvrante = '{';
accolade_fermante
=
'}'
;
egal = '=';
inferieur
=
'<'
;
et = '&';
ou
=
'|'
;
non = '!';
plus
=
'+'
;
nonnull = '?';
si
=
'si'
;
alors = 'alors';
sinon
=
'sinon'
;
tantque = 'tantque';
faire
=
'faire'
;
entier = 'entier';
bool
=
'bool'
;
nul = 'nul';
integer
=
chiffre+;
id
=
alpha alphanum*;
retour
=
'retour'
;
lire = 'lire';
ecrire
=
'ecrire'
;
nombre = chiffre+;
identif
=
alpha alphanum*;
Ignored
Tokens
...
...
@@ -64,64 +47,147 @@ espaces, commentaire;
Productions
prog
=
po saprog ldecvar ldecfonc pf;
exp
=
{add} po saexpadd [op1]:exp [op2]:exp pf
|
{and}
po
saexpand
[op1]
:exp
[op2]
:exp
pf
|
{div}
po
saexpdiv
[op1]
:exp
[op2]
:exp
pf
|
{equal}
po
saexpequal
[op1]
:exp
[op2]
:exp
pf
|
{inf}
po
saexpinf
[op1]
:exp
[op2]
:exp
pf
|
{mult}
po
saexpmult
[op1]
:exp
[op2]
:exp
pf
|
{or}
po
saexpor
[op1]
:exp
[op2]
:exp
pf
|
{sub}
po
saexpsub
[op1]
:exp
[op2]
:exp
pf
|
{not}
po
saexpnot
exp
pf
|
{appel}
po
saexpappel
appel
pf
|
{var}
po
saexpvar
var
pf
|
{faux}
faux
|
{vrai}
vrai
|
{int}
integer
|
{lire}
lire
;
inst
=
{affect} po sainstaffect var exp pf
|
{bloc}
po
sainstbloc
linst
pf
|
{ecriture}
po
sainstecriture
exp
pf
|
{retour}
po
sainstretour
exp
pf
|
{si}
po
sainstsi
exp
[alors]
:inst
[sinon]
:inst
pf
|
{si2}
po
sainstsi
exp
[alors]
:inst
null
pf
|
{tantque}
po
sainsttantque
exp
inst
pf
|
{appel}
appel
;
ldecfonc
=
{rec} po saldecfonc decfonc ldecfonc pf
|
{fin}
null
;
ldecvar
=
{rec} po saldecvar decvar ldecvar pf
|
{fin}
null
;
lexp
=
{rec} po salexp exp lexp pf
|
{fin}
null
;
linst
=
{rec} po salinst inst linst pf
|
{fin}
null
;
decfonc
=
po sadecfonc id type [param]:ldecvar [variables]:ldecvar inst pf;
decvar
=
{tab} po sadectab id type integer pf
|
{simple}
po
sadecvarsimple
id
type
pf
;
var
=
{indicee} po savarindicee id exp pf
|
{simple}
po
savarsimple
id
pf
;
appel
=
po saappel id lexp pf;
type
=
{entier} entier
|
{bool}
bool
|
{null}
nul
;
\ No newline at end of file
programme
=
{decvarldecfonc}
optdecvar
listedecfonc
|
{ldecfonc}
listedecfonc
;
optdecvar
=
listedecvar point_virgule;
listedecvar
=
{decvarldecvar}
decvar
listedecvarbis
|
{decvar}
decvar
;
listedecvarbis
=
{decvarldecvar}
virgule
decvar
listedecvarbis|
{decvar}
virgule
decvar
;
decvar
=
{decvarentier}
entier
identif
|
{decvartableau}
entier
identif
crochet_ouvrant
nombre
crochet_fermant
;
listedecfonc
=
{ldecfoncrec}
decfonc
listedecfonc
|
{ldecfoncfinal}
;
decfonc
=
{decvarinstr}
identif
listeparam
optdecvar
instrbloc
|
{instr}
identif
listeparam
instrbloc
;
listeparam
=
{sansparam}
parenthese_ouvrante
parenthese_fermante
|
{avecparam}
parenthese_ouvrante
listedecvar
parenthese_fermante
;
instr
=
{instraffect}
instraffect
|
{instrbloc
}
instrbloc
|
{instrsi
}
instrsi
|
{instrtantque
}
instrtantque
|
{instrappel
}
instrappel
|
{instrretour
}
instrretour
|
{instrecriture
}
instrecriture
|
{instrvide}
instrvide
|
{instnonnull}
instnonnull
;
instraffect
=
var egal exp point_virgule ;
instrbloc
=
accolade_ouvrante listeinst accolade_fermante ;
//
listeinst
=
instr*;
listeinst
=
{linstrec}
instr
listeinst
|
{linstfinal}
;
instrsi
=
{avecsinon}
si
exp
alors
instrbloc
instrsinon
|
{sanssinon}
si
exp
alors
instrbloc
;
instopetern
=
{sanssinon}
si
exp
nonnull
alors
instrbloc
instopetern
|
{avecsinon}
si
exp2
alors
instrbloc
instnonnull
;
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