pingus-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pingus Scripting Language


From: Ingo Ruhnke
Subject: Pingus Scripting Language
Date: Tue, 06 Apr 2004 05:25:01 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Hiho,

have hacked together a little very simple XML based scripting
language, not the most beatifull one, but might be enough for our
needs. Some example scripts are below, interpreter for them is in the
svn repo, named xml_eval. Not sure if we really need scripting, but in
case we do it might be usefull :)

Display fibonacci numbers:

<block>
  <set name="last1" var="0" />
  <set name="last2" var="1" />
  
  <function name="fib">
    <set name="cur" var="last1" />
    <add name="cur" var="last2" />

    <printvar var="cur" />
    <newline />

    <set name="last1" var="last2" />
    <set name="last2" var="cur" />
    <funcall name="fib" />
  </function>

  <funcall name="fib" />
</block>

Calc Primes from 3 to 150:

<block>
  <function name="checkprim">
    <set name="prim" var="1"/>

    <set name="end" var="i" />
    <add name="end" var="-1" />

    <for name="j" start="2" end="end">
      <set    name="test" var="i" />
      <modulo name="test" var="j" />
     
      <if-zero var="test">
        <set name="prim" var="0"/>
        <set name="j" var="end"/><!-- break -->
      </if-zero>
    </for>
    
    <if-non-zero var="prim">
      <printvar var="i" />
      <print string=" is prime" />
      <newline />
    </if-zero>
  </function>

  <for name="i" start="3" end="150">
    <funcall name="checkprim" />
  </for>
</block>

-- 
WWW:      http://pingus.seul.org/~grumbel/ 
JabberID: address@hidden 
ICQ:      59461927




reply via email to

[Prev in Thread] Current Thread [Next in Thread]