Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Pointers on working with another language's syntax

by CountZero (Bishop)
on Feb 17, 2003 at 19:58 UTC ( [id://236089]=note: print w/replies, xml ) Need Help??


in reply to Pointers on working with another language's syntax

Is that the language in which the text adventures of Zork et al. were written?

Fond memories of long nights spend in solving them, come back.

But for a solution of your problem: I would put the Inform code after a __DATA__ statement and then read the Inform code into a hash-structure (or more likely a hash of hashes of ... (just guessing as I don't know anything about the Inform language so the exact structure/grammar/rules are totally opaque to me)

Your Perl-Inform parser/interpreter can then manipulate this data structure in the "usual" way.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

  • Comment on Re: Pointers on working with another language's syntax

Replies are listed 'Best First'.
Re: Re: Pointers on working with another language's syntax
by Koschei (Monk) on Feb 18, 2003 at 10:56 UTC

    It's not the same language, no. But it compiles to the same virtual machine: the Z-machine. Inform was written to be a nice free compiler for the z-machine. It's actually a very nice OO language (well, as far as writing games goes).

    If you've listened to Mr Sugalski, you may have heard him talk about how he'd love to have Parrot be able to run z-code. Which would be fun.

    -- Iain, aka Koschei.

Re: Pointers on working with another language's syntax
by jonadab (Parson) on Feb 18, 2003 at 13:30 UTC
    I would put the Inform code after a __DATA__ statement and then read the Inform code

    Brilliant! Why didn't I think of that?

    into a hash-structure (or more likely a hash of hashes of

    Yes, it will need to be a nested structure. Something like

    $datum{$objectname}{$propertyname}=$propertyvalue; $datum{$objectname}{$attributename}=(($attr)?1:0);

    As an added bonus, this way of doing it will allow me to give the Inform objects hardware short names, declare their parents, and so on. Simply wonderful.

    The only downside is, this prevents me from putting a bunch of Perl code at the end as I was doing, but I can live with that restriction.


    sub H{$_=shift;while($_){$c=0;while(s/^2//){$c++;}s/^4//;$ v.=(' ','|','_',"\n",'\\','/')[$c]}$v}sub A{$_=shift;while ($_){$d=hex chop;for(1..4){$pl.=($d%2)?4:2;$d>>=1}}$pl}$H= "16f6da116f6db14b4b0906c4f324";print H(A($H)) # -- jonadab
      You could get the same effect with "here" documents, i.e. "<<EOF" style. That way you could continue to mix perl and Inform code and gain more points for obfuscation.
Re: Pointers on working with another language's syntax
by jonadab (Parson) on Feb 18, 2003 at 13:15 UTC
    Is that the language in which the text adventures of Zork et al. were written?

    Not Zork, but a great many of the modern classics in the same genre: _Curses_, _The Meteor, the Stone, and a Long Glass of Sherbet_, _Spider and Web_, _Christminster_, _Delusions_, and so on and so forth. There is also a clone of _Adventure_ (the cave game that inspired Zork), though the original was written in Fortran I think.

    Zork itself (and the other Infocom games) were written using a language and a compiler that AFAIK no longer exist. It is said to have been similar to MDL. Do a Google Groups search for the word "zil" in the group rec.arts.int-fiction for more information. You will have to wade through some repetition and a lot of people asking questions to which there are few answers, but there is also some real information and a short code snippet or two.

    However, when Activision went back and produced _Zork: The Undiscovered Underground_ (to re-awaken interest in the Zork series, since they were also doing a graphical game set in the same universe), they used Inform, since the language used for Zork had been lost.

    And, as the other pointer mentioned, Inform can compile to the virtual machine that Zork used, which is probably the second-most widely portable format after ASCII; the games can be played on anything from thirty-year-old mainframes to certain brands of pocket calculators (really). It is one of the few things that can be objectively said to definitely be more portable Perl. (Inform also compiles to another VM called glulx, which is newer and has less historical significance.)


    sub H{$_=shift;while($_){$c=0;while(s/^2//){$c++;}s/^4//;$ v.=(' ','|','_',"\n",'\\','/')[$c]}$v}sub A{$_=shift;while ($_){$d=hex chop;for(1..4){$pl.=($d%2)?4:2;$d>>=1}}$pl}$H= "16f6da116f6db14b4b0906c4f324";print H(A($H)) # -- jonadab

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://236089]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 07:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found