run time compiler

Programming, for all ages and all languages.
Post Reply
nuno_silva_pt

run time compiler

Post 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!
Eero Ränik

Re:run time compiler

Post by Eero Ränik »

There are plenty of topics here about making compilers... ;)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:run time compiler

Post 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++;
}
Post Reply