Example #1
0
 public MethodDeclaringNode(IdentifierNode ident, TypeNode type, ParameterSequenceNode parameters,
                            DeclaringSequenceNode vars, ActionSequenceNode actions, ReturnActionNode ret, SourceCodePosition pos)
     : base(pos)
 {
     Identifier    = ident;
     Type          = type;
     Parameters    = parameters;
     VarDeclarings = vars;
     Actions       = actions;
     Return        = ret;
 }
Example #2
0
 public object Visit(ReturnActionNode n, object o)
 {
     if (n.Expression is null)
     {
         AppendLine($"{AddIndent()}return;");
     }
     else
     {
         Append($"{AddIndent()}return ");
         n.Expression.Accept(this, null);
         AppendLine(";");
     }
     return(null);
 }
Example #3
0
        private ReturnActionNode ReturnStatement()
        {
            ReturnActionNode   itsAST;
            SourceCodePosition itsPos = _currentToken.SourcePosition;

            Accept(Token.TokenType.Return);
            if (_currentToken.Type == Token.TokenType.Semicolon)
            {
                itsAST = new ReturnActionNode(null, itsPos);   // null indicates void return type
            }
            else
            {
                itsAST = new ReturnActionNode(Expression(), itsPos);
            }
            Accept(Token.TokenType.Semicolon);
            return(itsAST);
        }
Example #4
0
        private MethodDeclaringNode ParseMethodDeclaring()
        {
            MethodDeclaringNode itsAST;
            SourceCodePosition  itsPos = _currentToken.SourcePosition;

            Accept(Token.TokenType.Method);
            TypeNode       itsType = ReturnType();
            IdentifierNode itsName = new IdentifierNode(_currentToken);

            Accept(Token.TokenType.Identifier);
            Accept(Token.TokenType.LeftParen);
            ParameterSequenceNode itsParams = Parameters();

            Accept(Token.TokenType.RightParen);
            Accept(Token.TokenType.LeftBrace);
            DeclaringSequenceNode itsVars    = VariableDeclarings();
            ActionSequenceNode    itsActions = ActionStatements();
            ReturnActionNode      itsReturn  = ReturnStatement();

            Accept(Token.TokenType.RightBrace);
            itsAST = new MethodDeclaringNode(itsName, itsType, itsParams, itsVars, itsActions, itsReturn, itsPos);
            return(itsAST);
        }
Example #5
0
 public object Visit(ReturnActionNode n, object o)
 {
     return(null);
 }
 // actionNode consturctor
 public ActionNode(ReturnActionNode _action)
 {
     action = _action;
 }