My Scripting Language

Printable View



I plan on using the API to create controls (including windows) instead of using a control array and creating a new instance of an already existing form. I figure it'd be less of a drag on memory if I did it this way.

I've attached the source to the parser. If you guys want to improve on it, give me suggestions, or compliments up to this point, please do :)

chem
  • Aug 4th, 2005, 10:43 AM
    penagate
    Re: My Scripting Language
    Can you clarify the difference between an Enum and a struct? That looks like an enum to me. or do you declare a struct using typedef struct?
  • Aug 4th, 2005, 10:52 AM
    chemicalNova
    Re: My Scripting Language
    Hey, I've spent 3 days on this with greater success than I thought I would up to this point. At the moment, it defaults to an enum (mainly because I haven't added the variable assignment yet (outside of the default value)).

    I just wanted a bit of feedback concerning the idea, possibly some suggestions on global types, etc.

    I'm a bit tired now. If something isn't clear, I'll be able to explain it better tomorrow :p

    chem
  • Aug 4th, 2005, 11:00 AM
    penagate
    Re: My Scripting Language
    Suggestion: A Win API header file parser that converts types and API declares to your script language syntax, for use as include files :)

    have I got the idea:
    Code:

    typedef struct OSVERSIONINFO {
        long dwOSVersionInfoSize,
        long dwMajorVersion,
        long dwMinorVersion,
        long dwBuildNumber,
        long dwPlatformId,
        char szCSDVersion[128],
    };

    ?
  • Aug 4th, 2005, 11:10 AM
    chemicalNova
    Re: My Scripting Language
    Hey, that isn't a bad idea :D Although, it would take forever, some of them are :eek:

    Tomorrow, I'll start working on variable assignments, then I can create a proper typedef syntax (enum, struct, and possibly union :D).

    Another idea I had, was to use LoadLibrary and FreeLibrary so the API can be used.
    Code:

    dlopen("user32");
    _api InvalidateRect([rect type here]);
    dlclose("user32");

    :D

    You've inspired me to keep going with this penagate, and for that, I thank you :p

    chem
  • Aug 4th, 2005, 11:16 AM
    penagate
    Re: My Scripting Language
    Quote:

    Originally Posted by chemicalNova
    Another idea I had, was to use LoadLibrary and FreeLibrary so the API can be used.
    Code:

    dlopen("user32");
    _api InvalidateRect([rect type here]);
    dlclose("user32");


    I haven't looked at your parser yet, will tommorow (you can probably guess the time in Adelaide right now, half hour diff) but that is an idea. The trouble you have then is calling it. The only way I have seen so far is to use CallWindowProc but that forces you to pass 4 Long parameters.

    Quote:

    Originally Posted by chemicalNova
    You've inspired me to keep going with this penagate, and for that, I thank you :p

    Always like to see interesting projects :)
  • Aug 7th, 2005, 07:44 AM
    chemicalNova
    Re: My Scripting Language
    I think this might be best moved to the Project Communications area.

    I've got variable assignments happening. So a script like this:
    Code:

    void main()
    {
            var string myString;
            myString = "Hello World!";
            MessageBox.MB_OKCANCEL = MessageBox.MB_RETRYCANCEL;
            MessageBox(myString, MessageBox.MB_OKCANCEL + MessageBox.MB_EXCLAMATION, "Test");
            ExitProcess;
    }

    ..will work. myString contains no string until the next line. I'll get Enums and Structs working, then I'll attach the updated code. I plan on have unions aswell. For an example of this in VB, its having a type with another type declared in it:
    VB Code:
    1. Type tPosition
    2.     Top As Long
    3.     Left As Long
    4. End Type
    5.  
    6. Type Character
    7.     Name As String
    8.     [b]Position As tPosition[/b]
    9. End Type
    Also on the agenda: classes. This will take alot longer than the above, but it will happen :) Then we could use this:
    Code:

    var class MyClass
    {
        var long MyNum=0;
        void Add(var long num1, var long num2)
        {
            return (num1+num2);
        }
    }

    void main()
    {
        var MyClass this;
        this.myNum = 4;
        MessageBox(this.Add(this.MyNum, 4), MessageBox.MB_OK, "Equals");
        ExitProcess;
    }

    Suggestions are welcome :D

    chem
  • Aug 7th, 2005, 11:43 AM
    Joacim Andersson
    Re: My Scripting Language
    Quote:

    Originally Posted by chemicalNova
    I plan on have unions aswell. For an example of this in VB, its having a type with another type declared in it:
    VB Code:
    1. Type tPosition
    2.     Top As Long
    3.     Left As Long
    4. End Type
    5.  
    6. Type Character
    7.     Name As String
    8.     [b]Position As tPosition[/b]
    9. End Type

    I think you've misunderstood what a union is. It's kind of like a struct but can at any one time contain only one of it's members in memory.

    Take this C example:
    Code:

    union MyUnion
    {
        int i;
        char ch;
    }

    void main()
    {
        union MyUnion uni; //declaration of a union variable
        uni.i = 27; //assignment to one of the union members
        uni.ch = 'A'; //another assignment
        printf("%d", uni.i); //syntax error! The i member has been overwritten
    }

    The above code would probably cause an error or a very unsuspected result. Since the union can only hold one of the members in memory at one time, assigning a value to the ch member will overwrite the memory used by the i member.
  • Aug 8th, 2005, 02:23 AM
    penagate
    Re: My Scripting Language
    Can you get rid of the "var" keyword? It seems a bit unnecessary seeing as whenever you declare a type in C it follows the syntax [Typename] [Varname] anyway.

    Also, what about one-line declaration and assignment? e.g.
    Code:

    string MyString = "Hello World!";
    and how does class instantiation work?
    Code:

    MyClass this = new MyClass;
    // or
    MyClass this;  // gets instantiated here?

  • Aug 8th, 2005, 02:35 AM
    chemicalNova
    Re: My Scripting Language
    Quote:

    Originally Posted by Joacim Andersson
    I think you've misunderstood what a union is. It's kind of like a struct but can at any one time contain only one of it's members in memory.

    Take this C example:
    Code:

    union MyUnion
    {
        int i;
        char ch;
    }

    void main()
    {
        union MyUnion uni; //declaration of a union variable
        uni.i = 27; //assignment to one of the union members
        uni.ch = 'A'; //another assignment
        printf("%d", uni.i); //syntax error! The i member has been overwritten
    }

    The above code would probably cause an error or a very unsuspected result. Since the union can only hold one of the members in memory at one time, assigning a value to the ch member will overwrite the memory used by the i member.

    Crickey. *gets old C++ books from shelf*. Think its best I read up on those, again. Ta Joacim :)

    Quote:

    Originally Posted by penagate
    Can you get rid of the "var" keyword?

    It just makes parsing it alot easier :) Maybe soon I'll just make it [type][varname].
    Quote:

    Originally Posted by penagate
    and how does class instantiation work?

    I think I'll end up making it..
    Code:

    MyClass this = new MyClass;
    I kinda wanted it to be different from C/C++, so I don't want it too much like them.

    Ta for the input guys :)

    chem