playground stuff
This commit is contained in:
parent
468c791267
commit
3e5a976599
|
@ -1,7 +1,6 @@
|
|||
grammar T;
|
||||
|
||||
s : A # X
|
||||
| x
|
||||
;
|
||||
s : rule ;
|
||||
|
||||
A : C ;
|
||||
rule : A # X
|
||||
;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CommonTokenFactory;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.DiagnosticErrorListener;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class TransformEType {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String inputFile = null;
|
||||
if ( args.length>0 ) inputFile = args[0];
|
||||
InputStream is = System.in;
|
||||
if ( inputFile!=null ) {
|
||||
is = new FileInputStream(inputFile);
|
||||
}
|
||||
CharStream input = new ANTLRInputStream(is);
|
||||
|
||||
JavaLRLexer lex = new JavaLRLexer(input);
|
||||
lex.setTokenFactory(new CommonTokenFactory(true));
|
||||
|
||||
CommonTokenStream tokens = new CommonTokenStream(lex);
|
||||
JavaLRParser parser = new JavaLRParser(tokens);
|
||||
|
||||
parser.addErrorListener(new DiagnosticErrorListener());
|
||||
|
||||
ParserRuleContext tree = parser.compilationUnit();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue