diff --git a/src/main/antlr/.antlr/VSLLexer.java b/src/main/antlr/.antlr/VSLLexer.java index 7700158..191f1cb 100644 --- a/src/main/antlr/.antlr/VSLLexer.java +++ b/src/main/antlr/.antlr/VSLLexer.java @@ -1,4 +1,4 @@ -// Generated from /home/tuanvu/Desktop/M1/S8/PDS/tp2-vsl-pds/src/main/antlr/VSLLexer.g by ANTLR 4.13.1 +// Generated from c:/Users/Thibaut/Documents/Git/PDS/tp2-vsl-pds/src/main/antlr/VSLLexer.g by ANTLR 4.13.1 package TP2; diff --git a/src/main/antlr/.antlr/VSLParser.java b/src/main/antlr/.antlr/VSLParser.java index fbbe861..da45987 100644 --- a/src/main/antlr/.antlr/VSLParser.java +++ b/src/main/antlr/.antlr/VSLParser.java @@ -1,4 +1,4 @@ -// Generated from /home/tuanvu/Desktop/M1/S8/PDS/tp2-vsl-pds/src/main/antlr/VSLParser.g by ANTLR 4.13.1 +// Generated from c:/Users/Thibaut/Documents/Git/PDS/tp2-vsl-pds/src/main/antlr/VSLParser.g by ANTLR 4.13.1 package TP2; import TP2.asd.Program.*; diff --git a/src/main/antlr/.antlr/VSLParserBaseListener.java b/src/main/antlr/.antlr/VSLParserBaseListener.java new file mode 100644 index 0000000..1b05a5b --- /dev/null +++ b/src/main/antlr/.antlr/VSLParserBaseListener.java @@ -0,0 +1,166 @@ +// Generated from c:/Users/Thibaut/Documents/Git/PDS/tp2-vsl-pds/src/main/antlr/VSLParser.g by ANTLR 4.13.1 + + package TP2; + import TP2.asd.Program.*; + import TP2.asd.*; + import TP2.asd.Interface.*; + import TP2.asd.Eval.*; + + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link VSLParserListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class VSLParserBaseListener implements VSLParserListener { + /** + * {@inheritDoc} + * + *
The default implementation does nothing.
+ */ + @Override public void enterProgram(VSLParser.ProgramContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitProgram(VSLParser.ProgramContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterFunction(VSLParser.FunctionContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitFunction(VSLParser.FunctionContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterPrototype(VSLParser.PrototypeContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitPrototype(VSLParser.PrototypeContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterList_instr(VSLParser.List_instrContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitList_instr(VSLParser.List_instrContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterInstruction(VSLParser.InstructionContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitInstruction(VSLParser.InstructionContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterExpression(VSLParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitExpression(VSLParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterTd_expression(VSLParser.Td_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitTd_expression(VSLParser.Td_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterLit(VSLParser.LitContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitLit(VSLParser.LitContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterIdent(VSLParser.IdentContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitIdent(VSLParser.IdentContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterType(VSLParser.TypeContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitType(VSLParser.TypeContext ctx) { } + + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void visitTerminal(TerminalNode node) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/src/main/antlr/.antlr/VSLParserListener.java b/src/main/antlr/.antlr/VSLParserListener.java new file mode 100644 index 0000000..ab73cf1 --- /dev/null +++ b/src/main/antlr/.antlr/VSLParserListener.java @@ -0,0 +1,116 @@ +// Generated from c:/Users/Thibaut/Documents/Git/PDS/tp2-vsl-pds/src/main/antlr/VSLParser.g by ANTLR 4.13.1 + + package TP2; + import TP2.asd.Program.*; + import TP2.asd.*; + import TP2.asd.Interface.*; + import TP2.asd.Eval.*; + +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link VSLParser}. + */ +public interface VSLParserListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link VSLParser#program}. + * @param ctx the parse tree + */ + void enterProgram(VSLParser.ProgramContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#program}. + * @param ctx the parse tree + */ + void exitProgram(VSLParser.ProgramContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#function}. + * @param ctx the parse tree + */ + void enterFunction(VSLParser.FunctionContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#function}. + * @param ctx the parse tree + */ + void exitFunction(VSLParser.FunctionContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#prototype}. + * @param ctx the parse tree + */ + void enterPrototype(VSLParser.PrototypeContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#prototype}. + * @param ctx the parse tree + */ + void exitPrototype(VSLParser.PrototypeContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#list_instr}. + * @param ctx the parse tree + */ + void enterList_instr(VSLParser.List_instrContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#list_instr}. + * @param ctx the parse tree + */ + void exitList_instr(VSLParser.List_instrContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#instruction}. + * @param ctx the parse tree + */ + void enterInstruction(VSLParser.InstructionContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#instruction}. + * @param ctx the parse tree + */ + void exitInstruction(VSLParser.InstructionContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#expression}. + * @param ctx the parse tree + */ + void enterExpression(VSLParser.ExpressionContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#expression}. + * @param ctx the parse tree + */ + void exitExpression(VSLParser.ExpressionContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#td_expression}. + * @param ctx the parse tree + */ + void enterTd_expression(VSLParser.Td_expressionContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#td_expression}. + * @param ctx the parse tree + */ + void exitTd_expression(VSLParser.Td_expressionContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#lit}. + * @param ctx the parse tree + */ + void enterLit(VSLParser.LitContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#lit}. + * @param ctx the parse tree + */ + void exitLit(VSLParser.LitContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#ident}. + * @param ctx the parse tree + */ + void enterIdent(VSLParser.IdentContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#ident}. + * @param ctx the parse tree + */ + void exitIdent(VSLParser.IdentContext ctx); + /** + * Enter a parse tree produced by {@link VSLParser#type}. + * @param ctx the parse tree + */ + void enterType(VSLParser.TypeContext ctx); + /** + * Exit a parse tree produced by {@link VSLParser#type}. + * @param ctx the parse tree + */ + void exitType(VSLParser.TypeContext ctx); +} \ No newline at end of file diff --git a/src/main/java/TP2/Main.java b/src/main/java/TP2/Main.java index 6c5436d..7c1a7b7 100644 --- a/src/main/java/TP2/Main.java +++ b/src/main/java/TP2/Main.java @@ -29,9 +29,6 @@ public class Main { VSLLexer lexer = new VSLLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); - for (Token token : tokens.getTokens()) { - System.out.println("Token: " + token.getText() + " Type: " + token.getType()); - } // Instantiate Parser VSLParser parser = new VSLParser(tokens); @@ -42,6 +39,8 @@ public class Main { // Pretty-print the program (to debug parsing) System.err.println("todo " + ast); + System.out.println("\n\n PRETTYPRINTER : \n--------------\n" + ast.prettyprinter() + "\n--------------\nFIN PRETTYPRINTER"); + // Verify the program semantic // Generate the intermediate representation diff --git a/src/main/java/TP2/asd/Interface.java b/src/main/java/TP2/asd/Interface.java index acf9656..505c94f 100644 --- a/src/main/java/TP2/asd/Interface.java +++ b/src/main/java/TP2/asd/Interface.java @@ -8,16 +8,20 @@ import TP2.asd.Program.*; public interface Interface{ public interface ProgramI { public