当前位置: 首页>>代码示例>>C#>>正文


C# ParserResult类代码示例

本文整理汇总了C#中ParserResult的典型用法代码示例。如果您正苦于以下问题:C# ParserResult类的具体用法?C# ParserResult怎么用?C# ParserResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParserResult类属于命名空间,在下文中一共展示了ParserResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RetrievePageXDoc

        public static XDoc RetrievePageXDoc(PageBE page, uint pageId, ParserMode mode, string language, bool isInclude, int section, Title relToTitle, bool xhtml, out ParserResult parserResult) {
            uint contextPageId = pageId;
            if((mode == ParserMode.VIEW) && (contextPageId != uint.MaxValue) && page.Title.IsTemplate) {

                // NOTE (steveb): page being rendered is a template and a contextual page was specified; this means we're rendering a global template page
                PageBE contextPage = GetPageById(contextPageId);
                if(contextPage == null) {
                    parserResult = new ParserResult();
                    return null;
                }
                parserResult = DekiXmlParser.ParseGlobalTemplate(contextPage, page);
            } else {
                parserResult = DekiXmlParser.Parse(page, page.ContentType, language ?? page.Language, page.GetText(DbUtils.CurrentSession), mode, isInclude, section, null, relToTitle);
            }
            if(page.Title.IsTemplate && isInclude) {
                DekiXmlParser.PostProcessTemplateInsertBody(parserResult, page);
            }

            // post process tail element
            DekiXmlParser.PostProcessParserResults(parserResult);

            // BUGBUGBUG (steveb): we cannot properly restore an old title unless it had a display title set

            // wrap the result in a content tag and return it to the user
            XDoc result = new XDoc("content")
                    .Attr("type", parserResult.ContentType)
                    .Attr("etag", page.Etag)
                    .Attr("title", page.CustomTitle ?? page.Title.AsUserFriendlyName());

            // check if page contains unsafe content
            if(mode == ParserMode.EDIT) {
                result.Attr("unsafe", !DekiScriptLibrary.VerifyXHtml(parserResult.MainBody, true));
            }

            if(xhtml) {
                result.AddNodes(parserResult.Content);
            } else {

                // encode the result as nodes of text
                foreach(XDoc entry in parserResult.Content.Elements) {
                    if(entry.HasName("body")) {
                        result.Start("body").Attr("target", entry["@target"].AsText).Value(entry.ToInnerXHtml()).End();
                    } else {
                        result.Elem(entry.Name, entry.ToInnerXHtml());
                    }
                }
            }
            return result;
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:49,代码来源:PageBL.cs

示例2: OnFileParsed

        void OnFileParsed(string file, ParserResult result)
        {
            switch (result.Kind)
            {
                case ParserResultKind.Success:
                    Diagnostics.Message("Parsed '{0}'", file);
                    break;
                case ParserResultKind.Error:
                    Diagnostics.Error("Error parsing '{0}'", file);
                    break;
                case ParserResultKind.FileNotFound:
                    Diagnostics.Error("File '{0}' was not found", file);
                    break;
            }

            for (uint i = 0; i < result.DiagnosticsCount; ++i)
            {
                var diag = result.getDiagnostics(i);

                if (Options.IgnoreParseWarnings
                    && diag.Level == ParserDiagnosticLevel.Warning)
                    continue;

                if (diag.Level == ParserDiagnosticLevel.Note)
                    continue;

                Diagnostics.Message("{0}({1},{2}): {3}: {4}",
                    diag.FileName, diag.LineNumber, diag.ColumnNumber,
                    diag.Level.ToString().ToLower(), diag.Message);
            }
        }
开发者ID:robacklin,项目名称:CppSharp,代码行数:31,代码来源:Driver.cs

示例3: __CopyValue

 private static void* __CopyValue(ParserResult.__Internal native)
 {
     var ret = Marshal.AllocHGlobal(28);
     global::CppSharp.Parser.ParserResult.__Internal.cctor_1(ret, new global::System.IntPtr(&native));
     return ret.ToPointer();
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:6,代码来源:CppSharp.CppParser.cs

示例4: ParserResult

 protected ParserResult(ParserResult.Internal* native, bool isInternalImpl = false)
 {
     __Instance = new global::System.IntPtr(native);
 }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:4,代码来源:CppParser.cs

示例5: __CopyValue

 private static ParserResult.Internal* __CopyValue(ParserResult.Internal native)
 {
     var ret = Marshal.AllocHGlobal(56);
     CppSharp.Parser.ParserResult.Internal.cctor_1(ret, new global::System.IntPtr(&native));
     return (ParserResult.Internal*) ret;
 }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:6,代码来源:CppParser.cs

示例6: ParserResult

 protected ParserResult(ParserResult.Internal* native, bool skipVTables = false)
 {
     if (native == null)
         return;
     __Instance = new global::System.IntPtr(native);
 }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:6,代码来源:CppParser.cs

示例7: ParserResult

 private ParserResult(ParserResult.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
 }
开发者ID:corefan,项目名称:CppSharp,代码行数:5,代码来源:CppParser.cs

示例8: Calculate

        public virtual void Calculate(DateTime t1, DateTime t2)
        {
            var t1a = t1;
            var t2a = t2;

            Logger.OnLogEvent += Logger_OnLogEvent;

            var seriesBeforeCalc = this.Clone();
            //if( this.TimeInterval == TimeSeries.TimeInterval.Irregular)
               t2a = t2.AddDays(1); // we may need midnight value in the next day.

               if (this.TimeInterval == TimeSeries.TimeInterval.Daily)
               {
                   // daily_wrdo_pu needs AdjustStartingDate
                   t1a = this.AdjustStartingDateFromProperties(t1, t2a);// DO DO??? needed??
               }

            Exception error = new Exception();

            if (Expression != null && Expression.Trim() != "")
            {
                string tmpExpression = Expression;

                Logger.WriteLine("begin Calculate()");

                Expression = ExpressionPreProcessor();

                ParserResult result = null;
                try
                {
                    result = Parser.Evaluate(this.Expression, t1a, t2a, this.TimeInterval);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Logger.WriteLine(e.Message, "ui");
                    Messages.Add(e.Message);
                    error = e;
                    result = null;
                }

                if (result != null && ( result.IsDouble || result.IsInteger ))
                { // constant expression, need to convert to a Series.
                    Series constant = new Series();
                    constant.TimeInterval = this.TimeInterval;
                    constant = Math.FillMissingWithZero(constant, t1, t2);
                    if( result.IsDouble)
                      constant = Math.Add(constant, result.Double);
                    else
                      constant = Math.Add(constant, result.Integer);
                    result = new ParserResult(constant);
                }

                if (result != null &&  result.IsSeries)
                {
                    result.Series.Trim(t1, t2);
                    //var s = result.Series;
                    //result.Series = Math.Subset(s, t1, t2); // trim extra data used for calculations

                    Logger.WriteLine("Calculation result has " + result.Series.Count + " rows");
                    this.TimeInterval = result.Series.TimeInterval;
                    string tableName = this.Table.TableName;

                    this.Table = result.Series.Table;
                    this.Table.TableName = tableName;
                    if (m_db != null)
                    {
                       // Logger.WriteLine("Setting Flags");
                        m_db.Quality.SetFlags(this);
                    }

                    this.Table.AcceptChanges();// prevents error releated to Deleted rows from Trim() above.
                    foreach (DataRow row in this.Table.Rows)
                    {
                        row.SetAdded(); // so database will insert these rows.
                    }
                    if (m_db != null) // database is not required for calculations.
                    {

                        //bool canSave = m_db.Server.HasSavePrivilge(this.Table.TableName);
                      //  if(canSave)
                        m_db.SaveTimeSeriesTable(this.ID, this, DatabaseSaveOptions.UpdateExisting);
                        Expression = tmpExpression;

                        if (seriesBeforeCalc.TimeInterval != this.TimeInterval
                            || seriesBeforeCalc.Units != this.Units)
                        {
                            Logger.WriteLine("Warning Units or interval has changed.");
                            //if(canSave)
                            m_db.SaveProperties(this); // time interval, units, are dependent on calculation.
                        }
                    }

                }
                else
                {
                    Clear();
                    Console.WriteLine(error.Message);
                    Logger.WriteLine(error.Message);
                }
//.........这里部分代码省略.........
开发者ID:usbr,项目名称:Pisces,代码行数:101,代码来源:CalculationSeries.cs

示例9: parse

        /**
         * Parses a piece of Java code that matches a certain grammar rule.
         *
         * @param pSource  The Java source that should get parsed.
         * @param pCodeFragmentType  The code fragment type defining the grammar
         *                           rule that should be used to parse the code
         *                           fragment.
         * @param pErrorMessages  If this argument is not <code>null</code> error
         *                        messages emited by the parser will be added to
         *                        this list. Otherwise these error messages will be
         *                        written to <code>System.err</code>.
         *
         * @return  An object of type <code>JSOParser.ParserResult</code>
         *          containing the root node representing a Java code fragment and
         *          the token stream containing the tokens of the parsed source.
         *
         * @
         *         if parsing the code fragment or creating the AST failes.
         * @throws RecognitionException
         *
         * __TEST__  All parsable code fragments still untested for parser failure.
         */
        private ParserResult parse(
            ANTLRStringStream pSource, CodeFragmentType pCodeFragmentType,
            List<String> pErrorMessages)
        {
            ParserResult result = new ParserResult();
            bool isMessageCollectingEnabled = pErrorMessages != null;
            mLexer.CharStream = pSource;
            mLexer.EnableErrorMessageCollection(isMessageCollectingEnabled);
            TokenRewriteStream tokenRewriteStream =
            new TokenRewriteStream(mLexer);
            if (mParser != null) {
            mParser.TokenStream = tokenRewriteStream;
            } else {
            mParser = new JavaParser(tokenRewriteStream);
            mParser.TreeAdaptor = mAST2JSOMTreeAdaptor;
            }
            mParser.EnableErrorMessageCollection(isMessageCollectingEnabled);
            AST2JSOMTree tree = null;
            if (pCodeFragmentType == CodeFragmentType.ANNOTATION) {
            tree = (AST2JSOMTree) mParser.annotation().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.ASSERT_STATEMENT) {
            tree = (AST2JSOMTree) mParser.assertStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.BREAK_STATEMENT) {
            tree = (AST2JSOMTree) mParser.breakStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.CLASS_EXTENDS_CLAUSE) {
            tree = (AST2JSOMTree) mParser.classExtendsClause().Tree;
            } else if (   pCodeFragmentType
                   == CodeFragmentType.COMPLEX_TYPE_IDENTIFIER) {
            tree = (AST2JSOMTree) mParser.typeIdent().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.CONTINUE_STATEMENT) {
            tree = (AST2JSOMTree) mParser.continueStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.DO_WHILE_STATEMENT) {
            tree = (AST2JSOMTree) mParser.doWhileStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.ENUM_CONSTANT) {
            tree = (AST2JSOMTree) mParser.enumConstant().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.EXPRESSION) {
            tree = (AST2JSOMTree) mParser.expression().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.EXPRESSION_STATEMENT) {
            tree = (AST2JSOMTree) mParser.expressionStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.FOR_STATEMENT) {
            tree = (AST2JSOMTree) mParser.forStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.FOREACH_STATEMENT) {
            tree = (AST2JSOMTree) mParser.forEachStatement().Tree;
            } else if (   pCodeFragmentType
                   == CodeFragmentType.FORMAL_PARAMETER_LIST) {
            tree = (AST2JSOMTree) mParser.formalParameterList().Tree;
            } else if (   pCodeFragmentType
                   == CodeFragmentType.GENERIC_TYPE_ARGUMENT_LIST) {
            tree = (AST2JSOMTree) mParser.genericTypeArgumentList().Tree;
            } else if (   pCodeFragmentType
                == CodeFragmentType.GENERIC_TYPE_PARAMETER_LIST) {
             tree = (AST2JSOMTree) mParser.genericTypeParameterList().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.IF_STATEMENT) {
            tree = (AST2JSOMTree) mParser.ifStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.IMPLEMENTS_CLAUSE) {
            tree = (AST2JSOMTree) mParser.implementsClause().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.IMPORT_DECLARATION) {
            tree = (AST2JSOMTree) mParser.importDeclaration().Tree;
            } else if (   pCodeFragmentType
                   == CodeFragmentType.INTERFACE_EXTENDS_CLAUSE) {
            tree = (AST2JSOMTree) mParser.interfaceExtendsClause().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.JAVA_SOURCE) {
            tree = (AST2JSOMTree) mParser.javaSource().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.LABELED_STATEMENT) {
            tree = (AST2JSOMTree) mParser.labeledStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.LOCAL_VARIABLE_DECLARATION) {
            tree = (AST2JSOMTree) mParser.localVariableDeclaration().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.MODIFIER_LIST) {
            tree = (AST2JSOMTree) mParser.modifierList().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.PRIMITIVE_TYPE) {
            tree = (AST2JSOMTree) mParser.primitiveType().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.QUALIFIED_IDENTIFIER) {
            tree = (AST2JSOMTree) mParser.qualifiedIdentifier().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.RETURN_STATEMENT) {
            tree = (AST2JSOMTree) mParser.returnStatement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.STATEMENT) {
            tree = (AST2JSOMTree) mParser.statement().Tree;
            } else if (pCodeFragmentType == CodeFragmentType.STATEMENT_BLOCK) {
//.........这里部分代码省略.........
开发者ID:smartmobili,项目名称:parsing,代码行数:101,代码来源:JSOParser.cs

示例10: EvalExp1Comparison

        // Process comparison operators
        void EvalExp1Comparison(out ParserResult result)
        {
            string comp;
            ParserResult partialResult;

            Eval2Add(out result);
            while ((comp = token) == ">" || comp == "<")
            {
                stack.Add(" comparison : " + comp);
                GetToken();
                Eval2Add(out partialResult);

                if (Debug && result.IsSeries && partialResult.IsSeries)
                {
                    Console.WriteLine("Part A ");
                    partialResult.Series.WriteToConsole();
                    Console.WriteLine("Part B");
                    result.Series.WriteToConsole();
                }
                switch (comp)
                {
                    case ">":
                        result = result.GreaterThan(partialResult);
                        break;
                    case "<":
                        result = result.LessThan(partialResult);
                        break;
                }
                if ((Debug && result.IsSeries && partialResult.IsSeries))
                {
                    Console.WriteLine("Part A " + comp + " Part B ");
                    result.Series.WriteToConsole();
                }
            }

            //Eval2Add(out result);
        }
开发者ID:usbr,项目名称:Pisces,代码行数:38,代码来源:SeriesExpressionParser.cs

示例11: Eval6Parenthesis

 // Process a parenthesized expression.
 void Eval6Parenthesis(out ParserResult result)
 {
     if ((token == "("))
     {
         stack.Add("opening parenthesis ( ");
         GetToken();
         Eval2Add(out result);
         if (token != ")")
             SyntaxErr(Errors.UNBALPARENS);
         GetToken();
     }
     else Atom(out result);
 }
开发者ID:usbr,项目名称:Pisces,代码行数:14,代码来源:SeriesExpressionParser.cs

示例12: Eval5Sign

        // Evaluate a unary + or -.
        void Eval5Sign(out ParserResult result)
        {
            string op;

            op = "";
            if ((tokType == Types.DELIMITER) &&
                token == "+" || token == "-")
            {
                stack.Add(" operator : "+token);
                op = token;
                GetToken();
            }
            Eval6Parenthesis(out result);
            if (op == "-") result = new ParserResult(-1) * result;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:16,代码来源:SeriesExpressionParser.cs

示例13: Eval4Exponent

        // Process an exponent.
        void Eval4Exponent(out ParserResult result)
        {
            ParserResult partialResult;

            Eval5Sign(out result);
            if (token == "^")
            {
                stack.Add(" exponent: ^");
                GetToken();
                Eval4Exponent(out partialResult);
                result = ParserResult.Pow(result, partialResult);
            }
        }
开发者ID:usbr,项目名称:Pisces,代码行数:14,代码来源:SeriesExpressionParser.cs

示例14: OnFileParsed

 void OnFileParsed(string file, ParserResult result)
 {
     OnFileParsed(new[] { file }, result);
 }
开发者ID:ymlai87416,项目名称:CppSharp,代码行数:4,代码来源:Driver.cs

示例15: OnSourceFileParsed

 void OnSourceFileParsed(IList<SourceFile> files, ParserResult result)
 {
     OnFileParsed(files.Select(f => f.Path), result);
 }
开发者ID:ymlai87416,项目名称:CppSharp,代码行数:4,代码来源:Driver.cs


注:本文中的ParserResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。