code: public static synchronized Grammar getMainGrammar() {
  
      	if (mainGrammar == null) {
      		// Create it...
      		try {
              	final Grammar root = new XmlGrammar("ROOT", null, null, XmlGrammar.class.getClassLoader());
              	final InputStream inpt = XmlGrammar.class.getResourceAsStream(MAIN_GRAMMAR_LOCATION);
                  final Document doc = new SAXReader().read(inpt);
                  final Task k = new ScriptRunner(root).compileTask(doc.getRootElement());
          		final RuntimeRequestResponse req = new RuntimeRequestResponse();
          		final ReturnValueImpl rslt = new ReturnValueImpl();
          		req.setAttribute(Attributes.RETURN_VALUE, rslt);
          		k.perform(req, new RuntimeRequestResponse());
          		mainGrammar = (Grammar) rslt.getValue();
              } catch (Throwable t) {
                  String msg = "Error parsing Main Grammar.";
                  throw new RuntimeException(msg, t);
              }
      	}
  
          return mainGrammar;
  
      }
docs: /*
  Public API.