diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-11-04 10:27:29 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-11-04 10:27:29 +0100 |
commit | 900fb0aee0b68cbb88f578f20019738b4416f436 (patch) | |
tree | 9ac25ac14f2b8eaac7bbd152e4ae567de6b63e16 /src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java | |
parent | 362310157373eef80f49ea6023b1666b3883f4b1 (diff) |
Add query language interpreter code
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java')
-rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java new file mode 100644 index 0000000..57ac1f8 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java @@ -0,0 +1,46 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query; +import java.io.FileNotFoundException; +import java.io.FileReader; + +public class Test +{ + public static void main(String args[]) throws Exception + { + Yylex l = null; + parser p; + try + { + if (args.length == 0) l = new Yylex(System.in); + else l = new Yylex(new FileReader(args[0])); + } + catch(FileNotFoundException e) + { + System.err.println("Error: File not found: " + args[0]); + System.exit(1); + } + p = new parser(l); + /* The default parser is the first-defined entry point. */ + /* You may want to change this. Other options are: */ + /* */ + try + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program parse_tree = p.pProgram(); + System.out.println(); + System.out.println("Parse Succesful!"); + System.out.println(); + System.out.println("[Abstract Syntax]"); + System.out.println(); + System.out.println(PrettyPrinter.show(parse_tree)); + System.out.println(); + System.out.println("[Linearized Tree]"); + System.out.println(); + System.out.println(PrettyPrinter.print(parse_tree)); + } + catch(Throwable e) + { + System.err.println("At line " + String.valueOf(l.line_num()) + ", near \"" + l.buff() + "\" :"); + System.err.println(" " + e.getMessage()); + System.exit(1); + } + } +} |