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?
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
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],
};
?
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
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 :)
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:
Type tPosition
Top As Long
Left As Long
End Type
Type Character
Name As String
[b]Position As tPosition[/b]
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
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:
Type tPosition
Top As Long
Left As Long
End Type
Type Character
Name As String
[b]Position As tPosition[/b]
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.
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?
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