示例#1
0
        // a qualified sequence are consecutive words separated by path delim: aa/bb/cc
        StmtWordListCursor Parse_QualifiedSequence(delIsMemberEnd InIsMemberEnd)
        {
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;
            StmtWordListCursor csr  = this.StartCursor.PositionBefore(WhichEdge.LeadEdge);

            while (true)
            {
                csr = csr.Next();
                if ((csr == null) || (csr.WordCursor.IsEndOfString == true))
                {
                    break;
                }

                sef  = StmtElem.CalcElemForm(InIsMemberEnd, TopStmt, this, csr);
                elem = new StmtElem(TopStmt, sef, csr);
                AddMemberElem(elem);

                if (Stmt.ElemFormHasSubElements(elem.ElemForm) == true)
                {
                    csr = Parse_SubElement(csr, elem, null);
                }

                if (csr.WordCursor.IsPathPart == false)
                {
                    break;
                }
            }
            return(csr);
        }
示例#2
0
        // parse a collection of statements.
        StmtWordListCursor Parse_TopStmt(delIsMemberEnd InIsMemberEnd)
        {
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;
            StmtWordListCursor csr  = this.StartCursor.PositionBefore(WhichEdge.LeadEdge);

            while (true)
            {
                csr = csr.Next();
                if ((csr == null) || (csr.WordCursor.IsEndOfString == true))
                {
                    break;
                }

                sef = StmtElem.CalcElemForm(InIsMemberEnd, TopStmt, this, csr);

                // skip empty words within the collection of stmts.
                if (sef == StmtElemForm.Empty)
                {
                }

                else
                {
//        sef = StmtElem.CalcElemForm(InIsMemberEnd, TopStmt, this, csr);
                    elem = new StmtElem(TopStmt, sef, csr);

                    AddMemberElem(elem);

                    csr = elem.Parse();
                }
            }
            return(csr);
        }
示例#3
0
        // parse the CSV form element.
        // return the WordCursor that terminates the element.
        private StmtWordListCursor Parse_CSV(delIsMemberEnd InIsMemberEnd)
        {
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;
            StmtWordListCursor csr  = this.StartCursor.PositionBefore(WhichEdge.LeadEdge);

            while (true)
            {
                csr = csr.Next();
                if ((csr == null) || (csr.WordCursor.IsEndOfString == true))
                {
                    break;
                }

                sef  = StmtElem.CalcElemForm(InIsMemberEnd, TopStmt, this, csr);
                elem = new StmtElem(TopStmt, sef, csr);
                AddMemberElem(elem);

                if (Stmt.ElemFormHasSubElements(elem.ElemForm) == true)
                {
                    csr = elem.Parse();
                }

                // the CSV stmt ends when an element is not comma delimeted.
                if (csr.WordCursor.DelimClass != DelimClassification.DividerSymbol)
                {
                    break;
                }
                if (csr.WordCursor.DelimValue != ",")
                {
                    break;
                }
            }
            return(csr);
        }
示例#4
0
        // parse the Command form element.
        // return the WordCursor that terminates the element.
        StmtWordListCursor Parse_Command(delIsMemberEnd InIsMemberEnd)
        {
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;
            StmtWordListCursor csr  = this.StartCursor.PositionAfter(WhichEdge.LeadEdge);

            while (true)
            {
                csr = csr.Next();
                if ((csr == null) || (csr.WordCursor.IsEndOfString == true))
                {
                    break;
                }

                sef  = StmtElem.CalcElemForm(InIsMemberEnd, TopStmt, this, csr);
                elem = new StmtElem(TopStmt, sef, csr);
                AddMemberElem(elem);

                if (Stmt.ElemFormHasSubElements(elem.ElemForm) == true)
                {
                    csr = elem.Parse(Parse_Command_IsMemberEnd);
                }

                // the command stmt ends when an element is not space delimeted.
                if (csr.WordCursor.DelimClass != DelimClassification.Whitespace)
                {
                    break;
                }
            }
            return(csr);
        }
示例#5
0
        StmtWordListCursor Parse_Assignment(delIsMemberEnd InIsMemberEnd)
        {
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;
            StmtWordListCursor csr  = this.StartCursor.PositionBefore(WhichEdge.LeadEdge);

            // first word is the lhs of the assignment stmt.
            csr = csr.Next();

            StmtElem lhsElem = new StmtElem(TopStmt, StmtElemForm.lhs, csr);

            AddMemberElem(lhsElem);

            // parse the lhs word
            sef  = StmtElem.CalcElemForm(null, TopStmt, lhsElem, csr);
            elem = new StmtElem(TopStmt, sef, csr);
            lhsElem.AddMemberElem(elem);
            if (Stmt.ElemFormHasSubElements(sef) == true)
            {
                csr = elem.Parse();
            }

            // right hand side.
            csr = csr.Next();
            if ((csr == null) || (csr.WordCursor.IsEndOfString == true))
            {
                throw new ApplicationException("assignment stmt missing right hand side");
            }
            StmtElem rhsElem = new StmtElem(TopStmt, StmtElemForm.rhs, csr);

            AddMemberElem(rhsElem);

            sef  = StmtElem.CalcElemForm(InIsMemberEnd, TopStmt, rhsElem, csr);
            elem = new StmtElem(TopStmt, sef, csr);
            rhsElem.AddMemberElem(elem);
            if (Stmt.ElemFormHasSubElements(sef) == true)
            {
                StmtWordListCursor csr2 = null;
                csr2 = elem.Parse();
                if (elem.ElemForm == StmtElemForm.Function)
                {
                    csr = csr.Next();
                }
                else
                {
                    csr = csr2;
                }
            }
            return(csr);
        }
示例#6
0
        StmtWordListCursor Parse_ValueExpression(delIsMemberEnd InIsMemberEnd)
        {
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;
            StmtWordListCursor csr  = this.StartCursor.PositionBefore(WhichEdge.LeadEdge);

            // parse the expression until delim that is not an expression symbol
            while (true)
            {
                csr = csr.Next();
                if ((csr == null) || (csr.WordCursor.IsEndOfString == true))
                {
                    break;
                }

                sef  = StmtElem.CalcElemForm(InIsMemberEnd, TopStmt, this, csr);
                elem = new StmtElem(TopStmt, sef, csr);
                AddMemberElem(elem);

                if (Stmt.ElemFormHasSubElements(elem.ElemForm) == true)
                {
                    elem.Parse();
                    csr = csr.Next();
                    if (csr == null)
                    {
                        break;
                    }
                }

                // add the expression string as a operator element of the expression parent.
                if (csr.WordCursor.DelimIsExpressionSymbol == true)
                {
                    elem = new StmtElem(TopStmt, StmtElemForm.ExpressionOperator, csr);
                    AddMemberElem(elem);
                }
                else
                {
                    break;
                }
            }

            return(csr);
        }
示例#7
0
        // parse the function form element.
        // return the WordCursor that terminates the element.
        StmtWordListCursor Parse_Function(delIsMemberEnd InIsMemberEnd)
        {
            StmtWordListCursor csr  = null;
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;

            csr = StartCursor.StmtWord.SubWords.PositionBegin();
            while (true)
            {
                csr = csr.Next();
                if (csr == null)
                {
                    break;
                }

                // new line between function arguments. is ok. treat as whitespace.
                else if ((csr.WordCursor.IsDelimOnly == true) &&
                         (csr.WordCursor.DelimClass == DelimClassification.NewLine))
                {
                }

                // is the closing brace delim of a function with no args.
                else if (csr.WordCursor.IsDelimOnly == true)
                {
                }

                // function arg sub element.
                else
                {
                    sef  = StmtElem.CalcElemForm(Parse_Function_IsMemberEnd, TopStmt, this, csr);
                    elem = new StmtElem(TopStmt, sef, csr);
                    AddMemberElem(elem);

                    if (Stmt.ElemFormHasSubElements(sef) == true)
                    {
                        csr = Parse_SubElement(csr, elem, Parse_Function_IsMemberEnd);
                    }
                }

                CloseCursor = csr;
            }
            return(csr);
        }
示例#8
0
        StmtWordListCursor Parse_Sentence(delIsMemberEnd InIsMemberEnd)
        {
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;
            StmtWordListCursor csr  = this.StartCursor.PositionBefore(WhichEdge.LeadEdge);

            while (true)
            {
                csr = csr.Next();
                if ((csr == null) || (csr.WordCursor.IsEndOfString == true))
                {
                    break;
                }

                sef = StmtElem.CalcElemForm(InIsMemberEnd, TopStmt, this, csr);

                // skip empty words within a sentence ( a newline char sequence )
                if (sef == StmtElemForm.Empty)
                {
                }

                else
                {
                    elem = new StmtElem(TopStmt, sef, csr);
                    AddMemberElem(elem);

                    if (Stmt.ElemFormHasSubElements(elem.ElemForm) == true)
                    {
                        csr = Parse_SubElement(csr, elem, null);
                    }
                }

                // the sentence ends when the delim after the sentence member elem is
                // not a sentence delim.
                if (TopStmt.StmtTraits.IsSentenceDelim(csr.WordCursor.DelimValue) == false)
                {
                    break;
                }
            }
            return(csr);
        }
示例#9
0
        // braced content consists of a list of statements.
        // examples of braced on content:
        //    string func( arg InFac1 ) { int xx = 5 ; return xx.ToString( ) ; } // two stmts.
        //    char[] nwc = new char[] { 'a', 'b', 'c' } ; //  one stmt.
        StmtWordListCursor Parse_BracedContent(delIsMemberEnd InIsMemberEnd)
        {
            StmtWordListCursor csr  = null;
            StmtElem           elem = null;
            StmtElemForm       sef  = StmtElemForm.None;

            csr = StartCursor.StmtWord.SubWords.PositionBegin();
            while (true)
            {
                csr = csr.Next();
                if (csr == null)
                {
                    break;
                }

                // is the closing brace delim of a function with no args.
                else if (csr.WordCursor.IsDelimOnly == true)
                {
                }

                // function arg sub element.
                else
                {
                    sef  = StmtElem.CalcElemForm(Parse_Function_IsMemberEnd, TopStmt, this, csr);
                    elem = new StmtElem(TopStmt, sef, csr);
                    AddMemberElem(elem);

                    if (Stmt.ElemFormHasSubElements(sef) == true)
                    {
                        csr = Parse_SubElement(csr, elem, Parse_Function_IsMemberEnd);
                    }
                }

                CloseCursor = csr;
            }
            return(csr);
        }