Exemple #1
0
        private List<SToken> ExplodeStoken(SToken sToken, SToken token, string form)
        {
            List<SToken> tokens = new List<SToken>();
            //foreach (string form in forms)
            {
                string text = sToken.TokenString;
                string textBefore = string.Empty;
                string textAfter = string.Empty;

                if (text.Contains(form))
                {
                    textBefore = " "+text.Substring(0, text.IndexOf(form)).Trim()+" ";
                    textAfter = " "+text.Substring(text.IndexOf(form) + form.Length).Trim()+" ";
                }

               // while (text.Contains(form))
                {
                    SToken tokenInside = new SToken();
                    tokenInside.Configure(token.TokenId, token.TokenString, token.TokenType, token.TokenCode);
                    tokenInside.Link(SToken.NULL, SToken.NULL, null, null);
                    SToken tokenBefore = new SToken();
                    tokenBefore.Configure(sToken.TokenId, textBefore, sToken.TokenType,  sToken.TokenCode);
                    tokenBefore.Link(sToken.TokenBefore, tokenInside, null, null);
                    SToken tokenAfter = new SToken();
                    tokenAfter.Configure(sToken.TokenId, textAfter, sToken.TokenType, sToken.TokenCode);
                    //*** tokenAfter.Link(tokenInside, sToken.TokenAfter, null, null);
                    tokenInside.TokenBefore = tokenBefore;
                    if (sToken.TokenBefore != null)
                    {
                       //***  sToken.TokenBefore.TokenAfter = tokenBefore;
                    }
                    //*** if (sToken.TokenAfter != null)
                    {
                        //*** sToken.TokenAfter.TokenBefore = tokenAfter;
                    }
                    //*** tokenInside.TokenAfter = tokenAfter;
                    
                    tokens.Add(tokenBefore);
                    tokens.Add(tokenInside);
                    tokens.Add(tokenAfter);
                }
            }
            return tokens;
        }
Exemple #2
0
        public EDocument(string documentText)
        {
            DocumentText = documentText;
            RootTocken = new SToken();
            SToken newTocken = new SToken();

            RootTocken.Configure(0, string.Empty + "Program", SElementType.Undefined, string.Empty + " * ");
            newTocken.Configure(0, string.Empty + "..", SElementType.Undefined, string.Empty);
            RootTocken.TokenNodeType = SElementType.Undefined;
            newTocken.TokenNodeType = SElementType.Undefined;

            RootTocken.Link(SToken.NULL, SToken.NULL, null, null);
            newTocken.Link(rootTocken, SToken.NULL, null, null);

            RootTocken.TokenChilds.Add(newTocken);
            parentToken = RootTocken;
            currentToken = RootTocken.TokenChilds[0];

            InitializePersons();            
        }
Exemple #3
0
        private List<SToken> ExplodeStoken(SToken sToken, SToken token, string form)
        {
            List<SToken> tokens = new List<SToken>();
            //foreach (string form in forms)
            {
                string text = sToken.TokenString;
                string textBefore = string.Empty;
                string textAfter = string.Empty;

                if (text.Contains(form))
                {
                    textBefore = " "+text.Substring(0, text.IndexOf(form)).Trim()+" ";
                    textAfter = " "+text.Substring(text.IndexOf(form) + form.Length).Trim()+" ";
                }

               // while (text.Contains(form))
                {
                    SToken tokenInside = new SToken();
                    SToken tokenBefore = new SToken();
                    SToken tokenAfter = new SToken();
                    tokenInside.Configure(token.TokenId, token.TokenString, token.TokenType, token.TokenCode);
                    tokenInside.Link(sToken.TokenParent, tokenBefore, tokenAfter, sToken.TokenChilds);
                    tokenInside.TokenMultiplicity = sToken.TokenMultiplicity;
                    tokenInside.TokenMultiplicityLevel = sToken.TokenMultiplicityLevel;
                    tokenBefore.Configure(sToken.TokenId, textBefore, sToken.TokenType, sToken.TokenCode);
                    tokenBefore.Link(sToken.TokenParent, sToken.TokenBefore, tokenInside, token.TokenChilds);
                    tokenAfter.Configure(sToken.TokenId, textAfter, sToken.TokenType, sToken.TokenCode);
                    //*** tokenAfter.Link(sToken.TokenParent, tokenInside, sToken.TokenAfter, token.TokenChilds);

                   //***  tokenInside.TokenAfter = tokenAfter;

                    if (string.IsNullOrEmpty(tokenBefore.TokenString.Trim()))
                    {
                        tokenInside.TokenBefore = tokenBefore.TokenBefore;
                    }
                    if (string.IsNullOrEmpty(tokenAfter.TokenString.Trim()))
                    {
                        //*** tokenInside.TokenAfter = tokenAfter.TokenAfter;
                    }

                    if (sToken.TokenMultiplicity != SElementMultiplicity.Undefined)
                    {
                        tokenInside.TokenMultiplicity = sToken.TokenMultiplicity;
                        tokenBefore.TokenMultiplicity = sToken.TokenMultiplicity;
                        tokenInside.TokenMultiplicity = sToken.TokenMultiplicity;
                    }
                    else
                    {
                        tokenInside.TokenMultiplicity = token.TokenMultiplicity;
                        tokenBefore.TokenMultiplicity = token.TokenMultiplicity;
                        tokenInside.TokenMultiplicity = token.TokenMultiplicity;
                    }
                    tokenAfter.TokenBefore = tokenBefore;
                    if (sToken.TokenBefore != null)
                    {
                        //*** sToken.TokenBefore.TokenAfter = tokenBefore;
                    }
                    //*** if (sToken.TokenAfter != null)
                    {
                        //*** sToken.TokenAfter.TokenBefore = tokenAfter;
                    }
                    
                    if (!string.IsNullOrEmpty(tokenBefore.TokenString.Trim()))
                    {
                        tokens.Add(tokenBefore);
                    } 
                    tokens.Add(tokenInside);
                    if (!string.IsNullOrEmpty(tokenAfter.TokenString.Trim()))
                    {
                        tokens.Add(tokenAfter);
                    }
                }
            }
            return tokens;
        }
Exemple #4
0
 /// <summary>
 /// Create a collection of tokens from the input string
 /// </summary>
 /// <returns></returns>
 public List<SToken> TokenizeInput(string tokenizableString)
 {
     List<SToken> tokenizedInput = new List<SToken>();
     SToken newToken = new SToken();
     newToken.Configure(0, string.Empty, SElementType.Undefined, tokenizableString);
     newToken.Link(SToken.NULL, SToken.NULL, null, null);
     tokenizedInput.Add(newToken);
     return tokenizedInput;
 }
Exemple #5
0
 public bool AdoptSymbol(int symbolId, string symbolText, List<string> forms, string code, SElementMultiplicity multiplicity)
 {
     bool simbolFound = false;
     SToken token = new SToken();
     if (currentToken.TokenBefore != null)
     {
         token = currentToken;
     }
     token.Configure(symbolId, symbolText, SElementType.Symbol, "[" + symbolId + ":0]");
     token.Link(currentToken.TokenParent, currentToken, null, null);
     if (currentToken.TokenBefore != null)
     {
         token.TokenBefore = currentToken.TokenBefore;
     }
     if (token.TokenMultiplicity == SElementMultiplicity.Undefined)
     token.TokenMultiplicity = multiplicity;
     StringBuilder tokenCollectionAsString = new StringBuilder();
     SToken localCurrentToken = currentToken;
     while (localCurrentToken != null)
     {
         for (int i = 0; i < forms.Count; i++)
         {
             if (localCurrentToken.TokenType == SElementType.Undefined)
             {
                 if (localCurrentToken.TokenString.Contains(forms[i]))
                 {
                     List<SToken> explodedToken = ExplodeStoken(localCurrentToken, token, forms[i]);
                     // Try child
                     int ii = localCurrentToken.TokenParent.TokenChilds.IndexOf(localCurrentToken);
                     if (ii > -1)
                     {
                         localCurrentToken.TokenParent.TokenChilds.Insert(localCurrentToken.TokenParent.TokenChilds.IndexOf(localCurrentToken), explodedToken[0]);
                         localCurrentToken.TokenParent.TokenChilds.Remove(localCurrentToken);
                         i = 0;
                         //if (explodedToken[explodedToken.Count - 1]!=null)
                         localCurrentToken = explodedToken[explodedToken.Count - 1];
                         simbolFound = true;
                     }
                     // Try properties
                     if (currentToken.TokenDescribed != null)
                     {
                         ii = localCurrentToken.TokenDescribed.TokenProperties.IndexOf(localCurrentToken);
                         if (ii > -1)
                         {
                             localCurrentToken.TokenDescribed.TokenProperties.Insert(localCurrentToken.TokenDescribed.TokenProperties.IndexOf(localCurrentToken), explodedToken[0]);
                             localCurrentToken.TokenDescribed.TokenProperties.Remove(localCurrentToken);
                             i = 0;
                             //if (explodedToken[explodedToken.Count - 1]!=null)
                             localCurrentToken = explodedToken[explodedToken.Count - 1];
                             simbolFound = true;
                         }
                     }
                 }
             }
         }
         localCurrentToken = GetNext(localCurrentToken);
     }
     return simbolFound;
 }
Exemple #6
0
 public void AdoptLogic(int logicId, string logicText, List<string> forms, string code)
 {
     SToken token = new SToken();
     token.Configure(logicId, code, SElementType.Logic, logicText);
     token.Link(SToken.NULL, SToken.NULL, null, null);
     StringBuilder tokenCollectionAsString = new StringBuilder();
     SToken localCurrentToken = currentToken;
     while (localCurrentToken != null)
     {
         for (int i = 0; i < forms.Count; i++)
         {
             if (localCurrentToken.TokenType == SElementType.Undefined)
             {
                 if (localCurrentToken.TokenString.Contains(forms[i]))
                 {
                     List<SToken> explodedToken = ExplodeStoken(localCurrentToken, token, forms[i]);
                     tokenCollection.AddRange(explodedToken);
                     tokenCollection.Remove(localCurrentToken);
                     i = 0;
                     localCurrentToken = explodedToken[explodedToken.Count - 1];
                 }
             }
         }
         //*** localCurrentToken = localCurrentToken.TokenAfter;
     }
 }
Exemple #7
0
        private SToken FoldBelowWithPrewious(string c, SElementType[] conditionType)
        {
            // Fold Needed ?
            bool foldNeeded = true;
            if (currentToken.TokenBefore != null) // if there is nothing before fold
            {
                if (conditionType.Contains(currentToken.TokenBefore.TokenType)) // if there is another terminated fold before then fold
                {
                    //foldNeeded = false;
                }
                if (currentToken.TokenBefore.TokenType == SElementType.Collection && c == "and") // Fold needed ?
                {
                    foldNeeded = false;
                }
                if (true)
                {

                }
            }

            // Fold Location ?
            SToken firstToFold = currentToken;
            if (foldNeeded)
            {
                if (currentToken.TokenNodeType == SElementType.FoldClose && currentToken.TokenBefore.TokenNodeType != SElementType.CollectionAnd)
                {
                    while (firstToFold.TokenBefore != null && firstToFold.TokenNodeType != SElementType.FoldOpen)
                    {
                        firstToFold = firstToFold.TokenBefore;
                    }
                }


                // Insert Folding Markers
                SToken bracketOpenToken = new SToken();
                bracketOpenToken.Configure(0, "(", SElementType.Collection, "");
                bracketOpenToken.TokenNodeType = SElementType.FoldOpen; 
                bracketOpenToken.TokenMultiplicity = currentToken.TokenMultiplicity;
                SToken bracketCloseToken = new SToken();
                bracketCloseToken.Configure(0, ")", SElementType.Collection, "");
                bracketCloseToken.TokenNodeType = SElementType.FoldClose;
                bracketOpenToken.Link(firstToFold.TokenParent, firstToFold.TokenBefore, bracketCloseToken, new List<SToken>() { firstToFold });
                if (bracketOpenToken.TokenBefore != null)
                {
                    //*** bracketOpenToken.TokenBefore.TokenAfter = bracketOpenToken;
                }
                SToken localToken = firstToFold;
                while (localToken != null)
                {
                    localToken.TokenParent = bracketOpenToken;
                    //*** localToken = localToken.TokenAfter;
                }
                bracketCloseToken.Link(firstToFold.TokenParent, bracketOpenToken, null, null);
                // If bracketOpenToken is the first in clilds replace the lider
                if (bracketOpenToken.TokenBefore == null)
                {
                    bracketOpenToken.TokenParent.TokenChilds.Remove(firstToFold);
                    bracketOpenToken.TokenParent.TokenChilds.Add(bracketOpenToken);
                }
                // Fold element
                //*** firstToFold.Link(bracketOpenToken, null, firstToFold.TokenAfter, firstToFold.TokenChilds);

            }
            else
            {
                SToken localToken = null;
                if (currentToken.TokenParent.TokenChilds.Count > 0)
                {
                    localToken = currentToken.TokenParent.TokenChilds[0];
                    //*** while (localToken.TokenAfter != null)
                    {
                        //*** localToken = localToken.TokenAfter;
                    }
                }
                currentToken = localToken;
               // localToken.TokenAfter = new SToken(0, "", SElementType.Undefined, "");
               // currentToken.TokenBefore.TokenAfter = currentToken.TokenAfter;
               // currentToken.TokenBefore = localToken;
               // currentToken.TokenParent = localToken.TokenParent;
               // currentToken.TokenBefore.TokenAfter = currentToken;
            }
            // Right
            //sticked = true; // keep next token into array 
            return currentToken;
        }
Exemple #8
0
 public void AdoptOperator(int operatorId, string operatorText, List<string> forms, string code)
 {
     SToken token = new SToken();
     token.Configure(operatorId, string.Empty, SElementType.Operator, operatorText);
     token.Link(SToken.NULL, SToken.NULL, null, null);
     StringBuilder tokenCollectionAsString = new StringBuilder();
     SToken localCurrentToken = currentToken;
     while (localCurrentToken != null)
     {
         for (int i = 0; i < forms.Count; i++)
         {
             if (localCurrentToken.TokenType == SElementType.Undefined)
             {
                 if (localCurrentToken.TokenString.Contains(forms[i]))
                 {
                     List<SToken> explodedToken = ExplodeStoken(localCurrentToken, token, forms[i]);
                     currentToken.TokenParent.TokenChilds.InsertRange(currentToken.TokenParent.TokenChilds.IndexOf(localCurrentToken), explodedToken);
                     currentToken.TokenParent.TokenChilds.Remove(localCurrentToken);
                     i = 0;
                     localCurrentToken = explodedToken[explodedToken.Count - 1];
                 }
             }
         }
         //*** localCurrentToken = localCurrentToken.TokenAfter;
     }
 }
Exemple #9
0
        void FoldToken(string c)
        {
            bool foldNeeded = true;
            SElementType[] conditionType = new SElementType[] { SElementType.CollectionAnd, SElementType.CollectionOr };
            if (currentToken.TokenBefore != null) // if there is nothing before fold
            {
                if (conditionType.Contains(currentToken.TokenBefore.TokenType)) // if there is another terminated fold before then fold
                {
                    //foldNeeded = false;
                }
                if (currentToken.TokenBefore.TokenType == SElementType.Collection && currentToken.TokenString == "and") // Fold needed ?
                {
                    foldNeeded = false;
                }
                if (currentToken.TokenParent.TokenNodeType == SElementType.FoldOpen)
                {
                    foldNeeded = false;
                }
            }
            if (foldNeeded)
            {
                SToken firstToFold = currentToken;
                if (currentToken.TokenBefore != null)
                {
                    if (currentToken.TokenBefore.TokenBefore != null && currentToken.TokenBefore.TokenNodeType == SElementType.FoldClose && currentToken.TokenBefore.TokenBefore.TokenNodeType != SElementType.CollectionAnd)
                    {
                        while (firstToFold.TokenBefore != null && firstToFold.TokenNodeType != SElementType.FoldOpen)
                        {
                            firstToFold = firstToFold.TokenBefore;
                        }
                    }
                    else
                    {
                        firstToFold = currentToken.TokenBefore;
                    }
                }
                // Insert Folding Markers
                SToken bracketOpenToken = new SToken();
                SToken bracketCloseToken = new SToken();

                bracketOpenToken.Configure(0, "(", SElementType.Collection, "");
                bracketCloseToken.Configure(0, ")", SElementType.Collection, "");

                bracketOpenToken.TokenNodeType = SElementType.FoldOpen;
                bracketCloseToken.TokenNodeType = SElementType.FoldClose;

                if (currentToken.TokenBefore != null)
                {
                    bracketOpenToken.TokenMultiplicity = currentToken.TokenBefore.TokenMultiplicity;
                }


                bracketOpenToken.Link(firstToFold.TokenParent, firstToFold.TokenBefore, bracketCloseToken, new List<SToken>() { firstToFold });
                bracketCloseToken.Link(firstToFold.TokenParent, bracketOpenToken, null, null);
                firstToFold.Link(bracketOpenToken, null, null, firstToFold.TokenChilds);

                if (bracketOpenToken.TokenBefore != null)
                {
                   bracketOpenToken.TokenBefore.TokenAfter[0] = bracketOpenToken;
                }
                SToken localToken = firstToFold;
                while (localToken != null && localToken.TokenAfter != null)
                {
                    localToken.TokenParent = bracketOpenToken;
                    localToken = localToken.TokenAfter[0];
                }
                // If bracketOpenToken is the first in clilds replace the lider
                if (bracketOpenToken.TokenBefore == null)
                {
                    bracketOpenToken.TokenParent.TokenChilds.Remove(firstToFold);
                    bracketOpenToken.TokenParent.TokenChilds.Add(bracketOpenToken);
                }
            //currentToken = bracketCloseToken;
            }

            switch (c)
            {
                case "and":
                    currentToken.TokenParent.TokenType = SElementType.CollectionAnd;
                    currentToken.TokenParent.TokenString = "( && ";
                    break;
                case "or":
                    currentToken.TokenParent.TokenType = SElementType.CollectionOr;
                    currentToken.TokenParent.TokenString = "( || ";
                    break;
            }
            
            if (currentToken.TokenParent.TokenNodeType != SElementType.FoldOpen)
            {
                //currentToken = currentToken.TokenParent;
            }
            else
            {
                //AppendToken();
            }
            
            
        }
Exemple #10
0
        private bool SubstituteSymbols(SToken localCurrentToken)
        {
            try
            {
                bool simbolFound = false;
                //SToken localCurrentToken = currentToken;
                //while (localCurrentToken.TokenBefore != null && localCurrentToken.TokenBefore.TokenType == SElementType.Undefined)
                {
                }
                while (localCurrentToken != null)
                {
                    int offset = 0;
                    if (localCurrentToken.TokenType == SElementType.Undefined)
                        while (!NothingMoreToreplace(localCurrentToken, offset))
                        {
                            string candidate = GetFirstCandidateToReplace(localCurrentToken, offset);
                            candidate = candidate.Trim();
                            offset += candidate.Length;
                            while (!string.IsNullOrEmpty(candidate))
                            {
                                bool found = false;
                                string partialCandidate = candidate;
                                while (!found)
                                {
                                    SObjectCollection objectCollection = new SObjectCollection();
                                    objectCollection.AddByName(singularize(partialCandidate), 0); // logics.getSymbsBySubstring(partialCandidate, 0, 100);
                                    if (objectCollection.SObject.Count < 1)
                                    {
                                        if (partialCandidate.LastIndexOf(' ') > -1)
                                        {
                                            partialCandidate = partialCandidate.Substring(0, partialCandidate.LastIndexOf(' '));
                                        }
                                        else
                                        {
                                            candidate = candidate.Substring(partialCandidate.Length).Trim();//
                                            /*for (int i = 0; i < candidate.Length; i++)
                                            {
                                                if (char.IsWhiteSpace(candidate[i]))
                                                {
                                                    ReplaceAt++;
                                                }
                                                else
                                                {
                                                    candidate = candidate.Substring(i);
                                                    return;
                                                }
                                            }*/
                                            //string substitute = "[0:0]";
                                            /***>> if (Symbol.CreateUnknown && (char.IsWhiteSpace(SubsritutedQuery[SubsritutedQuery.Length - 1]) || (SubsritutedQuery[SubsritutedQuery.Length - 1] == '!')))
                                            {
                                                Symbol symbol = new Symbol(partialCandidate, true);
                                                substitute = "[" + symbol.SymbolID[0] + ":" + symbol.SymbolID[1] + "]";
                                            } <<***/

                                            //SubsritutedQuery = SubsritutedQuery.Substring(0, ReplaceAt) + substitute + SubsritutedQuery.Substring(ReplaceAt + partialCandidate.Length);
                                            //ReplaceAt = ReplaceAt + substitute.Length + 1; // because i have a spave after substitude
                                            found = true;
                                        }
                                    }
                                    else
                                    {
                                        bool needReplaceAtPluse = false;
                                        string substitute = "";
                                        foreach (SymbolID symbol in objectCollection.SObject)
                                        {
                                            substitute = symbol.ToString();
                                            simbolFound = AdoptSymbol(symbol.Location.A, symbol.Names[0], new List<string>() { partialCandidate }, "[" + symbol.Location.A + ":0]", pluralize(symbol.Names[0]).Equals(partialCandidate) ? SElementMultiplicity.All : SElementMultiplicity.One);

                                            currentToken = currentToken.TokenParent.TokenChilds[0];
                                            //*** while (currentToken.TokenAfter != null)
                                            {
                                                //*** currentToken = currentToken.TokenAfter;
                                            }
                                            //currentToken.TokenParent.TokenChilds
                                            //currentToken.TokenType = localCurrentToken.TokenType;
                                            //currentToken.TokenNodeType = localCurrentToken.TokenNodeType;
                                            //currentToken.TokenMultiplicity = localCurrentToken.TokenMultiplicity;
                                            //currentToken = currentToken.TokenParent.TokenChilds[0];
                                            //*** if (currentToken.TokenAfter != null)
                                            {
                                                //*** currentToken.TokenAfter.TokenBefore = currentToken;
                                            }
                                            //offset = 0;
                                        }
                                        if (partialCandidate.Length < candidate.Length)
                                        {
                                            candidate = candidate.Substring(partialCandidate.Length + 1); // this is not possible if we are at the end of candidate
                                            needReplaceAtPluse = true;
                                        }
                                        else
                                        {
                                            candidate = string.Empty;
                                        }
                                        if (needReplaceAtPluse)
                                        {
                                            //ReplaceAt++;
                                        }
                                        found = true;
                                    }
                                }
                            }
                        }
                    localCurrentToken = GetNext(localCurrentToken);
                }
                if (simbolFound && false)
                {
                    SToken newToken = new SToken();
                    newToken.Configure(0, "", SElementType.Undefined, "");
                    newToken.Link(currentToken.TokenParent, currentToken, null, null);
                    //*** currentToken.TokenAfter = newToken;
                    currentToken = newToken;
                }
                return simbolFound;
            }
            catch (Exception ss)
            {
            }
            return false;
        }
Exemple #11
0
 void AppendTokenDown()
 {
     SToken newToken = new SToken();
     newToken.Configure(0, "append", SElementType.Undefined, "");
     newToken.Link(currentToken.TokenParent, currentToken, null, null);
     //*** currentToken.TokenAfter = newToken;
     //*** currentToken = currentToken.TokenAfter;
 }
Exemple #12
0
        private SToken AppendToken(string tokenText, string c)
        {
            //ParseDocument();
            if (!sticked)
            {
                if (currentToken.TokenParent.TokenNodeType == SElementType.FoldOpen || currentToken.TokenParent.TokenType == SElementType.CollectionAnd || currentToken.TokenParent.TokenType == SElementType.CollectionOr)
                {
                    //*** currentToken.TokenBefore.TokenAfter = currentToken.TokenAfter; // link
                    //*** currentToken.TokenBefore = currentToken.TokenParent.TokenAfter;
                    //*** currentToken.TokenParent.TokenAfter.TokenAfter = currentToken;
                    currentToken.TokenParent = currentToken.TokenParent.TokenParent;
                }
                else
                {
                    SToken newToken = new SToken();
                    newToken.Configure(0, "", SElementType.Undefined, "");
                    newToken.Link(currentToken.TokenParent, currentToken, null, null);
                    // if the multilplicity is not defined get the colection multiplicity
                    if (currentToken.TokenMultiplicity == SElementMultiplicity.Undefined)
                    {
                        newToken.TokenMultiplicity = currentToken.TokenParent.TokenMultiplicity;
                    }
                    //currentToken = newToken;
                    currentToken.TokenString = c;
                    //*** currentToken.TokenAfter = newToken;
                    //*** currentToken = currentToken.TokenAfter;
                }
            }
            else
            {
                currentToken.TokenString = c;

                //currentToken = newToken;
            }
            sticked = false;
            return currentToken;
        }
Exemple #13
0
 private void AddBlock(string tokenText, string c)
 {
     currentToken.TokenString = tokenText + c;
     SToken aToken = new SToken();
     aToken.Configure(0, string.Empty, SElementType.Undefined, "");
     aToken.Link(SToken.NULL, SToken.NULL, parentToken, new List<SToken>());
     parentToken.TokenChilds.Add(aToken);
     currentToken = aToken;
 }
Exemple #14
0
 private void AddToCollection(string tokenText, string c)
 {
     currentToken.TokenString = tokenText;
     if (!sticked && currentToken.TokenParent.TokenNodeType == SElementType.FoldOpen)
     {
         //*** currentToken = currentToken.TokenParent.TokenAfter;
     }
     currentToken = FoldBelowWithPrewious(c, new SElementType[] { SElementType.CollectionAnd, SElementType.CollectionOr });
     if (currentToken.TokenParent.TokenType == SElementType.Collection)
     {
         //string c = "";
         switch (c)
         {
             case "and":
                 currentToken.TokenParent.TokenType = SElementType.CollectionAnd;
                 currentToken.TokenParent.TokenString = "( && ";
                 break;
             case "or":
                 currentToken.TokenParent.TokenType = SElementType.CollectionOr;
                 currentToken.TokenParent.TokenString = "( || ";
                 break;
         }
     }
     SToken newTocken = new SToken();
     newTocken.Configure(0, string.Empty, SElementType.Undefined, string.Empty);
     newTocken.Link(currentToken.TokenParent, currentToken, SToken.NULL, new List<SToken>());
     //currentToken.TokenMultiplicity = currentToken.TokenParent.TokenMultiplicity;
     //*** currentToken.TokenAfter = newTocken;
     currentToken = newTocken;
     //if (currentToken.TokenParent.TokenType == SElementType.Collection)
     sticked = true;
 }
Exemple #15
0
        private void CreateNewCollection()
        {
            sticked = true;

            //Prepare Brackets

            SToken nextToken = CurrentToken;
            CurrentToken = CurrentToken.TokenBefore;
            CurrentToken.TokenAfter = null;
            
            SToken bracketOpenToken = new SToken();
            SToken bracketCloseToken = new SToken();

            bracketOpenToken.Configure(0, "(", SElementType.Collection, "");
            bracketCloseToken.Configure(0, ")", SElementType.Collection, "");

            bracketOpenToken.TokenNodeType = SElementType.FoldOpen;
            bracketCloseToken.TokenNodeType = SElementType.FoldClose;

            // Wire Up

            bracketOpenToken.Link(CurrentToken.TokenParent, CurrentToken.TokenBefore, bracketCloseToken, new List<SToken>() { CurrentToken });
            bracketCloseToken.Link(CurrentToken.TokenParent, bracketOpenToken, null, null);
            nextToken.Link(bracketOpenToken, CurrentToken, null, null);
            if (CurrentToken.TokenBefore != null)
            {
                CurrentToken.TokenBefore.TokenAfter[0] = bracketOpenToken;
            }
            if (CurrentToken.TokenDescribed != null)
            {
                CurrentToken.TokenDescribed.TokenProperties[0] = bracketOpenToken;
            }
            CurrentToken.Link(bracketOpenToken, null, nextToken, null);
            CurrentToken = nextToken;
        }