예제 #1
0
    public override ParseNode_Base Parse(SyntaxTreeBuilder pSyntaxTreeBuilder)
    {
        foreach (var node in nodes)
        {
            if (node.Matches(pSyntaxTreeBuilder))
            {
                return(node.Parse(pSyntaxTreeBuilder));
            }
        }
        if (FirstSet.ContainsEmpty())
        {
            return(NextAfterChild(this, pSyntaxTreeBuilder));
        }

        pSyntaxTreeBuilder.SyntaxErrorExpected(FirstSet);
        return(this);
    }
    public override ParseNode_Base Parse(SyntaxTreeBuilder pSyntaxTreeBuilder)
    {
        if (!FirstSet.Contains(pSyntaxTreeBuilder.TokenScanner.Current.tokenId))
        {
            pSyntaxTreeBuilder.SyntaxErrorExpected(FirstSet);
            return(this);
        }

        pSyntaxTreeBuilder.SyntaxRule_Cur.AddToken(pSyntaxTreeBuilder.TokenScanner).ParseNode = this;
        pSyntaxTreeBuilder.TokenScanner.MoveNext();
        if (pSyntaxTreeBuilder.ErrorMessage == null)
        {
            pSyntaxTreeBuilder.SyntaxRule_Err = pSyntaxTreeBuilder.SyntaxRule_Cur;
            pSyntaxTreeBuilder.ParseNode_Err  = pSyntaxTreeBuilder.ParseNode_Cur;
        }

        return(parent.NextAfterChild(this, pSyntaxTreeBuilder));
    }
    public override ParseNode_Base Parse(SyntaxTreeBuilder pSyntaxTreeBuilder)
    {
        bool           wasError = pSyntaxTreeBuilder.ErrorMessage != null;
        ParseNode_Base ret      = null;

        if (FirstSet.Contains(pSyntaxTreeBuilder.TokenScanner.Current))
        {
            ret = rhs.Parse(pSyntaxTreeBuilder);
        }
        if ((ret == null || !wasError && pSyntaxTreeBuilder.ErrorMessage != null) && !FirstSet.ContainsEmpty())
        {
            pSyntaxTreeBuilder.SyntaxErrorExpected(FirstSet);
            return(ret ?? this);
        }
        if (ret != null)
        {
            return(ret);
        }
        return(NextAfterChild(rhs, pSyntaxTreeBuilder)); // ready to be reduced
    }