<HEAD><TITLE>discuss@charon: [802] in "Coldmud discussion meeting"</TITLE>
<H1>[802] in Coldmud discussion meeting</H1></HEAD>
<A HREF="/"><IMG SRC="/i-d.gif" ALT="root"></A>
<A HREF="?802"><IMG SRC="/i-back.gif" ALT="meeting"></A>
<A HREF="/help.html"><IMG SRC="/i-help.gif" ALT="help"></A>
<A HREF="1"><IMG SRC="/i-first.gif" ALT="first"></A>
<IMG SRC="/n-fref.gif" ALT="">
<IMG SRC="/n-pref.gif" ALT="">
<A HREF="801"><IMG SRC="/i-prev.gif" ALT="previous"></A>
<A HREF="803"><IMG SRC="/i-next.gif" ALT="next"></A>
<IMG SRC="/n-nref.gif" ALT="">
<IMG SRC="/n-lref.gif" ALT="">
<A HREF="1641"><IMG SRC="/i-last.gif" ALT="last"></A>
<HR><H2>MOO Verb -&gt; ColdC Method</H2>
<H3>daemon@ATHENA.MIT.EDU (Sun Sep 10 17:05:19 1995
)</H3>
<PRE>
Date: Sun, 10 Sep 1995 15:04:33 -0600
From: 869683 Gillespie Brandon James &lt;brandon@smithfield.declab.usu.edu&gt;
To: coldstuff@MIT.EDU

In the wee morning hours of last night, I started to hack up a MOO-&gt;ColdC
convertor.  It currently does everything, including some buildint function
conversions, up to the point where I got sick of doing it (about at
property/verb MOO builtins).

This is NOT intended as a direct conversion utility, you WILL have to
still do some cleanup/rewrites.  However, if it helps lure some of the MOO
crowd over, yipee :)

-------------------------------
moo2coldc
#!/u2/consultants/brandon/bin/p

while (&lt;&gt;) {
    # get comments out of the way...
    (s/^(\s*)\"\s*(.*)\s*\"\;/$1\/\/ $2/) &amp;&amp; print &amp;&amp; next;

    # Fix lists first...
    s/\{/[/g;
    s/\}/]/g;

    # if we know it will only match once, continue
    (s/^(\s*)else$/${1}} else {/) &amp;&amp; print &amp;&amp; next;
    (s/^(\s*)(endif|endfor|endwhile)/${1}}/) &amp;&amp; print &amp;&amp; next;

    # control .. things (man am I up too late)
    s/^(\s*)if\s+\((.*)\)\s*/${1}if ($2) {\n/;
    s/^(\s*)elseif\s+\((.*)\)/${1}} else if ($2) {/;
    s/^(\s*)for\s+([a-z_\*])\s+in\s+([\(\[].*[\)\]])\s*/${1}for $2 in $3 {\n/;
    s/^(\s*)while\s+\((.*)\)\s*/${1}while ($2) {\n/;

    # change 'this' to nothing, fix properties
    s/this:/./g;
    s/this\.//g;

    # change obj:verb to obj.method, fix property refs by making them methods
    s/([a-z_\*]+)\.([a-z_\*]+)/$1.$2()/gi;
    s/([a-z_\*]+):([a-z_\*]+)/$1.$2/gi;

    # handle subrange syntax, this doesn't get assignment subranges
    s/([a-z_\*]+)\[([0-9]+)\.\.([0-9]+)\]/${1}.subrange(${2}, ${3})/gi;

    # do basic function conversions...
    s/typeof\(/type\(/g;
    s/tonum\(/toint\(/g;
    s/length\((.*)\)/${1}.length()/g;
    s/rindex\((.*)\)/${1}.rindex()/g;
    s/match\(/match_regexp(/g;
    s/rmatch\(/match_regexp(/g;
    s/substitute\((.*),\s*(.*)\)/${1}.regexp\(/g;
    s/listinsert\(/insert(/g;
    s/listappend\(/append(/g;
    s/listdelete\(/delete(/g;
    s/listset\(/replace(/g;
    s/chparent\((.*),\s*(.*)\)/${1}.chparents(${2})/g;
    s/parent\((.*)\)/${1}.parents()/g;
    s/children\((.*)\)/${1}.children()/g;
    s/recycle\(/destroy(/g;
    s/max_object\(/next_dbref(/g;
    s/move\((.*)\)/${1}.move_to()/g;

    ## properties/verbs are not the same, PAY ATTENTION
    s/properties\((.*)\)/${1}.parameters()/g;
    s/properties\((.*)\)/${1}.parameters()/g;

    ## Bad
    # s/players\(\)//g;

    print;
}

</PRE>
