예제 #1
0
 void Function(object sender, RulezParser.MessageListener.EventArgs e)
 {
     throw new NotImplementedException();
 }
예제 #2
0
        /// <summary>
        /// generate a selection Rule XPT out of a String
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public SelectionRule Generate(string source)
        {
            RulezParser.MessageListener aListener = new RulezParser.MessageListener();
            RulezParser.SelectionRulezContext aCtx = null;

            try
            {
                RulezLexer aLexer = new RulezLexer(new Antlr4.Runtime.AntlrInputStream(source));
                // wrap a token-stream around the lexer
                Antlr4.Runtime.CommonTokenStream theTokens = new Antlr4.Runtime.CommonTokenStream(aLexer);
                // create the aParser
                RulezParser aParser = new RulezParser(theTokens);
                aParser.Trace = true;
                aParser.Engine = this.Engine;
                aParser.AddErrorListener(aListener);
                // parse
                aCtx = aParser.selectionRulez();
                // return
                return (SelectionRule) aCtx.XPTreeNode;
            }
            catch (Exception ex)
            {
                if (aCtx != null) return (SelectionRule) aCtx.XPTreeNode;
                return null;
            }
        }