public String GetParseTreeAsString(String rule) { AntlrInputStream input = new AntlrInputStream(rule); RuleSetLexer lexer = new RuleSetLexer(input); var tokens = new CommonTokenStream(lexer); RuleSetParser parser = new RuleSetParser(tokens); return parser.rule_set().ToStringTree(parser); }
public IRuleSet GetCompiledRule(string rule) { AntlrInputStream input = new AntlrInputStream(rule); RuleSetLexer lexer = new RuleSetLexer(input); var tokens = new CommonTokenStream(lexer); RuleSetParser parser = new RuleSetParser(tokens); RuleSetTreeBuilder ruleSetTreeBuilder = new RuleSetTreeBuilder(jsonParser); parser.AddParseListener(ruleSetTreeBuilder); parser.ErrorHandler = new ExceptionThrowingErrorHandler(); parser.rule_set(); return ruleSetTreeBuilder.ruleSet; }