🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Actual Epoch Work! Yayy!

Published July 17, 2008
Advertisement
I've finally gotten back around to working on the Epoch virtual machine again. In addition to a handful of arithmetic operators, I've added some key elements:

  • 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.
Next Entry Hello world
0 likes 3 comments

Comments

Emmanuel Deloget
Quote: Original post by ApochPiQ
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.

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.
July 17, 2008 05:56 PM
ApochPiQ
Even with a tool like ANTLR to streamline the process, developing a syntax is not trivial (at least at my current level of experience). There's a lot of tweaking and minor adjustment that has to be made, and the bulk of discovering a good syntax involves actually writing code to find out where the syntax gets cramped or problematic. Creating the parser and hooking it up to the VM backend is a breeze; it's the process of slowly refining the thing until it's actually usable that worries me.

I'd much rather the bulk of the facilities of the language in place first. That way it's just a matter of experimenting with the options on the syntax level. Otherwise, you run the risk of creating a beautiful syntax and then discovering that some critical language feature doesn't fit into the paradigm - and that is precisely why I'm putting of the syntax work as long as possible.
July 17, 2008 10:13 PM
Jotaf
I prefer Boost::Spirit, once you learn the details defining any syntax is pretty easy ;)
July 18, 2008 12:29 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement