Exemplo n.º 1
0
 public SCodeToken(int tokenId, SCElementType tokenType, string tokenString, SCodeToken tokenBefore, SCodeToken tokenAfter, string tokenCode, SCodeToken tokenParent, List<SCodeToken> tokenChilds )
 {
     TokenId = tokenId;
     TokenType = tokenType;
     TokenString = tokenString;
     TokenBefore = tokenBefore;
     TokenAfter = tokenAfter;
     TokenCode = tokenCode;
     TokenParent = tokenParent;
     TokenChild = tokenChilds != null ? new List<SCodeToken>() : tokenChilds;
 }
Exemplo n.º 2
0
        public string ToString(SCodeToken token)
        {
            int acoladeBracketBlock = 0;
            int angleBracketBlock = 0;
            int rightBracketBlock = 0;
            int roundBracketBlock = 0;

            StringBuilder tokenCollectionAsString = new StringBuilder();

            while (token != null)
            {
                string color;
                switch (token.TokenType)
                {
                    case SCElementType.AcoladeBracketBlock:
                        color = "red";
                        break;
                    case SCElementType.AngleBracketBlock:
                        color = "blue";
                        break;
                    case SCElementType.RightBracketBlock:
                        color = "magenta";
                        break;
                    case SCElementType.RoundBracketBlock:
                        color = "orange";
                        break;
                    case SCElementType.Undefined:
                        color = "green";
                        break;
                    default:
                        color = "black";
                        break;
                }
                if (((!(token.TokenAfter == null) && !(token.TokenAfter.TokenAfter == null) && (!(token.TokenAfter.TokenAfter.TokenAfter == null && ! string.IsNullOrEmpty(token.TokenAfter.TokenString) &&")]>}".Contains(token.TokenAfter.TokenString[0]))))) || token.TokenType == SCElementType.Undefined)
                {
                    tokenCollectionAsString.Append("<span style='color:" + color + "'>" + System.Security.SecurityElement.Escape(token.TokenString + ":" + token.TokenCode) + "</span> ");
                }
                else
                {
                    tokenCollectionAsString.Append("<span style='background-color:yellow; color:" + color + "'>" + System.Security.SecurityElement.Escape(token.TokenString) + "</span> ");
                }
                
                foreach (SCodeToken codeTokenlist in token.TokenChild)
                {
                    tokenCollectionAsString.Append(ToString(codeTokenlist));
                    if (token.TokenType==SCElementType.AcoladeBracketBlock && tokenCollectionAsString.ToString().TrimEnd().EndsWith(";"))
                    {
                        tokenCollectionAsString.Append("</br>");
                    }
                }
                token = token.TokenAfter;
                
            }
            
            return tokenCollectionAsString.ToString();
        }
Exemplo n.º 3
0
 private void CloseRightBlock(string tokenText, char c) 
 {
     currentToken.TokenString = tokenText;
     currentToken = parentToken;
     SCodeToken bracketToken = new SCodeToken(0, SCElementType.RightBracketBlock, string.Empty + c, currentToken, SCodeToken.NULL, "", currentToken.TokenParent, new List<SCodeToken>());
     parentToken = currentToken.TokenParent;
     currentToken.TokenAfter = bracketToken;
     SCodeToken nextToken = new SCodeToken(0, SCElementType.Undefined, string.Empty, bracketToken, SCodeToken.NULL, "", bracketToken.TokenParent, new List<SCodeToken>());
     bracketToken.TokenAfter = nextToken;
     currentToken = nextToken;
 }
Exemplo n.º 4
0
 private void OpenRightBlock(string tokenText, char c) 
 {
     currentToken.TokenString = tokenText;
     // DownLevel
     SCodeToken bracketToken = new SCodeToken(0, SCElementType.RightBracketBlock, string.Empty + c, currentToken, SCodeToken.NULL, "", parentToken, new List<SCodeToken>());
     currentToken.TokenAfter = bracketToken;
     currentToken = bracketToken;
     // Right
     SCodeToken bracketContentToken = new SCodeToken(0, SCElementType.Undefined, string.Empty, SCodeToken.NULL, SCodeToken.NULL, "", bracketToken, new List<SCodeToken>());
     currentToken.TokenChild.Add(bracketContentToken);
     parentToken = currentToken; // mouve down
     currentToken = bracketContentToken;
 }
Exemplo n.º 5
0
 private void AddBlock(string tokenText, char c) {
     currentToken.TokenString = tokenText + c;
     SCodeToken aToken = new SCodeToken(0, SCElementType.Undefined, "", SCodeToken.NULL, SCodeToken.NULL, "", parentToken, new List<SCodeToken>());
     parentToken.TokenChild.Add(aToken);
     currentToken = aToken;
 }
Exemplo n.º 6
0
 public ECodeDocument(string documentText)
 {
     DocumentText = documentText;
     RootTocken = new SCodeToken(0, SCElementType.Undefined, string.Empty, SCodeToken.NULL, SCodeToken.NULL, string.Empty, SCodeToken.NULL, new List<SCodeToken>());
     RootTocken.TokenChild.Add( new SCodeToken(0, SCElementType.Undefined, string.Empty, SCodeToken.NULL, SCodeToken.NULL, string.Empty, rootTocken, new List<SCodeToken>()) );
     parentToken = RootTocken;
     currentToken = RootTocken.TokenChild[0];
 }