print les strings
This commit is contained in:
@@ -81,11 +81,18 @@ instruction returns [Instruction out]:
|
|||||||
})*
|
})*
|
||||||
{$out = new DeclarationImp($t.return_type, declare);}
|
{$out = new DeclarationImp($t.return_type, declare);}
|
||||||
| // PRINT
|
| // PRINT
|
||||||
PRINT TEXT
|
PRINT t1=TEXT
|
||||||
{
|
{
|
||||||
String text= $TEXT.getText();
|
String text= $t1.getText();
|
||||||
$out = new PrintImp(text.substring(1,text.length()-1));
|
ArrayList<String> printer= new ArrayList<String>();
|
||||||
}
|
printer.add(text.substring(1,text.length()-1));
|
||||||
|
}(VIRGULE t2=TEXT
|
||||||
|
{
|
||||||
|
String text2= $t2.getText();
|
||||||
|
printer.add(text2.substring(1,text2.length()-1));
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
{$out = new PrintImp(printer);}
|
||||||
;
|
;
|
||||||
|
|
||||||
//Priorité lit(val, const ou paranthese) -> td_exp (*/%) -> exp (+-)
|
//Priorité lit(val, const ou paranthese) -> td_exp (*/%) -> exp (+-)
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String visitPrint(PrintImp instr, String indent) {
|
public String visitPrint(PrintImp instr, String indent) {
|
||||||
return indent+ "PRINT \""+instr.t() +"\"";
|
String str = indent + "PRINT ";
|
||||||
|
for (String elem: instr.t()){
|
||||||
|
str += "\"" +elem +"\"";
|
||||||
|
}
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
//EXPRESSION
|
//EXPRESSION
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class Program{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static record PrintImp(String t) implements Instruction{
|
public static record PrintImp(ArrayList<String> t) implements Instruction{
|
||||||
@Override
|
@Override
|
||||||
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
|
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
|
||||||
return v.visitPrint(this, h);
|
return v.visitPrint(this, h);
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ FUNC INT main() {
|
|||||||
INT a,b,c
|
INT a,b,c
|
||||||
b:=3
|
b:=3
|
||||||
c:=1
|
c:=1
|
||||||
PRINT "coucou, tu peux réparer le visitPrint dans LLVM stp"
|
PRINT "coucou, tu peux réparer le visitPrint dans LLVM stp","il manque virgule au milieu"
|
||||||
RETURN 4 + 6 * 5 + 2 }
|
RETURN 4 + 6 * 5 + 2 }
|
||||||
Reference in New Issue
Block a user