List of usage examples for org.antlr.v4.tool Grammar Grammar
public Grammar(String grammarText) throws org.antlr.runtime.RecognitionException
From source file:no.ssb.vtl.test.junit.GrammarRule.java
License:Apache License
private void before() { try {//from w w w.j a v a2 s . c om if (grammarURL == null) { try { Class<?> vtlParserClass = ClassLoader.getSystemClassLoader() .loadClass("no.ssb.vtl.parser.VTLParser"); grammarURL = Resources.getResource(vtlParserClass, "VTL.g4"); } catch (ClassNotFoundException e) { throw new RuntimeException( "could not find no.ssb.vtl.parser.VTLParser.class, did you compile antlr project?"); } } String grammarString = Resources.toString(grammarURL, Charset.defaultCharset()); grammar = new Grammar(grammarString); } catch (IOException | RecognitionException e) { throw new IllegalArgumentException("could not create grammar", e); } }