Ejemplo n.º 1
0
void Tokenize(const string& code, CodeToken::List& tokens)
{
	CodeError::List errors;
	auto codeFile = CodeFile::Parse(code, 0, errors);
	TEST_ASSERT(errors.size() == 0);
	TEST_ASSERT(codeFile->lines.size() == 1);
	tokens = codeFile->lines[0]->tokens;
}
Ejemplo n.º 2
0
    repeat with the current number from first number to last number
        add the current number to the result
    end
end

phrase main
    print "1+ ... +100 = " & sum from 1 to 100
end
)tinymoe";

	vector<string> codes;
	CodeError::List errors;
	codes.push_back(GetCodeForStandardLibrary());
	codes.push_back(code);
	auto assembly = SymbolAssembly::Parse(codes, errors);
	TEST_ASSERT(errors.size() == 0);
	TEST_ASSERT(assembly->symbolModules.size() == 2);
}

TEST_CASE(TestParseNamedBlockModule)
{
	string code = R"tinymoe(
module hello world
using standard library

sentence print (message)
	redirect to "printf"
end

phrase sum from (first number) to (last number)
    set the result to 0