Esempio n. 1
0
 public object Visit(MultipleDeclaringSequenceNode n, object o)
 {
     n.Declaring.Accept(this, null);
     if (_buildingImplSequence)
     {
         Append(", ");
     }
     n.Declarings.Accept(this, null);
     return(null);
 }
Esempio n. 2
0
        private DeclaringSequenceNode ParseMethodDeclarings()
        {
            DeclaringSequenceNode itsAST;
            SourceCodePosition    itsPos    = _currentToken.SourcePosition;
            DeclaringNode         itsMethod = ParseMethodDeclaring();

            if (_currentToken.Type == Token.TokenType.Method)
            {
                DeclaringSequenceNode itsNextMethods = ParseMethodDeclarings();
                itsAST = new MultipleDeclaringSequenceNode(itsMethod, itsNextMethods, itsPos);
            }
            else
            {
                itsAST = new SingleDeclaringSequenceNode(itsMethod, itsPos);
            }
            return(itsAST);
        }
Esempio n. 3
0
        private DeclaringSequenceNode ParseVariableDeclarings()
        {
            DeclaringSequenceNode itsAST;
            SourceCodePosition    itsPos = _currentToken.SourcePosition;
            DeclaringNode         itsVar = ParseVariableDeclaring();

            if (_currentToken.Type == Token.TokenType.Var)
            {
                DeclaringSequenceNode itsNextVars = ParseVariableDeclarings();
                itsAST = new MultipleDeclaringSequenceNode(itsVar, itsNextVars, itsPos);
            }
            else
            {
                itsAST = new SingleDeclaringSequenceNode(itsVar, itsPos);
            }
            return(itsAST);
        }
Esempio n. 4
0
        private DeclaringSequenceNode ParseImplements()
        {
            DeclaringSequenceNode itsAST;
            SourceCodePosition    itsPos       = _currentToken.SourcePosition;
            DeclaringNode         itsImplement = ParseImplement();

            if (_currentToken.Type == Token.TokenType.Comma)
            {
                Accept(Token.TokenType.Comma);
                DeclaringSequenceNode itsNextImplements = ParseImplements();
                itsAST = new MultipleDeclaringSequenceNode(itsImplement, itsNextImplements, itsPos);
            }
            else
            {
                itsAST = new SingleDeclaringSequenceNode(itsImplement, itsPos);
            }
            return(itsAST);
        }
Esempio n. 5
0
        // Parses the source code based on the grammar of the language.
        // The result of the parsing is an AST representing the source code.
        // Each node in the built AST contains the source code position of the corresponding source code,
        // such that future processing of the AST can always refer back to this position.
        // If any syntax error is found, a SyntaxError exception is thrown.
        public ProgramNode Program()
        {
            ProgramNode           itsAST = null; // set to null in case of syntax error
            SourceCodePosition    itsPos = _currentToken.SourcePosition;
            DeclaringSequenceNode itsDeclarings;

            if (_currentToken.Type == Token.TokenType.Interface)
            {
                itsDeclarings = new SingleDeclaringSequenceNode(InterfaceDeclaring(), itsPos);
                while (_currentToken.Type == Token.TokenType.Interface)
                {
                    itsDeclarings = new MultipleDeclaringSequenceNode(InterfaceDeclaring(), itsDeclarings, itsPos);
                }
                while (_currentToken.Type == Token.TokenType.Class)
                {
                    itsDeclarings = new MultipleDeclaringSequenceNode(ClassDeclaring(), itsDeclarings, itsPos);
                }
                Accept(Token.TokenType.EOF);
                itsAST = new ProgramNode(itsDeclarings, itsPos);
            }
            else if (_currentToken.Type == Token.TokenType.Class)
            {
                itsDeclarings = new SingleDeclaringSequenceNode(ClassDeclaring(), itsPos);
                while (_currentToken.Type == Token.TokenType.Class)
                {
                    itsDeclarings = new MultipleDeclaringSequenceNode(ClassDeclaring(), itsDeclarings, itsPos);
                }
                Accept(Token.TokenType.EOF);
                itsAST = new ProgramNode(itsDeclarings, itsPos);
            }
            else if (_currentToken.Type == Token.TokenType.EOF)
            {
                Accept(Token.TokenType.EOF);
            }
            else
            {
                Error("Expected interface, class or EOF");
            }
            return(itsAST);
        }
Esempio n. 6
0
 public object Visit(MultipleDeclaringSequenceNode n, object o)
 {
     n.Declaring.Accept(this, null);
     n.Declarings.Accept(this, null);
     return(null);
 }