示例#1
0
 public Token(int id, int line, int collumn, RecognitionToken recToken, string word)
 {
     this.Id       = id;
     this.Line     = line;
     this.Collumn  = collumn;
     this.RecToken = recToken;
     this.Word     = word;
 }
示例#2
0
        /// <summary>
        /// 1. Create Structs
        /// 2. Separators unitys
        /// 2.1
        /// </summary>
        /// <param name="sourcecode"></param>
        /// <returns></returns>
        public override Graph <Token, Token> Analysis(string sourcecode)
        {
            if (string.IsNullOrWhiteSpace(sourcecode))
            {
                sourcecode = string.Empty;
            }

            sourcecode = sourcecode.Replace("\r", "");
            List <string> tokens = Tokenizer(sourcecode);

            GraphTokens = new Graph <Token, Token>();
            List <Token> lastTokens   = new List <Token>();
            int          lineActual   = 0;
            int          columnActual = 0;
            var          root         = GraphTokens.AddNode("Root");

            GraphTokens.Root = root;
            root.Info        = new Token(0, 0, 0, null, "R");
            Node <Token, Token> lastNode = root;

            for (int i = 0; i < tokens.Count; i++)
            {
                if (i == 23)
                {
                }
                columnActual = i;

                RecognitionToken rule = FindRules(tokens[i]).Max();
                if (rule != null)
                {
                    var   node  = GraphTokens.AddNode(NextIdNode());
                    Token token = new Token(NextIdToken(), lineActual, columnActual, rule, tokens[i]);
                    node.Info = token;
                    var edge = lastNode.AddEdge(token, node, rule.LastMatchValue);
                    lastNode = node;
                }
            }
            return(GraphTokens);
        }
示例#3
0
 public Token(int id, int line, int collumn, RecognitionToken recToken, char word)
     : this(id, line, collumn, recToken, "" + word)
 {
 }