Skip to content
Snippets Groups Projects
Commit f5f94809 authored by BAZIZI Zakaria's avatar BAZIZI Zakaria
Browse files

going

parent ea6754cf
No related branches found
No related tags found
No related merge requests found
Showing
with 747 additions and 0 deletions
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<component name="libraryTable">
<library name="sablecc">
<CLASSES>
<root url="jar://$PROJECT_DIR$/sablecc/sablecc.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/2024-compilation-bazizi.iml" filepath="$PROJECT_DIR$/2024-compilation-bazizi.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
*\.class
*/*\.class
*/*/*\.class
*~
\ No newline at end of file
all: Compiler C3aVM NasmVM SaVM
SaVM: SaVM.java saParser
javac SaVM.java
NasmVM.jar : NasmVM
jar cmf NasmVM.mf NasmVM.jar NasmVM.class nasm
C3aVM: C3aVM.java c3aParser
javac C3aVM.java
NasmVM: NasmVM.java nasmParser
javac NasmVM.java
Compiler.jar : Compiler
jar cmf Compiler.mf Compiler.jar *.class sc sa ts nasm util c3a fg ig lParser
Compiler: Compiler.java lParser
javac Compiler.java
lParser: l.cfg
java -jar ../sablecc/sablecc.jar l.cfg
saParser: sa.cfg
java -jar ../sablecc/sablecc.jar sa.cfg
c3aParser: c3a.cfg
java -jar ../sablecc/sablecc.jar c3a.cfg
nasmParser: nasm.cfg
java -jar ../sablecc/sablecc.jar nasm.cfg
ualParser: ual.cfg
java -jar ../sablecc/sablecc.jar ual.cfg
clean:
-rm *.class
-rm sc/*.class
-rm sa/*.class
-rm c3a/*.class
-rm ts/*.class
-rm nasm/*.class
-rm fg/*.class
-rm ig/*.class
-rm util/intset/*.class
-rm util/graph/*.class
-rm util/*.class
-rm -r lParser
-rm -r saParser
-rm -r c3aParser
-rm -r nasmParser
Package c3aParser;
Helpers
lettre = [['a' .. 'z'] + ['A' .. 'Z']];
chiffre = ['0' .. '9'];
alpha = [lettre + ['_' + '$']];
alphanum = [lettre + chiffre];
Tokens
espaces = (' ' | 13 | 10 | 9)+;
commentaire= '#' [[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
co = '[';
cf = ']';
call = 'call';
stop = 'stop';
fbegin = 'fbegin';
fend = 'fend';
aff = '=';
noteq = '!=';
inf = '<';
infeq = '<=';
sup = '>';
supeq = '>=';
eq = '==';
goto = 'goto';
param = 'param';
ret = 'ret';
if = 'if';
moins = '-';
plus = '+';
fois = '*';
divise = '/';
write = 'write';
read = 'read';
nombre = chiffre+;
prefixe_temp = '@';
identif = alpha alphanum*;
Ignored Tokens
espaces, commentaire;
Productions
prog = listeinst;
listeinst = {recursif} inst listeinst |
{final} inst
;
inst = {add} add |
{sub} sub |
{mul} mul |
{div} div |
{aff} affect |
{jmp} jmp |
{jmpeg} jmpeg |
{jmpneg} jmpneg |
{jmpinf} jmpinf |
{jminfeg} jmpinfeg |
{jmpsup} jmpsup |
{jmpsupeg} jmpsupeg |
{fcall} fcall |
{iwrite} iwrite |
{iread} iread |
{arg} arg |
{return} return |
{begin} begin |
{end} end |
{stop} istop
;
add = etiqop [result]:tv aff [op1]:ctv plus [op2]:ctv;
sub = etiqop [result]:tv aff [op1]:ctv moins [op2]:ctv;
mul = etiqop [result]:tv aff [op1]:ctv fois [op2]:ctv;
div = etiqop [result]:tv aff [op1]:ctv divise [op2]:ctv;
affect = etiqop [result]:tv aff [op1]:ctv;
jmpeg = etiqop if [op1]:ctv eq [op2]:ctv goto [result]:constante;
jmpneg = etiqop if [op1]:ctv noteq [op2]:ctv goto [result]:constante;
jmpinf = etiqop if [op1]:ctv inf [op2]:ctv goto [result]:constante;
jmpinfeg = etiqop if [op1]:ctv infeq [op2]:ctv goto [result]:constante;
jmpsup = etiqop if [op1]:ctv sup [op2]:ctv goto [result]:constante;
jmpsupeg = etiqop if [op1]:ctv supeq [op2]:ctv goto [result]:constante;
jmp = etiqop goto [result]:constante;
begin = identif fbegin;
end = etiqop fend;
fcall = etiqop [result]:tv aff call identif;
iwrite = etiqop write ctv;
iread = etiqop [result]:tv aff read;
arg = etiqop param ctv;
return = etiqop ret ctv;
istop = etiqop stop ctv;
ctv = {c} constante | {t} temporaire | {v} variable;
tv = {t} temporaire | {v} variable;
constante = nombre;
temporaire = prefixe_temp nombre;
variable = {scalaire} identif |
{tab} identif co ctv cf
;
etiqop = {cte} nombre |
{vide}
;
File added
File added
Package lParser;
Helpers
lettre = [['a' .. 'z'] + ['A' .. 'Z']];
chiffre = ['0' .. '9'];
alpha = [lettre + ['_' + '$']];
alphanum = [lettre + chiffre];
Tokens
espaces = (' ' | 13 | 10)+;
commentaire= '#' [[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
plus = '+';
pointvirgule = ';' ;
moins = '-';
ou = '|' ;
et = '&' ;
virgule = ',' ;
egale = '=' ;
inf = '<' ;
fois = '*' ;
diviser = '/' ;
non ='!' ;
gparenthese = '(' ;
dparenthese = ')' ;
accoladeg = '{' ;
accoladed = '}' ;
crochetg = '[' ;
crochetd = ']' ;
bool = 'bool' ;
entier = 'entier' ;
si = 'si' ;
alors = 'alors' ;
tantque = 'tantque' ;
faire = 'faire' ;
sinon = 'sinon' ;
retourner = 'retour' ;
lire ='lire';
ecrire = 'ecrire' ;
nombre = chiffre+;
vrai = 'vrai' ;
faux = 'faux' ;
id = alpha[alpha+chiffre]* ;
Ignored Tokens
espaces, commentaire;
Productions
prog = ldec ldf ;
exp =
{or} exp ou and | {and} and ;
and =
{et} and et equals | {equals} equals ;
equals =
{egale} equals egale add | {inf} equals inf add | {add} add ;
add =
{plus} add plus mult | {moins} add moins mult | {mult} mult ;
mult =
{fois} mult fois neg | {diviser} mult diviser neg | {neg} neg ;
neg =
{non} non neg | {e6} e6 ;
e6 =
{parenthese} gparenthese exp dparenthese
| {nombre} nombre
| {vrai} vrai
| {faux} faux
| {lire} lire gparenthese dparenthese
|{var} var
| {appelfnc} id gparenthese le dparenthese;
ins =
{affectation} var egale exp pointvirgule
|{tq} tantque exp faire bloc
|{si} si exp alors bloc
|{sisinon} si exp alors [alor]:bloc sinon [sino]:bloc
|{return} retourner exp pointvirgule
|{write} ecrire gparenthese exp dparenthese pointvirgule
|{appelfnc} id gparenthese le dparenthese pointvirgule ;
bloc = {instr} accoladeg li accoladed;
li = {listeinstr} ins li | {epsilon} epsilon ;
epsilon = ;
le = {expr} exp lse | {epsilon} epsilon ;
lse = {lstexpr} virgule exp lse | {epsilon} epsilon ;
var = {id} id | {id_crochet} id crochetg exp crochetd ;
decvar = {declavariable} type id |type id crochetg nombre crochetd ;
type = {type} bool | entier ;
decfonc = {declafonc} typeopt id gparenthese [firstldec]: ldec dparenthese [secondldec]: ldec bloc ;
typeopt= {typeopt} type | epsilon ;
ldec = {lstdeclacvar} decvar suitedec | epsilon ;
suitedec = {suitedeclvar} virgule decvar suitedec |epsilon ;
ldf = {lstdecfnc} decfonc ldf | epsilon ;
File added
File added
Package nasmParser;
Helpers
letter = [['a' .. 'z'] + ['A' .. 'Z']];
digit = ['0' .. '9'];
alpha = [letter + ['_' + '$']];
alphanum = [letter + digit];
Tokens
spaces = (' ' | 13 | 10 | 9)+;
comment= ';' [[0 .. 0xffff] - [10 + 13]]* (10 | 13 | 10 13);
plus = '+';
minus = '-';
times = '*';
brackopen = '[';
brackclose = ']';
semicol = ':';
comma = ',';
quote = ''';
dot = '.';
percentage = '%';
byte = 'byte';
word = 'word';
dword = 'dword';
prefix_register = '@';
inc = 'include';
section = 'section';
data = '.data';
definebyte = 'db';
defineword = 'dw';
definedoubleword = 'dd';
definequadword = 'dq';
definetenbytes = 'dt';
bss = '.bss';
reservebyte = 'resb';
reserveword = 'resw';
reservedoubleword = 'resd';
reservequadword = 'resq';
reservetenbytes = 'rest';
text = '.text';
global = 'global';
mov = 'mov';
push = 'push';
pop = 'pop';
add = 'add';
sub = 'sub';
imul = 'imul';
idiv = 'idiv';
and = 'and';
or = 'or';
xor = 'xor';
not = 'not';
cmp = 'cmp';
jmp = 'jmp';
je = 'je';
jne = 'jne';
jg = 'jg';
jge = 'jge';
jl = 'jl';
jle = 'jle';
call = 'call';
ret = 'ret';
int = 'int 0x80';
eax = 'eax';
ebx = 'ebx';
ecx = 'ecx';
edx = 'edx';
ebp = 'ebp';
esp = 'esp';
number = digit+;
id = alpha alphanum*;
Ignored Tokens
spaces, comment;
Productions
prog = linclude secdata secbss sectext;
linclude = {rec} include linclude
| {empty};
include = percentage inc [open]: quote filename [close]: quote ;
filename = {simple} label
| {complex} [prefix]: label dot [suffix]: label
;
secdata = {nonempty} section data lconst
| {empty}
;
lconst = {rec} const lconst
| {empty} ;
const = {db} label definebyte numconst
| {dw} label defineword numconst
| {dd} label definedoubleword numconst
| {dq} label definequadword numconst
| {dt} label definetenbytes numconst
;
secbss = {nonempty} section bss lvar
| {empty}
;
lvar = {rec} var lvar
| {empty}
;
var = {resb} label semicol reservebyte number
| {resw} label semicol reserveword number
| {resd} label semicol reservedoubleword number
| {resq} label semicol reservequadword number
| {rest} label semicol reservetenbytes number
;
sectext = section text lglobal linst;
lglobal = {rec} global label lglobal
| {empty}
;
linst = {rec} inst linst |
{last} inst
;
inst = {mov} oplabel mov ar comma acr
| {push} oplabel push acr
| {pop} oplabel pop ar
| {add} oplabel add ar comma acr
| {sub} oplabel sub ar comma acr
| {imul} oplabel imul ar comma acr
| {idiv} oplabel idiv ar
| {and} oplabel and ar comma acr
| {or} oplabel or ar comma acr
| {xor} oplabel xor ar comma acr
| {not} oplabel not ar
| {cmp} oplabel cmp ar comma acr
| {jmp} oplabel jmp label
| {je} oplabel je label
| {jne} oplabel jne label
| {jg} oplabel jg label
| {jge} oplabel jge label
| {jl} oplabel jl label
| {call} oplabel call label
| {ret} oplabel ret
| {inter} oplabel int
;
acr = {address} address
| {numconst} numconst
| {register} register
;
ar = {address} address
| {register} register
;
address = opsizeof brackopen exp brackclose;
opsizeof = {byte} byte
| {word} word
| {dword} dword
| {empty}
;
exp = {plus} exp plus exp1
| {minus} exp minus exp1
| {next} exp1
;
exp1 = {times} exp1 times exp2
| {next} exp2
;
exp2 = {label} label
| {numconst} numconst
| {register} register
;
numconst = number;
register = {temp} prefix_register number
| {eax} eax
| {ebx} ebx
| {ecx} ecx
| {edx} edx
| {ebp} ebp
| {esp} esp
;
oplabel = {label} label semicol
| {empty}
;
label = id;
File added
File added
Package saParser;
Helpers
lettre = [['a' .. 'z'] + ['A' .. 'Z']];
chiffre = ['0' .. '9'];
alpha = [lettre + ['_' + '$']];
alphanum = [lettre + chiffre];
Tokens
espaces = (' ' | 13 | 10 | 9)+;
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';
entier = 'entier';
bool = 'bool';
nul = 'nul';
integer = chiffre+;
id = alpha alphanum*;
Ignored Tokens
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
File added
File added
/* This file was generated by SableCC (http://www.sablecc.org/). */
package c3aParser.analysis;
import c3aParser.node.*;
public interface Analysis extends Switch
{
Object getIn(Node node);
void setIn(Node node, Object o);
Object getOut(Node node);
void setOut(Node node, Object o);
void caseStart(Start node);
void caseAProg(AProg node);
void caseARecursifListeinst(ARecursifListeinst node);
void caseAFinalListeinst(AFinalListeinst node);
void caseAAddInst(AAddInst node);
void caseASubInst(ASubInst node);
void caseAMulInst(AMulInst node);
void caseADivInst(ADivInst node);
void caseAAffInst(AAffInst node);
void caseAJmpInst(AJmpInst node);
void caseAJmpegInst(AJmpegInst node);
void caseAJmpnegInst(AJmpnegInst node);
void caseAJmpinfInst(AJmpinfInst node);
void caseAJminfegInst(AJminfegInst node);
void caseAJmpsupInst(AJmpsupInst node);
void caseAJmpsupegInst(AJmpsupegInst node);
void caseAFcallInst(AFcallInst node);
void caseAIwriteInst(AIwriteInst node);
void caseAIreadInst(AIreadInst node);
void caseAArgInst(AArgInst node);
void caseAReturnInst(AReturnInst node);
void caseABeginInst(ABeginInst node);
void caseAEndInst(AEndInst node);
void caseAStopInst(AStopInst node);
void caseAAdd(AAdd node);
void caseASub(ASub node);
void caseAMul(AMul node);
void caseADiv(ADiv node);
void caseAAffect(AAffect node);
void caseAJmpeg(AJmpeg node);
void caseAJmpneg(AJmpneg node);
void caseAJmpinf(AJmpinf node);
void caseAJmpinfeg(AJmpinfeg node);
void caseAJmpsup(AJmpsup node);
void caseAJmpsupeg(AJmpsupeg node);
void caseAJmp(AJmp node);
void caseABegin(ABegin node);
void caseAEnd(AEnd node);
void caseAFcall(AFcall node);
void caseAIwrite(AIwrite node);
void caseAIread(AIread node);
void caseAArg(AArg node);
void caseAReturn(AReturn node);
void caseAIstop(AIstop node);
void caseACCtv(ACCtv node);
void caseATCtv(ATCtv node);
void caseAVCtv(AVCtv node);
void caseATTv(ATTv node);
void caseAVTv(AVTv node);
void caseAConstante(AConstante node);
void caseATemporaire(ATemporaire node);
void caseAScalaireVariable(AScalaireVariable node);
void caseATabVariable(ATabVariable node);
void caseACteEtiqop(ACteEtiqop node);
void caseAVideEtiqop(AVideEtiqop node);
void caseTEspaces(TEspaces node);
void caseTCommentaire(TCommentaire node);
void caseTCo(TCo node);
void caseTCf(TCf node);
void caseTCall(TCall node);
void caseTStop(TStop node);
void caseTFbegin(TFbegin node);
void caseTFend(TFend node);
void caseTAff(TAff node);
void caseTNoteq(TNoteq node);
void caseTInf(TInf node);
void caseTInfeq(TInfeq node);
void caseTSup(TSup node);
void caseTSupeq(TSupeq node);
void caseTEq(TEq node);
void caseTGoto(TGoto node);
void caseTParam(TParam node);
void caseTRet(TRet node);
void caseTIf(TIf node);
void caseTMoins(TMoins node);
void caseTPlus(TPlus node);
void caseTFois(TFois node);
void caseTDivise(TDivise node);
void caseTWrite(TWrite node);
void caseTRead(TRead node);
void caseTNombre(TNombre node);
void caseTPrefixeTemp(TPrefixeTemp node);
void caseTIdentif(TIdentif node);
void caseEOF(EOF node);
void caseInvalidToken(InvalidToken node);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment