dMZX Forums: Zukes, an alternate, C-like, goto-free language for MZX - dMZX Forums

Jump to content

A Note About Artwork

It is permissable to post tasteful nude art, provided you include the disclaimer "(18+)" in your topic title. This is not the same thing as posting porn or other smut. Know and be mindful of the difference. If you are unsure of whether an image you wish to post is within the bounds of good taste, run it by an Admin privately first.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Zukes, an alternate, C-like, goto-free language for MZX and it's compiler, gmzc, converting it to Robotic

#1 User is offline   iamgreaser 

  • Member
  • PipPip
  • Group: Members
  • Posts: 95
  • Joined: 24-March 08

Posted 22 July 2010 - 09:52 AM

Hey guys, I made a compiler, it's really cool and stuff. The language is a bit of a pain in the arse to work with (see fac.zuk if you want an idea on how to do recursion). It optimises with respect to precalculating some expressions (although expect to see a crapton of labels one after another).

An example (tested, use the top-left 99x99 area of the board and put the robot elsewhere):

commands = 10000;

funct rand(local2, local3) local
{
  robotic
  {
    set "local" random "local2" "local3"
  }
}

sub wall(xp, yp)
{
  robotic
  {
    put c07 Solid p00 "xp" "yp"
  }
}

sub blank(xp, yp)
{
  robotic
  {
    put c07 Space p00 "xp" "yp"
  }
}

y = 0;
while(y <= 98)
{
  loop(98)
  {
    wall(loopcount,y);
  }
  y += 1;
}

y = 0;
while(y <= 98)
{
  x = 0;
  while(x <= 98)
  {
    vis@x@_@y@ = 0;
    blank(x,y);
    x += 2;
  }
  y += 2;
}

cx = rand(0,49)*2;
cy = rand(0,49)*2;
cc = 50*50-1;

vis@cx@_@cy@ = 1;
while(cc > 0)
{
  u = rand(0,1)*2-1*2;
  v = rand(0,1)*u;
  u -= v;
  nx = cx+u;
  ny = cy+v;
  robotic { * "~f&nx&,&ny& &cc&" }
  if((nx >= 0) & (nx <= 98) & (ny >= 0) & (ny <= 98))
  {
    if(vis@nx@_@ny@ == 0)
    {
      tx = u/2+cx;
      ty = v/2+cy;
      blank(tx, ty);
      vis@nx@_@ny@ = 1;
      cc -= 1;
    }
    cx = nx;
    cy = ny;
  }
}

robotic { * "done" }



gmzc, of course, stands for "GreaseMonkey's Zukes Compiler".

The compiler spews a crapton of debug info as I haven't worked out how to point out lines yet.

Also, there are bugs, although the only ones I'm aware of are with respect to escaping strings (you'll have to do \\\" instead of \" if you want double-quotes for now, otherwise it'll spew out bad Robotic) and possibly one related to small blocks (the situation i'm thinking of is "sub foo(bar) if(baz) { }").

There's a bunch of notes in syntax.txt.

Some of you might not want to build it. Well, good news everyone: I've included binary builds for FreeBSD 8 and NetBSD 5!

EDIT: Found a bug.
At the end of save_rob_if_true, it should read (note the != instead of the =):
	} else {
		save_rob_expr_calls(tree->l, FALSE);
		fprintf(fp, "if ");
		save_rob_expr(tree, TRUE);
		fprintf(fp, " != 0 \"_%s%i\"\n", label_name, label_idx);
	}
}

void save_rob_if_false(struct syn_tree *tree, char *label_name, int label_idx)
{


And same deal with same_rob_if_false, but with = instead of !=.

Will fix that Zukes code soon.

EDIT 2: Done.

Attached File(s)


This post has been edited by iamgreaser: 22 July 2010 - 10:02 AM

blah blah raycasters blah blah blah

<Stephen> are you dozing
<gm|lap> totally
<Stephen> good
<Stephen> i will bury you
0

#2 User is offline   asiekierka 

  • ??
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,241
  • Joined: 06-April 06

Posted 22 July 2010 - 10:19 AM

And here is the Windows binary, in case you really care.

But nice job, GM, it will make it much easier for logicow to make demos now :E

PS: I think it should be allowed as a DoZ external app

EDIT: applied GreaseMonkey's fix so you don't have to, and make .txt/.zuk files CRLF

Attached File(s)


This post has been edited by asiekierka: 22 July 2010 - 10:27 AM

DOWNLOAD STAN HERE: http://asiekierka.bo...nd.net/STAN.zip

Status:

SimLego II: 25%
SimLight: 0%
0

#3 User is offline   iamgreaser 

  • Member
  • PipPip
  • Group: Members
  • Posts: 95
  • Joined: 24-March 08

Posted 22 July 2010 - 10:28 AM

View Postasiekierka, on 22 July 2010 - 11:19 PM, said:

PS: I think it should be allowed as a DoZ external app


Well, I've coded and released it fairly soon after a recent DoZ, so that leaves us about 6 months to learn it for those who want to use it. I don't really see why this wouldn't be permitted as it isn't a big top-secret thing, and isn't actual robotic code (although I assume that you can't prepare Zukes code for a DoZ, but would have to do it on the day, like Robotic).
blah blah raycasters blah blah blah

<Stephen> are you dozing
<gm|lap> totally
<Stephen> good
<Stephen> i will bury you
0

#4 User is offline   Old-Sckool 

  • Remember when DMZX didn't suck
  • PipPipPip
  • Group: Members
  • Posts: 434
  • Joined: 07-June 05

Posted 24 July 2010 - 04:57 PM

I think found a bug.

loop(24)
{
  wall(loopcount%5,loopcount/5,5);
}


Doesn't seem to interpret the modulus command and becomes this (assuming that wall is a valid subroutine)

loop start
set "x" "('loopcount'5)"
set "y" "('loopcount'/5)"
set "count" 5
goto "#wall"
: "_ln0"

DigitalBarkness

<oLd-sckOoL> I just realized something ------------------ | <Old-Sckool> I read in wallstreet journal that a few
<Malwyn> oLd-sckOoL: your name makes you look twelve? --- | companies were holding virtual job interviews in second life
--------------------------------------------------------- | <Tox> "So I see you're a furry, mister anderson"
<AussieEvil> On a unrelated note, I think I need to buy - | ------
------------ a golf glove ------------------------------- | <iSkwirl> i just got done carving my jack off lantern
<AussieEvil> My palm's callused like crazy -------------- | <iSkwirl> o*
<AussieEvil> from gripping the driver too hard ---------- | <Old-Sckool> O_O
<AussieEvil> ...You could read that the wrong way... ---- | ------
<AussieEvil> Driver as in golf club -- the 1-wood ------- | <+paul_> post like you're writing to the president.
<AussieEvil> It's really long and has a big-ass head ---- | ------
<AussieEvil> Oh damnit ---------------------------------- | <Scorch3000> FAIL! I've had better insults from the
<AussieEvil> It's a golf club. I'm not gay. ------------- | priest at the local church.


Barkness is expanding!!! doughnuts?!?
0

#5 User is offline   iamgreaser 

  • Member
  • PipPip
  • Group: Members
  • Posts: 95
  • Joined: 24-March 08

Posted 25 July 2010 - 03:24 AM

View PostOld-Sckool, on 25 July 2010 - 05:57 AM, said:

I think found a bug.

loop(24)
{
  wall(loopcount%5,loopcount/5,5);
}


Doesn't seem to interpret the modulus command and becomes this (assuming that wall is a valid subroutine)

loop start
set "x" "('loopcount'5)"
set "y" "('loopcount'/5)"
set "count" 5
goto "#wall"
: "_ln0"



Thanks for pointing that out. It's an issue with me using fprintf without realising this...
			case BINOP_MOD:
				fprintf(fp, "%");
				break;


should be
			case BINOP_MOD:
				fprintf(fp, "%%");
				break;


@ ~line 1557 in main.c.

EDIT: Also, these @ ~line 1356:
				case BINOP_DIV:
					nt->num = (tree->r->num == 0
						? (tree->l->num < 0
							? -0x80000000
							: 0x7FFFFFFF
						)
						: tree->l->num / tree->r->num
					);
					break;
				case BINOP_MOD:
					nt->num = tree->l->num % tree->r->num;
					break;


should be more like
				case BINOP_DIV:
					nt->num = (tree->r->num == 0
						? 0
						: tree->l->num / tree->r->num
					);
					break;
				case BINOP_MOD:
					nt->num = (tree->l->num == 0
						? 0
						: tree->l->num % tree->r->num
					);
					break;

This post has been edited by iamgreaser: 25 July 2010 - 03:42 AM

blah blah raycasters blah blah blah

<Stephen> are you dozing
<gm|lap> totally
<Stephen> good
<Stephen> i will bury you
0

#6 User is offline   Exophase 

  • Laughing on the inside.
  • Group: DigiStaff
  • Posts: 6,741
  • Joined: 23-October 00

Posted 25 July 2010 - 05:21 AM

I think it's good that you have free gotos, the gotos in MZX are too expensive. Wait, nevermind.

(yeah I don't say very many useful things anymore.. good preprocessor though, hope someone feels like using it, if not you should really help getting some kind of improvement somehow in MZX proper since a lot of people probably don't like editing robots externally that much)
~ ex0 has a kickass battle engine, without it you sux0rz! without it you sux0rz! ~

"The fact that I say I've one of the best, is called honesty." -Akwende
"Megazeux is not ment to be just ASCII, it is ANSI!" - T-bone6
"I hate it when you get all exo on me." - emalkay

Exophase can what Rubi-cant.
exoware is ware ur ware is exoware
ps. not loking 4 new membrs kthx
0

#7 User is offline   commodorejohn 

  • life is pain and nobody understands me
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 3,205
  • Joined: 31-October 02

Posted 25 July 2010 - 09:48 PM

You do realize that C itself has gotos, right?

Anyway this is a totally cool idea and I endorse everything about it except the snubbing of gotos.


--------------------
"There is only one basic human right, the right to do as you damn well please. And with it comes the only basic human duty, the duty to take the consequences."
- P.J. O'Rourke
--------------------
"Of all tyrannies, a tyranny sincerely exercised for the good of its victims may be the most oppressive. It would be better to live under robber barons than under omnipotent moral busybodies. The robber baron's cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good torment us without end, for they do so with the approval of their own conscience."
- C.S. Lewis
--------------------
This week, on LANCER PONDERS:
<lolilover> I notice alot of Japanese fiction involving kemono-mimi characters always has the main character saving an innocent animal and then the animal returns as a girl to reward him for his kindness.
<lolilover> Well there's a cat that is always wandering around in my backyard. Should I feed it in the hopes that one day a catgirl will show up at my door?
0

#8 User is offline   Lancer-X 

  • どうせVIP@wwww>>安価orz
  • Group: Elite
  • Posts: 7,493
  • Joined: 20-March 02

Posted 26 July 2010 - 04:19 AM

I'm pretty sure GM knows that. That's why he specifically stated 'C-like, goto-free' rather than simply using the first to imply the second. Although I'm not sure if it's really a selling point; to advertise that your language is missing a certain construct, even if that construct is one that's rarely used well in programming languages with decent flow control structures.
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#9 User is offline   Exophase 

  • Laughing on the inside.
  • Group: DigiStaff
  • Posts: 6,741
  • Joined: 23-October 00

Posted 26 July 2010 - 05:42 AM

I think the idea behind calling it "goto free" is more to emphasize that you don't need gotos, the main thing that makes writing Robotic so horrible.
~ ex0 has a kickass battle engine, without it you sux0rz! without it you sux0rz! ~

"The fact that I say I've one of the best, is called honesty." -Akwende
"Megazeux is not ment to be just ASCII, it is ANSI!" - T-bone6
"I hate it when you get all exo on me." - emalkay

Exophase can what Rubi-cant.
exoware is ware ur ware is exoware
ps. not loking 4 new membrs kthx
0

#10 User is offline   iamgreaser 

  • Member
  • PipPip
  • Group: Members
  • Posts: 95
  • Joined: 24-March 08

Posted 26 July 2010 - 09:13 AM

If you insist, there's always robotic { goto "foo" } and robotic { : "foo" }. It's a little less pretty than some of you might like, but at least you have robotic available (the compiler just spits out all nonwhitespaceonly lines with leading whitespace trimmed).

I am aware of C's "goto" keyword, but I don't think I've ever used it.
blah blah raycasters blah blah blah

<Stephen> are you dozing
<gm|lap> totally
<Stephen> good
<Stephen> i will bury you
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users