expression pour printf
This commit is contained in:
@@ -81,17 +81,28 @@ instruction returns [Instruction out]:
|
||||
})*
|
||||
{$out = new DeclarationImp($t.return_type, declare);}
|
||||
| // PRINT
|
||||
PRINT t1=TEXT
|
||||
{
|
||||
String text= $t1.getText();
|
||||
ArrayList<String> printer= new ArrayList<String>();
|
||||
printer.add(text.substring(1,text.length()-1));
|
||||
}(VIRGULE t2=TEXT
|
||||
PRINT
|
||||
{ArrayList<String> printer= new ArrayList<String>();}
|
||||
(t1=TEXT
|
||||
{
|
||||
String text= $t1.getText();
|
||||
printer.add(text.substring(1,text.length()-1));
|
||||
}
|
||||
|e1=expression
|
||||
{ String text_e= $e1.out.toString();
|
||||
printer.add(text_e);
|
||||
})
|
||||
(VIRGULE (t2=TEXT
|
||||
{
|
||||
String text2= $t2.getText();
|
||||
printer.add(text2.substring(1,text2.length()-1));
|
||||
}
|
||||
)*
|
||||
| e2=expression
|
||||
{
|
||||
String text_e2= $e2.out.toString();
|
||||
printer.add(text_e2);
|
||||
}
|
||||
))*
|
||||
{$out = new PrintImp(printer);}
|
||||
| //READ
|
||||
READ i1=ident
|
||||
|
||||
@@ -80,6 +80,13 @@ public class Program{
|
||||
}
|
||||
}
|
||||
|
||||
public static record ReadImp(ArrayList<String> t) implements Instruction{
|
||||
@Override
|
||||
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
|
||||
return v.visitRead(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
//Type
|
||||
public static record Type_voidImp() implements Type{
|
||||
@Override
|
||||
|
||||
@@ -3,4 +3,5 @@ FUNC INT main() {
|
||||
b:=3
|
||||
c:=1
|
||||
PRINT "coucou, tu peux réparer le visitPrint dans LLVM stp","il manque virgule au milieu"
|
||||
PRINT 5 * 5 + 7
|
||||
RETURN 4 + 6 * 5 + 2 }
|
||||
Reference in New Issue
Block a user