Jump to content

Translator into AutoIt


TypeIt
 Share

Recommended Posts

I'm writing a translator that translates another program written in something similar to AutoIt into AutoIt. That translator performs a static type check, then removes the type annotations and rewrites expressions and statements that AutoIt does not allow (currently only array literals and names) into something that the AutoIt interpreter will accept.

Example:

Func Fibonacci (n as number)
    Return n == 0 ? 1 : n * Fibonacci (n - 1)
EndFunc
Fibonacci (["array", "of", "strings"]) ; type error
becomes

Func Fibonacci ($n)
    Return $n == 0 ? 1 : $n * Fibonacci ($n - 1)
EndFunc
Local $temp1 = ["array", "of", "strings"]
Fibonacci ($temp1)
I'm planning to include function overloading and static overload resolution, and maybe a runtime type check for the arguments based on the specified or inferred parameter types. Do you have any other ideas?
Link to comment
Share on other sites

Not according to the output in the OP. That's the point I am making.

I don't agree with every default of Tidy. The lexer removes whitespace; I'm doing my best to make the output readable.

The lexer also removes comments. Before adding new comments I'd like to preserve existing comments. :)

But adding a comment containing the name of the function should be easy. I added an option.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...