appeal VSL
This commit is contained in:
@@ -160,6 +160,15 @@ instruction returns [Instruction out]:
|
|||||||
{$out = new WhileImp($exp1.out,$ins3.out);}
|
{$out = new WhileImp($exp1.out,$ins3.out);}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
list_expression returns [ArrayList<Expression> out ]
|
||||||
|
@init
|
||||||
|
{$out = new ArrayList<Expression>(); }:
|
||||||
|
e1= expression
|
||||||
|
{out.add($e1.out);}
|
||||||
|
((VIRGULE e2=expression)
|
||||||
|
{out.add($e2.out);}
|
||||||
|
)*
|
||||||
|
;
|
||||||
//Priorité lit(val, const ou paranthese) -> td_exp (*/%) -> exp (+-)
|
//Priorité lit(val, const ou paranthese) -> td_exp (*/%) -> exp (+-)
|
||||||
expression returns [Expression out]:
|
expression returns [Expression out]:
|
||||||
//Fix LL1 and compare add and sub first
|
//Fix LL1 and compare add and sub first
|
||||||
@@ -177,9 +186,9 @@ expression returns [Expression out]:
|
|||||||
;
|
;
|
||||||
|
|
||||||
td_expression returns [Expression out]:
|
td_expression returns [Expression out]:
|
||||||
left=lit {
|
left=lit {
|
||||||
$out = $left.out;
|
$out = $left.out;
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
(DIV right=lit{$out = new BinopExpressionImp(Op.DIV,$out,$right.out);})
|
(DIV right=lit{$out = new BinopExpressionImp(Op.DIV,$out,$right.out);})
|
||||||
| //MOD
|
| //MOD
|
||||||
@@ -196,9 +205,11 @@ lit returns [Expression out]:
|
|||||||
| ParO e=expression ParF{
|
| ParO e=expression ParF{
|
||||||
$out=$e.out;
|
$out=$e.out;
|
||||||
}
|
}
|
||||||
| t=ident{
|
| t=ident
|
||||||
$out=new VarImp($t.out);
|
(
|
||||||
}
|
ParO (para=list_expression) ParF {$out = new AppealImp($t.out,$para.out);}
|
||||||
|
| {$out=new VarImp($t.out);}
|
||||||
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
ident returns [String out]:
|
ident returns [String out]:
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ public class Program{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Declaration
|
//Declaration
|
||||||
|
|
||||||
public static record DeclarationImp(Type t, ArrayList<String> s) implements Declaration{
|
public static record DeclarationImp(Type t, ArrayList<String> s) implements Declaration{
|
||||||
@Override
|
@Override
|
||||||
public <H, S> S accept(DeclVisitor<H, S> v, H h) {
|
public <H, S> S accept(DeclVisitor<H, S> v, H h) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ PROTO INT add(x,y)
|
|||||||
|
|
||||||
FUNC INT add(x,y) {
|
FUNC INT add(x,y) {
|
||||||
INT z
|
INT z
|
||||||
y := x+y
|
z := x+y
|
||||||
RETURN z
|
RETURN z
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ FUNC INT main(x,y) {
|
|||||||
x := 5
|
x := 5
|
||||||
minh := x * y
|
minh := x * y
|
||||||
b:=3
|
b:=3
|
||||||
c:=1
|
c:=add(x,b)
|
||||||
PRINT "coucou, tu peux réparer le visitPrint dans LLVM stp","il manque virgule au milieu", c*5+b
|
PRINT "coucou, tu peux réparer le visitPrint dans LLVM stp","il manque virgule au milieu", c*5+b
|
||||||
WHILE b - 1
|
WHILE b - 1
|
||||||
DO{
|
DO{
|
||||||
|
|||||||
Reference in New Issue
Block a user