- Code block support (the value of a block is the value of the last executed statement)
- Function support (code block + parameter list)
- Library function framework
- Random number generator library function
This means that with a little more work on the UI side, I can hack up a quick guess-the-number game, which will be the first official program written entirely in Epoch.
It's still pretty weird to work with since all the language primitives are being manipulated in C++ rather than in an actual separate syntax. This gives us wonderfully verbose code like this:
bool LibraryCallTest::Test(){ VM::Scope parameters; parameters.AddIntegralVariable(L"maximum", 1000); Library::RandomIntegralValue func; VM::RValuePtr result = func.Invoke(parameters); UNITTEST_ASSUMPTION(result->GetType() == VM::EpochVariableType_Integer); int resultvalue = VM::TypesManager::CastRValue(*result).GetValue(); UNITTEST_ASSUMPTION(resultvalue >= 0 && resultvalue < 1000); std::wostringstream str; str << L"Random number generated: " << resultvalue; VM::Scope scope; VM::Operations::DebugWriteStaticString(str.str()).Execute(scope); return true;}
I still haven't decided when I'm going to actually get around to writing a syntax front-end for the thing. My hesitation stems from two points: general laziness (writing a parser is dreadful work), and concern that I'll lock in a syntax too quickly if I do it before the bulk of the language is implemented.
I really don't relish the idea of building much more complication into the language using this clunky approach, but at the same time, I really need a solid rapid-prototyping toolchain before I can really play with the syntax. Since syntax will be one of the most difficult parts of the language to refine, I want to make sure I get it right as quickly as possible.
Anyways... that's about all the babbling on that subject that I've got. Stay tuned - as soon as the VM is capable of running the guessing-game, I'll be releasing the very first public preview of the source for everyone to experiment with.
Meh.
Time for using a parser generator a la ANTLR1? You know that some of these can really generate some really real C++ code. Coco/R seems to be of interest too (and doesn't call the lexer method yylex()... that's an industry breakthrough).
More here.
--
1) ANTLR is supposed to be a LL(k) parser generator, so it shall bring you some additional freeness to build your language (as you're neither restricated to the simple case where k=1 nor to the classical LALR parser generators). Try to use v2.7.5 as there is no C++ code path for v3.