Exemple #1
0
        private VariableDeclaration ParseVariableDeclaration()
        {
            VariableDeclaration variableDeclaration = null;

            if (_currentToken.TheTokenType.Equals(Token.TokenType.VARIABLE_TYPE))
            {
                var variableType = new VariableType(Accept(Token.TokenType.VARIABLE_TYPE));
                var variableName = new UserCreatableID(Accept(Token.TokenType.USER_CREATABLE_ID));


                Expression1 expression = null;
                if (_currentToken.TheTokenType.Equals(Token.TokenType.ASSIGNMENT))
                {
                    Accept(Token.TokenType.ASSIGNMENT);
                    expression = ParseExpression1();
                }

                variableDeclaration = new VariableDeclarationSimple(variableType, variableName, expression);
            }
            else if (Token.TokenType.COOK == _currentToken.TheTokenType)
            {
                variableDeclaration =
                    new VariableDeclarationStructVariableDeclaration(ParseStructVariableDeclaration());
            }

            Accept(Token.TokenType.SEMICOLON);
            return(variableDeclaration);
        }
Exemple #2
0
        private StructVariableDeclaration ParseStructVariableDeclaration()
        {
            Accept(Token.TokenType.COOK);
            var structName   = new UserCreatableID(Accept(Token.TokenType.USER_CREATABLE_ID));
            var variableName = new UserCreatableID(Accept(Token.TokenType.USER_CREATABLE_ID));

            return(new StructVariableDeclaration(structName, variableName));
        }
Exemple #3
0
        private Struct ParseStruct()
        {
            Accept(Token.TokenType.KEBAB);
            var structName = new UserCreatableID(Accept(Token.TokenType.USER_CREATABLE_ID));

            Accept(Token.TokenType.LEFT_SQUARE);
            VariableDeclarationList variableDeclarationList = ParseVariableDeclarationList();

            Accept(Token.TokenType.RIGHT_SQUARE);
            return(new Struct(structName, variableDeclarationList));
        }
Exemple #4
0
        private FunctionDeclaration ParseFunctionDeclaration()
        {
            Accept(Token.TokenType.FUNCTION);
            var functionName = new UserCreatableID(Accept(Token.TokenType.USER_CREATABLE_ID));

            Accept(Token.TokenType.TAKES);
            ParameterList parameterList = ParseParameterList();

            Accept(Token.TokenType.GIVES_BACK);
            ReturnType returnType = ParseReturnType();

            Accept(Token.TokenType.LEFT_SQUARE);
            Statements statements = ParseStatements();

            Accept(Token.TokenType.RIGHT_SQUARE);
            return(new FunctionDeclaration(functionName, parameterList, returnType, statements));
        }
Exemple #5
0
 public FunctionCall(UserCreatableID functionName, ArgumentList argumentList)
 {
     FunctionName = functionName;
     ArgumentList = argumentList;
 }