appeal VSL
This commit is contained in:
@@ -160,6 +160,15 @@ instruction returns [Instruction 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 (+-)
|
||||
expression returns [Expression out]:
|
||||
//Fix LL1 and compare add and sub first
|
||||
@@ -177,9 +186,9 @@ expression returns [Expression out]:
|
||||
;
|
||||
|
||||
td_expression returns [Expression out]:
|
||||
left=lit {
|
||||
$out = $left.out;
|
||||
}
|
||||
left=lit {
|
||||
$out = $left.out;
|
||||
}
|
||||
(
|
||||
(DIV right=lit{$out = new BinopExpressionImp(Op.DIV,$out,$right.out);})
|
||||
| //MOD
|
||||
@@ -196,9 +205,11 @@ lit returns [Expression out]:
|
||||
| ParO e=expression ParF{
|
||||
$out=$e.out;
|
||||
}
|
||||
| t=ident{
|
||||
$out=new VarImp($t.out);
|
||||
}
|
||||
| t=ident
|
||||
(
|
||||
ParO (para=list_expression) ParF {$out = new AppealImp($t.out,$para.out);}
|
||||
| {$out=new VarImp($t.out);}
|
||||
)
|
||||
;
|
||||
|
||||
ident returns [String out]:
|
||||
|
||||
@@ -70,7 +70,6 @@ public class Program{
|
||||
}
|
||||
|
||||
//Declaration
|
||||
|
||||
public static record DeclarationImp(Type t, ArrayList<String> s) implements Declaration{
|
||||
@Override
|
||||
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) {
|
||||
INT z
|
||||
y := x+y
|
||||
z := x+y
|
||||
RETURN z
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ FUNC INT main(x,y) {
|
||||
x := 5
|
||||
minh := x * y
|
||||
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
|
||||
WHILE b - 1
|
||||
DO{
|
||||
|
||||
Reference in New Issue
Block a user