Exemplo n.º 1
0
        public static Node match(Token_Class ExpectedToken)
        {
            // string temp = Enum.GetName(typeof(Token_Class), ExpectedToken);
            //Node node = new Node(temp);
            Node node = new Node();

            //  if (i < myTokens.Count)
            //{
            if (myTokens[i].token_type == ExpectedToken)
            {
                node.token = myTokens[i];
                i++;
            }
            else if (myTokens[i].token_type == Token_Class.Comment)
            {
                i++;
            }
            else
            {
                Errors.Error_List.Add(" " + "missing" + " ");
                Errors.Error_List.Add(ExpectedToken.ToString());
            }
            //}

            return(node);
        }
Exemplo n.º 2
0
        public Node Match(Token_Class ExpectedToken)
        {
            if (InputPointer < TokenStream.Count && ExpectedToken == TokenStream[InputPointer].token_type)
            {
                InputPointer++;
                Node newNode = new Node(ExpectedToken.ToString());

                return(newNode);
            }

            else
            {
                if (InputPointer < TokenStream.Count)
                {
                    Errors.Error_List.Add("Parsing Error: Expected "
                                          + ExpectedToken.ToString() + " and " +
                                          TokenStream[InputPointer].token_type.ToString() +
                                          " found\r\n"
                                          + " at " + InputPointer.ToString() + "\n");

                    InputPointer++;
                }
                else
                {
                    Errors.Error_List.Add("Parsing Error: Expected "
                                          + ExpectedToken.ToString() + " and nothing was found\r\n");
                }

                return(null);
            }
        }
Exemplo n.º 3
0
 public bool CheckForNull(Token_Class token)
 {
     if (InputPointer < TokenStream.Count && TokenStream[InputPointer].token_type == token)
     {
         return(true);
     }
     return(false);
 }
 public void CheckForErrorList(Token_Class x1, Token_Class x2)
 {
     if (x1 != x2)
     {
         Console.WriteLine("ERROR LIST: " + x1 + " and " + x2);
         Errors.Error_List.Add("Expected " + x2 + " Found " + x1 + " Lexeme number: " + InputPointer);
         return;
     }
 }
Exemplo n.º 5
0
        public static TDNODE match(Token_Class t)
        {
            TDNODE match = new TDNODE();

            if (i < LT.Count() && LT[i].token_type == t)
            {
                match.token = LT[i];
                bing        = false;
                i++;
            }
            else
            {
                if (i >= LT.Count)
                {
                    string s = "Some essential lines doesn't exist.";
                    ErrorList.Add(s);
                }
                else if (!bing)
                {
                    int j = Scanner.NewLine.Count() - 1;
                    while (!(i <= Scanner.NewLine[j] && i > Scanner.NewLine[j - 1]))
                    {
                        j--;
                    }
                    if (i + 1 < LT.Count && LT[i + 1].token_type == t)
                    {
                        string s = "Extra ";
                        s += LT[i].lex;
                        ErrorList.Add(s);
                        match.token = LT[i + 1];
                        i          += 2;
                    }
                    else if (i == Scanner.NewLine[j - 1] + 1)
                    {
                        string s = "Expected ";
                        s += t.ToString();
                        s += " here.";
                        ErrorList.Add(s);
                        bing = true;
                    }
                    else //if (i + 1 < LT.Count && LT[i + 1].token_type != t)
                    {
                        string s = "Expected ";
                        s += t.ToString();
                        s += " instead of ";
                        s += LT[i].lex;
                        ErrorList.Add(s);
                        i++;
                    }
                }
            }
            return(match);
        }
Exemplo n.º 6
0
        public static Node match(Token_Class ExpectedToken)
        {
            Node node = new Node();

            //write your pars
            if (currenttokens[i].token_type == ExpectedToken)
            {
                node.token = currenttokens[i];
                i++;
            }
            else
            {
                string s = "Expected" + ExpectedToken + "found" + currenttokens[i].lex;
                node = new Node(s);
            }
            return(node);
        }
Exemplo n.º 7
0
        static bool CompareReturnType(string FunctionName, Token_Class Datatype)
        {
            FunctionValue Result = FunctionTable.Find(fv => fv.ID == FunctionName);

            if (Result == null)
            {
                MessageBox.Show("Function does't exist, something went wrong");
                return(false);
            }
            else
            {
                if (Result.ReturnType != Datatype)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 8
0
        public Node match(Token_Class ExpectedToken)
        {
            if (ExpectedToken == TokenStream[InputPointer].token_type)
            {
                InputPointer++;
                Node newNode = new Node(ExpectedToken.ToString());

                return(newNode);
            }

            else
            {
                Errors.Error_List.Add(InputPointer + "Parsing Error: Expected "
                                      + ExpectedToken.ToString() + " and " +
                                      TokenStream[InputPointer].token_type.ToString() +
                                      "  found\r\n");
                InputPointer++;
                return(null);
            }
        }
Exemplo n.º 9
0
 public Token(string lex, Token_Class token_type)
 {
     this.lex        = lex;
     this.token_type = token_type;
 }
Exemplo n.º 10
0
 public Token(string lex, Token_Class token_type)
 {
     this.tokenvalue = tokenvalue;
     this.token_type = token_type;
 }