예제 #1
0
        public void ProgramParsesReturnStatementWithUnsignedInteger()
        {
            string code            = @"
int main()
{
    return 420u;
}
";
            var    program         = new ProgramNode();
            var    function        = new FunctionNode(program, "main", new List <FunctionParameter>());
            var    returnStatement = new ReturnNode(function);
            var    returnValue     = new UIntNode(returnStatement, 420u);

            returnStatement.AddChild(returnValue);
            function.AddChild(returnStatement);
            program.AddChild(function);

            AssertResultMatchesExpectedProgram(code, program);
        }
예제 #2
0
        public void ProgramParsesReturnStatementWithIdentifier()
        {
            string code    = @"int foo = 420;
int main()
{
    return foo;
}
";
            var    program = new ProgramNode();

            program.AddChild(new VariableDeclarationNode(program, "int", "foo", "420"));
            var function        = new FunctionNode(program, "main", new List <FunctionParameter>());
            var returnStatement = new ReturnNode(function);
            var returnValue     = new IdentifierNode(returnStatement, "foo");

            returnStatement.AddChild(returnValue);
            function.AddChild(returnStatement);
            program.AddChild(function);

            AssertResultMatchesExpectedProgram(code, program);
        }