Initial commit
This commit is contained in:
24
src/main/java/de/hsrm/compiler/Klang/Klang.java
Normal file
24
src/main/java/de/hsrm/compiler/Klang/Klang.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package de.hsrm.compiler.Klang;
|
||||
|
||||
// import ANTLR's runtime libraries
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.tree.*;
|
||||
|
||||
public class Klang {
|
||||
public static void main(String[] args) throws Exception {
|
||||
// create a CharStream that reads from standard input
|
||||
ANTLRInputStream input = new ANTLRInputStream(System.in);
|
||||
|
||||
// create a lexer that feeds off of input CharStream
|
||||
KlangLexer lexer = new KlangLexer(input);
|
||||
|
||||
// create a buffer of tokens pulled from the lexer
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
|
||||
// create a parser that feeds off the tokens buffer
|
||||
KlangParser parser = new KlangParser(tokens);
|
||||
|
||||
ParseTree tree = parser.parse(); // begin parsing at init rule
|
||||
System.out.println(tree.toStringTree(parser)); // print LISP-style tree
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user