Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public Stmt(TextLines InLines, StmtTraits InTraits)
        {
            string             stmtText = InLines.ToString();
            StmtWordListCursor csr      = FirstPass_Common(stmtText, InTraits);

            Parse_Common(stmtText, csr, InTraits);
        }
Ejemplo n.º 3
0
        private StmtWordListCursor FirstPass_Common(string InStmtText, StmtTraits InTraits)
        {
            StmtWord           topWord = StmtElem.FirstPass(InStmtText, InTraits);
            StmtWordListCursor csr     = topWord.SubWords.PositionBegin();

            return(csr);
        }
        // If start of function, must scan to close function and the advance to
        // delim that follows the function.

        // Could be standalone function or the function could be member of
        // expression element ( or any other stmt level element. a sentence being most common. )

        // When parent elem is an expression, dont return an expression char delimeted
        // elem as start of new expression.

        // note: no need to be error checking the delimeter at this point.
        // The parent element parsing code will do that. Here we just say that
        // if the delim is expected within the parent elem the elem is standalone.
        // otherwise, the elem is consider a stmt within the stmt.
        static StmtElemForm CalcElemForm(
            delIsMemberEnd InIsMemberEnd,
            Stmt InTopStmt, StmtElem InParent,
            StmtWordListCursor InCsr)
        {
            StmtElemForm sef = StmtElemForm.None;


            // the cursor StmtWord has sub words. that is, it is braced. elem form could be
            // function, could be expression, ...
            if (InCsr.StmtWord.HasSubWords == true)
            {
                // the next word in the string.
                // note: since the word is braced, the next word is the delim only word which
                //       follows the closing brace. ( see StmtElem_FirstPass processing ).
                StmtWordListCursor nxCsr = InCsr.Next();

                sef = CalcElemForm_Actual(InIsMemberEnd, InTopStmt, InParent, InCsr, nxCsr.WordCursor);
            }

            else
            {
                sef = CalcElemForm_Actual(InIsMemberEnd, InTopStmt, InParent, InCsr, InCsr.WordCursor);
            }


            return(sef);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        private void Parse_Common(string InStmtText, StmtWordListCursor InCsr, StmtTraits InTraits)
        {
            StmtWordListCursor csr = null;

            mStmtText   = InStmtText;
            mStmtTraits = InTraits;

            csr = InCsr.Next();
            if (csr == null)
            {
                throw new ApplicationException("stmt is empty");
            }

            // the TopStmt holds a collection of statements.
            mTopElem = new StmtElem(this, StmtElemForm.TopStmt, csr);

            // parse the collection of statements.
            csr = mTopElem.Parse();

#if skip
            StmtElemForm sef = StmtElemForm.None;
            sef      = StmtElem.CalcElemForm(this, null, csr);
            mTopElem = new StmtElem(this, sef, csr);

            if (Stmt.ElemFormHasSubElements(mTopElem.ElemForm) == true)
            {
                csr = mTopElem.Parse();
            }
#endif
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        // parse the member elements of the element.
        // we know the ElemForm and the TopStmt contains the StmtText and StmtTraits.
        // Depending on the ElemForm, advance the WordCursor from word to word in the StmtText
        // and build a StmtElem for each word.
        public StmtWordListCursor Parse()
        {
            StmtWordListCursor csr = null;
            delIsMemberEnd     me  = null;

            csr = Parse(me);
            return(csr);
        }
Ejemplo n.º 10
0
 public StmtElem(Stmt InTopStmt)
 {
     mTopStmt     = InTopStmt;
     mParent      = null;
     mElemForm    = StmtElemForm.None;
     mStartCursor = null;
     mCloseCursor = null;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Construct the Stmt object from the statement string.
        /// </summary>
        /// <param name="InString"></param>
        public Stmt(string InStmtText)
        {
            StmtTraits         traits  = new StmtTraits();
            StmtWord           topWord = StmtElem.FirstPass(InStmtText, traits);
            StmtWordListCursor csr     = topWord.SubWords.PositionBegin( );

            Parse_Common(InStmtText, csr, traits);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Construct the Stmt from string with the cursor position AT the first word
        /// of the statement.
        /// TextTraits are the traits of the first word cursor.
        /// </summary>
        /// <param name="InString"></param>
        /// <param name="InCsr"></param>
        public Stmt(string InStmtText, WordCursor InStartCsr)
        {
            StmtTraits         traits  = new StmtTraits(InStartCsr.TextTraits);
            StmtWord           topWord = StmtElem.FirstPass(InStmtText, InStartCsr, traits);
            StmtWordListCursor wlCsr   = topWord.SubWords.PositionBegin();

            Parse_Common(InStmtText, wlCsr, traits);
        }
Ejemplo n.º 13
0
        // calc the elem form based on the isolated delim of the element.
        // ( see the caller. the isolated delim is either the direct delim of the
        //   word in the string, or is the delim that follows a braced word. )
        static StmtElemForm CalcElemForm_Actual_Sentence(
            delIsMemberEnd InIsMemberEnd,
            Stmt InTopStmt, StmtElem InParent,
            StmtWordListCursor InCsr,
            WordCursor InDelimCursor)
        {
            StmtElemForm sef = StmtElemForm.None;

            if ((InParent != null) && (InParent.IsSentence == true))
            {
                sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
            }
            else
            {
                StmtWordListCursor c2 = null;
                sef = StmtElemForm.Sentence;

                // lookahead in the stmt string. look to see if the sentence ends with
                // a braced section or not.
                c2 = InCsr.PositionBefore(WhichEdge.LeadEdge);
                while (true)
                {
                    c2 = c2.Next();
                    if (c2 == null)
                    {
                        break;
                    }

                    if (c2.StmtWord.HasSubWords == true)
                    {
                        if (InTopStmt.StmtTraits.IsSentenceOpenBraceChar(c2.WordCursor.DelimValue) == true)
                        {
                            sef = StmtElemForm.BracedSentence;
                            break;
                        }

                        c2 = c2.Next();
                    }

                    // word is an assignment symbol. stmt is not a sentence. it is an assignment.
                    if ((InParent != null) && (InParent.ElemForm != StmtElemForm.lhs))
                    {
                        if (c2.WordCursor.DelimIsAssignmentSymbol == true)
                        {
                            sef = StmtElemForm.Assignment;
                            break;
                        }
                    }

                    // last word in the sentence.
                    if (InTopStmt.StmtTraits.IsSentenceDelim(c2.WordCursor.DelimValue) == false)
                    {
                        break;
                    }
                }
            }
            return(sef);
        }
Ejemplo n.º 14
0
        public static StmtElemForm CalcElemForm(
            Stmt InTopStmt, StmtElem InParent,
            StmtWordListCursor InCsr)
        {
            StmtElemForm   sef = StmtElemForm.None;
            delIsMemberEnd me  = null;

            sef = CalcElemForm(me, InTopStmt, InParent, InCsr);
            return(sef);
        }
Ejemplo n.º 15
0
 // method called via delegate to know when sub element parsing should end because
 // delim is an end of member delim.
 bool Parse_Command_IsMemberEnd(StmtWordListCursor InCsr)
 {
     if (InCsr.WordCursor.DelimIsWhitespace == true)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 16
0
 public StmtElem(Stmt InTopStmt, StmtElemForm InForm, StmtWordListCursor InStartCursor)
 {
     if (InForm == StmtElemForm.None)
     {
         throw new ApplicationException("StmtElem form is not set");
     }
     mTopStmt     = InTopStmt;
     mElemForm    = InForm;
     mStartCursor = InStartCursor;
     mCloseCursor = null;
 }
Ejemplo n.º 17
0
        StmtWordListCursor Parse(delIsMemberEnd InIsMemberEnd)
        {
            StmtWordListCursor csr = null;

            switch (mElemForm)
            {
            case StmtElemForm.Function:
                csr = Parse_Function(InIsMemberEnd);
                break;

            case StmtElemForm.Sentence:
                csr = Parse_Sentence(InIsMemberEnd);
                break;

            case StmtElemForm.BracedSentence:
                csr = Parse_Sentence(InIsMemberEnd);
                break;

            case StmtElemForm.BracedContent:
                csr = Parse_BracedContent(InIsMemberEnd);
                break;

            case StmtElemForm.CSV:
                csr = Parse_CSV(InIsMemberEnd);
                break;

            case StmtElemForm.Assignment:
                csr = Parse_Assignment(InIsMemberEnd);
                break;

            case StmtElemForm.ValueExpression:
                csr = Parse_ValueExpression(InIsMemberEnd);
                break;

            case StmtElemForm.Command:
                csr = Parse_Command(InIsMemberEnd);
                break;

            case StmtElemForm.QualifiedSequence:
                csr = Parse_QualifiedSequence(InIsMemberEnd);
                break;

            case StmtElemForm.TopStmt:
                csr = Parse_TopStmt(InIsMemberEnd);
                break;

            default:
                throw new ApplicationException("Parse Stmt failed. StmtForm is unsupported.");
            }
            return(csr);
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
0
 // method called via delegate to know when sub element parsing should end because
 // delim is an end of member delim.
 bool Parse_Function_IsMemberEnd(StmtWordListCursor InCsr)
 {
     if ((InCsr.WordCursor.DelimClass == DelimClassification.DividerSymbol) &&
         (InCsr.WordCursor.DelimValue == ","))
     {
         return(true);
     }
     else if ((InCsr.WordCursor.DelimClass == DelimClassification.DividerSymbol) &&
              (InCsr.WordCursor.DelimValue == TopStmt.StmtTraits.FunctionCloseBraceChar))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
0
        // calc the form of the element without the context of the delim that separates it
        // from the next element, and without consideration of the parent elem.
        private static StmtElemForm CalcElemForm_Standalone(
            Stmt InTopStmt, StmtElem InParent,
            StmtWordListCursor InCsr)
        {
            StmtElemForm form = StmtElemForm.None;
            WordCursor   wc   = InCsr.WordCursor;

            if (wc.IsDelimOnly == true)
            {
                form = StmtElemForm.Empty;
            }
            else if (wc.WordClassification == WordClassification.OpenNamedBraced)
            {
                form = StmtElemForm.Function;
            }
            else if (wc.WordClassification == WordClassification.OpenContentBraced)
            {
                form = StmtElemForm.BracedContent;
            }
            else if (wc.WordClassification == WordClassification.Identifier)
            {
                form = StmtElemForm.Variable;
            }
            else if (wc.WordClassification == WordClassification.Quoted)
            {
                form = StmtElemForm.QuotedLiteral;
            }
            else if (wc.WordClassification == WordClassification.Numeric)
            {
                form = StmtElemForm.NumericLiteral;
            }
            else
            {
                throw new ApplicationException(
                          "Cannot calc StmtElem form of word " +
                          wc.Word.ToString() + " starting at position " +
                          wc.WordBx.ToString());
            }
            return(form);
        }
Ejemplo n.º 24
0
        // parse the sub element, then properly position the StmtWordListCursor to the word
        // which follows the sub element.
        StmtWordListCursor Parse_SubElement(
            StmtWordListCursor InElemCursor, StmtElem InSubElem, delIsMemberEnd InIsMemberEnd)
        {
            StmtWordListCursor csr2       = null;
            StmtWordListCursor elemCursor = InElemCursor;

            csr2 = InSubElem.Parse(InIsMemberEnd);

            // if the sub element just parsed is an expression, the words of the
            // expression were inline ( at the same level ) with the words of this
            // Function element.
            if ((InSubElem.IsExpression == true) ||
                (InSubElem.ElemForm == StmtElemForm.Sentence))
            {
                elemCursor = csr2;
            }

            // an assignment stmt. ( should throw if not delim by stmt end delim. )
            else if (InSubElem.ElemForm == StmtElemForm.Assignment)
            {
                elemCursor = csr2;
            }

            // the sub element is a function. the way the words of the sub function are
            // parsed, the closing brace of the sub function will be the delim of the
            // last element of the sub function.
            // The next word of this owning function ( assuming it is properly formed )
            // will be a delim only word where the delim is either "," or close brace.
            else if ((InSubElem.ElemForm == StmtElemForm.Function) ||
                     (InSubElem.ElemForm == StmtElemForm.BracedSentence) ||
                     (InSubElem.ElemForm == StmtElemForm.BracedContent))
            {
                elemCursor = elemCursor.Next();
            }

            return(elemCursor);
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
        // calc the elem form based on the isolated delim of the element.
        // ( see the caller. the isolated delim is either the direct delim of the
        //   word in the string, or is the delim that follows a braced word. )
        static StmtElemForm CalcElemForm_Actual(
            delIsMemberEnd InIsMemberEnd,
            Stmt InTopStmt, StmtElem InParent,
            StmtWordListCursor InCsr,
            WordCursor InDelimCursor)
        {
            StmtElemForm sef = StmtElemForm.None;

            // how to handle InParent when InParent is ElemForm == StmtElemForm.TopStmt?

            // actual end of text of string.
            if ((InDelimCursor.DelimClass == DelimClassification.EndOfString) ||
                (InTopStmt.StmtTraits.IsEndStmtDelim(InDelimCursor.DelimValue) == true))
            {
                if ((InParent != null) && (InParent.ElemForm != StmtElemForm.TopStmt))
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else if (InTopStmt.StmtTraits.HasSentenceDelimStrings == true)
                {
                    sef = StmtElemForm.Sentence;
                }
                else
                {
                    sef = StmtElemForm.Command;
                }
            }

            // lhs of assignment statement.
            else if (InDelimCursor.DelimIsAssignmentSymbol == true)
            {
                if (InParent == null)
                {
                    sef = StmtElemForm.Assignment;
                }
                else if ((InParent.ElemForm == StmtElemForm.lhs) ||
                         (InParent.ParentElemForm == StmtElemForm.lhs))
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else
                {
                    sef = StmtElemForm.Assignment;
                }
            }

            // a qualified name ( a directory path )
            else if (InDelimCursor.IsPathPart == true)
            {
                if (InParent == null)
                {
                    sef = StmtElemForm.QualifiedSequence;
                }
                else if (InParent.ElemForm == StmtElemForm.QualifiedSequence)
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else
                {
                    sef = StmtElemForm.QualifiedSequence;
                }
            }

            else if ((InDelimCursor.DelimIsPathPart == true) &&
                     (InDelimCursor.WhitespaceFollowsWord == true))
            {
                if (InParent == null)
                {
                    sef = StmtElemForm.Command;
                }
                else if (InParent.ElemForm == StmtElemForm.Command)
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else
                {
                    sef = StmtElemForm.Command;
                }
            }

            // the delim of the StmtWord is an expression symbol. this word is either the
            // start of an expression, or a word within an expression.
            // ( for now, assume is a value expression. if turns out to be boolean, should
            // be able to change the elem form of the expression element. )
            else if (InDelimCursor.DelimIsExpressionSymbol == true)
            {
                if (InParent == null)
                {
                    sef = StmtElemForm.ValueExpression;
                }
                else if (InParent.IsExpression == true)
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else
                {
                    sef = StmtElemForm.ValueExpression;
                }
            }

            // word is part of a space delim command string
            // note: have to set the CommandCapable switch in StmtTraits in order to parse
            //       commands.
            else if ((InTopStmt.StmtTraits.CommandCapable == true) &&
                     (InDelimCursor.DelimIsWhitespace == true))
            {
                if (InParent == null)
                {
                    sef = StmtElemForm.Command;
                }
                else if (InParent.ElemForm == StmtElemForm.Command)
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else
                {
                    sef = StmtElemForm.Command;
                }
            }

            // sentence delimiter.
            else if (InTopStmt.StmtTraits.IsSentenceDelim(InDelimCursor.DelimValue) == true)
            {
                sef = CalcElemForm_Actual_Sentence(
                    InIsMemberEnd, InTopStmt, InParent, InCsr, InDelimCursor);
            }

            // comma seperated values
            else if (InDelimCursor.DelimValue == ",")
            {
                if (InParent == null)
                {
                    sef = StmtElemForm.CSV;
                }
                else if (InParent.CommaIsMemberDelim)
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else if ((InParent.Parent != null) &&
                         (InParent.Parent.CommaIsMemberDelim))
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else
                {
                    sef = StmtElemForm.CSV;
                }
            }

            else if (InTopStmt.StmtTraits.IsFunctionCloseBrace(InDelimCursor.DelimValue) == true)
            {
                if (InParent == null)
                {
                    throw new ApplicationException("unexpected close brace char");
                }
                else if (InParent.ElemForm == StmtElemForm.Function)
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else if ((InParent.ElemForm == StmtElemForm.Sentence) &&
                         (InParent.ParentElemForm == StmtElemForm.Function))
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else
                {
                    throw new ApplicationException("unexpected function close brace char");
                }
            }

            else if (InTopStmt.StmtTraits.IsSentenceCloseBraceChar(InDelimCursor.DelimValue) == true)
            {
                if (InParent == null)
                {
                    throw new ApplicationException("unexpected close brace char");
                }
                else if (InParent.ElemForm == StmtElemForm.Sentence)
                {
                    sef = CalcElemForm_Standalone(InTopStmt, InParent, InCsr);
                }
                else
                {
                    throw new ApplicationException("unexpected function close brace char");
                }
            }

            return(sef);
        }
Ejemplo n.º 27
0
        public StmtWordListCursor PositionBegin()
        {
            StmtWordListCursor csr = new StmtWordListCursor(this, null, AcRelativePosition.Begin);

            return(csr);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Construct Stmt object from statement string and TextTraits
        /// </summary>
        /// <param name="InString"></param>
        /// <param name="InTraits">Traits that govern how the statement
        /// is parsed.</param>
        public Stmt(string InStmtText, StmtTraits InTraits)
        {
            StmtWordListCursor csr = FirstPass_Common(InStmtText, InTraits);

            Parse_Common(InStmtText, csr, InTraits);
        }