Page 1 of 1

run time compiler

Posted: Mon Jun 28, 2004 2:37 pm
by nuno_silva_pt
Helo everyone! nice to see the form has been growing!
so, i want to ask u this:
i have this file:
test.aplication
and i want to use
compiler.exe test.aplication
and i want the program to do this:
if the file has
msgbox("test","test")
then
the program makes a msgbox with the title "test" and the text "test"
how can i make it?
thank you for your help!

Re:run time compiler

Posted: Mon Jun 28, 2004 3:23 pm
by Eero Ränik
There are plenty of topics here about making compilers... ;)

Re:run time compiler

Posted: Tue Jun 29, 2004 4:27 am
by Pype.Clicker
that basically depends on how you're creating a message box ... and of what else you wish to do with your "application".

Compiler:
- identifies the text as

Code: Select all

<command>
    <function name="msgbox">
         <argument type="const string">"test"</argument>
         <argument type="const string">"test"</argument>
   </function>
</command>
this is the result of parsing your text input.

- have a translator that knows how a 'function call' should be implemented. For instance (using perl-like syntax pseudocode)

Code: Select all

sub translate_function {
    $address=$name_to_address_map{$function.name};
    foreach $arg (@function.arguments) {
         &translate($arg);
    push @code, "call $address";
    push @code, "add esp, ". 4*($#arg+1);
}

sub translate_const_string_argument {
    push @code, "section .data\ndb str$STRID $content\n"
                        ."section .code\n"
    push @code, "push $STRID";
    $STRID++;
}