[MUD-Dev] Internal Mud Languages

Chris Gray cg at ami-cg.GraySage.Edmonton.AB.CA
Mon May 26 20:07:22 New Zealand Standard Time 1997


[Jon L:]

:I have been attempting to decipher the LCC compiler which
:produces native 486 code.  An implementation of C with all it's
:semantic/syntax complexities is quite a bit more than I had in 
:mind.
:
:Can anyone point me to some very basic examples/documentation
:of these functions carried out completely?

"Amiga Transactor", V4 #'s 4-6, and V5 #1 contain a series of
articles on writing a small compiler. Now, that was in 1989 and I don't
imagine that copies are now easy to come by. However, since I wuz the
author (cough!), I happen to have the full sources and articles here
on my hard-drive. The compiler compiled a subset of my Draco language
into M68000 machine code. The whole thing is just 3260 lines of code,
with a fair amount of comments, plus the articles themselves. It does
not use any lexer generator or parser generator tools, etc. - it is
complete in itself. It is *not* a very big language, but I did manage
to write a small character-graphics target-shoot game in it. Here is
the classic in "Toy":

/*
 * hanoi.t - standard "Towers of Hanoi" in toy.
 */

proc printPeg(int peg)void:

    if peg = 1 then
	write("left");
    elif peg = 2 then
	write("center");
    else
	write("right");
    fi;
corp;

proc hanoi(int n, fromPeg, usingPeg, toPeg)void:

    if n ~= 0 then
	hanoi(n - 1, fromPeg, toPeg, usingPeg);
	write("Move disk from ");
	printPeg(fromPeg);
	write(" peg to ");
	printPeg(toPeg);
	write(" peg.\n");
	hanoi(n - 1, usingPeg, fromPeg, toPeg);
    fi;
corp;

proc main()void:
    int n;

    write("How many pegs? ");
    readln(n);
    hanoi(n, 1, 2, 3);
corp;


--
Chris Gray   cg at ami-cg.GraySage.Edmonton.AB.CA



More information about the MUD-Dev mailing list