Beispiel #1
0
 /// <summary>
 /// Verify a source code and return the Inode
 /// </summary>
 /// <param name="source"></param>
 /// <returns></returns>
 public INode Verifiy(string source)
 {
     RulezParser.MessageListener  aListener = new RulezParser.MessageListener();
     RulezParser.RulezUnitContext 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;
         aParser.AddErrorListener(aListener);
         aCtx = aParser.rulezUnit();
         if (aCtx != null)
         {
             return(aCtx.XPTreeNode);
         }
         return(null);
     }
     catch (Exception ex)
     {
         if (aCtx != null)
         {
             if (aCtx.XPTreeNode != null)
             {
                 aCtx.XPTreeNode.Messages.Add(new Message(type: MessageType.Error, message: ex.Message));
                 return(aCtx.XPTreeNode);
             }
         }
         return(null);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Verify a source code and return the Inode
 /// </summary>
 /// <param name="source"></param>
 /// <returns></returns>
 public INode Verifiy(string source)
 {
     RulezParser.MessageListener aListener = new RulezParser.MessageListener();
     RulezParser.RulezUnitContext 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;
         aParser.AddErrorListener(aListener);
         aCtx = aParser.rulezUnit();
         if (aCtx != null) return aCtx.XPTreeNode;
         return null;
     }
     catch (Exception ex)
     {
         if (aCtx != null)
         {
             if (aCtx.XPTreeNode != null)
             {
                 aCtx.XPTreeNode.Messages.Add(new Message(type: MessageType.Error, message: ex.Message));
                 return aCtx.XPTreeNode;
             }
         }
         return null;
     }
 }