Esempio n. 1
0
            public void MethodDec()
            {
                FormalParamListOpt();
                if (curr.token == Token.Separator)
                {
                    if (String.Equals(curr.lexem, ")"))
                    {
                        curr = curr.Next;
                    }
                }
                else
                {
                    throw new ParseException("Error of compilation, MethodDec(1)!", curr.cLine);
                }

                if (curr.token == Token.Separator)
                {
                    if (String.Equals(curr.lexem, ";"))
                    {
                        curr = curr.Next;
                    }
                }
                else
                {
                    throw new ParseException("Error of compilation, MethodDec(2)!", curr.cLine);
                }
            }
Esempio n. 2
0
 public void AccessOpt()
 {
     if (curr.token == Token.KeyWord)
     {
         if (String.Equals(curr.lexem, "private") || String.Equals(curr.lexem, "protected") || String.Equals(curr.lexem, "public"))
         {
             curr = curr.Next;
         }
     }
 }
Esempio n. 3
0
            public void ClassDecl()
            {
                Header();
                if (String.Equals(curr.lexem, "class"))
                {
                    curr = curr.Next;
                }
                else
                {
                    throw new ParseException("Error of compilation, ClassDecl(1)!", curr.cLine);
                }

                if (curr.token == Token.ID)
                {
                    curr = curr.Next;
                }
                else
                {
                    throw new ParseException("Error of compilation, ClassDecl(2)!", curr.cLine);
                }

                ClassBaseOpt();

                if (curr.token == Token.Separator)
                {
                    if (String.Equals(curr.lexem, "{"))
                    {
                        curr = curr.Next;
                    }
                    else
                    {
                        throw new ParseException("Error of compilation, ClassDecl(3)!", curr.cLine);
                    }
                }

                ClassItemDecsOpt();

                if (curr.token == Token.Separator)
                {
                    if (String.Equals(curr.lexem, "}"))
                    {
                        curr = curr.Next;
                    }
                    else
                    {
                        throw new ParseException("Error of compilation, ClassDecl(4)!", curr.cLine);
                    }
                }
                if (curr != null)
                {
                    curr = curr.Next;
                    ClassDecl();
                }
            }
Esempio n. 4
0
 public void Modifier()
 {
     if (curr.token == Token.KeyWord)
     {
         if (String.Equals(curr.lexem, "abstract") || String.Equals(curr.lexem, "override") ||
             String.Equals(curr.lexem, "static") || String.Equals(curr.lexem, "extern") ||
             String.Equals(curr.lexem, "virtual") || String.Equals(curr.lexem, "volatile"))
         {
             curr = curr.Next;
         }
     }
 }
Esempio n. 5
0
            public void HTID()
            {
                Header();

                IdType();

                if (curr.token == Token.ID)
                {
                    curr = curr.Next;
                }
                else
                {
                    throw new ParseException("Error of compilation, HTID()!", curr.cLine);
                }
            }
Esempio n. 6
0
 public void ParamList()
 {
     IdType();
     if (curr.token == Token.ID)
     {
         curr = curr.Next;
     }
     if (curr.token == Token.Separator)
     {
         if (String.Equals(curr.lexem, ","))
         {
             curr = curr.Next;
             ParamList();
         }
     }
 }
Esempio n. 7
0
 public void ClassBaseOpt()
 {
     if (curr.token == Token.Separator)
     {
         if (String.Equals(curr.lexem, ":"))
         {
             curr = curr.Next;
             if (curr.token == Token.ID)
             {
                 curr = curr.Next;
             }
             else
             {
                 throw new ParseException("Error of compilation, ClassBaseOpt()!", curr.cLine);
             }
         }
     }
 }
Esempio n. 8
0
 public void IdType()
 {
     if (curr.token == Token.ID)
     {
         curr = curr.Next;
     }
     else if (curr.token == Token.KeyWord)
     {
         if (String.Equals(curr.lexem, "int") || String.Equals(curr.lexem, "double") ||
             String.Equals(curr.lexem, "string") || String.Equals(curr.lexem, "bool"))
         {
             curr = curr.Next;
         }
     }
     else
     {
         throw new ParseException("Error of compilation, IdType()!", curr.cLine);
     }
 }
Esempio n. 9
0
 public void ClassItem()
 {
     HTID();
     if (curr.token == Token.Separator)
     {
         if (String.Equals(curr.lexem, ";"))
         {
             curr = curr.Next;
             ClassItemDecsOpt();
         }
         else if (String.Equals(curr.lexem, "("))
         {
             curr = curr.Next;
             MethodDec();
         }
         else
         {
             throw new ParseException("Error of compilation, ClassItem()!", curr.cLine);
         }
     }
 }
Esempio n. 10
0
 public Parser(Lexems.LexTokList lex)
 {
     this.lex = lex;
     curr     = lex.head;
 }