Pages: 1 2
Author Topic: Expression Evaluator complete.  (145,675 Views)
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Posted on: June 16, 2009, 07:26:59 PM
I'm pleased to inform that the expression evaluator is working just as I'd hoped.
I'd like it to have a public test.

There are two versions. The C++ one, and the GML one. The C++ one is for macros, and so does not allow strings or floats. (Numbers that aren't integers.) Also as per preprocessors, it doesn't allow casts. (Though, there is a cast system implemented.)
This means that 5/2 = 2.
The GML one does allow strings and floats. It should work just like you're used to.

Note that functions and variables aren't in yet. It's an expression evaluator. It's designed for #if. Variables will be treated as zero. I just overkilled it a bit so I could more easily make a full fledged interpreter later on.

Other changes include that ternary exists, and there are more than two string comparison operators.
(("str"=="str")?"true":"false")+"zor" is my favorite string test.
Also, note that single quotes are treated as numbers in C++, and I think I left them that way in the GML one. So 'str' is a number, "str" is a string.

This means one less step on my todo list. One more item checked off.

Those who wish to try it out can download it here:

When the window pops up, you are immediately allowed to type. You can clear the screen by typing c or cls, and close it by typing x. (And pressing enter.)


Anyway, I'm going back to the CFile parser now, which I've been told by many is the impossible task for one person with no tools. But I don't care what they think. ^_^

Also, feel free to keep guessing at the secret from last topic.
I'll be working.
Offline (Unknown gender) Game_boy

Member
Joined: Apr 2008
Posts: 228
View profile
Reply #1 Posted on: June 17, 2009, 04:46:13 PM
On the GML one:

1=1
Error at 2: can't assign to that

1==1
1
Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #2 Posted on: June 17, 2009, 08:54:51 PM
Stupid GM with its context-specific expression/statement crap...
Offline (Unknown gender) RetroX

Master of all things Linux
Contributor
Joined: Apr 2008
Posts: 1,055
View profile
Reply #3 Posted on: June 17, 2009, 09:18:50 PM
Quote from: Game_boy on June 17, 2009, 04:46:13 PM
On the GML one:

1=1
Error at 2: can't assign to that

1==1
1
Does that mean it works on the C++ one, or you just mentioned it because it's GML which allows that?
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #4 Posted on: June 18, 2009, 02:20:53 AM
Yeah, I didn't really put much thought into converting it to GML. I just flipped a couple macro values.
Either way, nice catch. Noted for whenever this is applied to debug mode. And since this evaluates just the expression part, not the actual assignment operator, it'll be as simple as replacing that error with treating it as a comparison.
Offline (Unknown gender) Game_boy

Member
Joined: Apr 2008
Posts: 228
View profile
Reply #5 Posted on: June 18, 2009, 05:53:12 AM
"Does that mean it works on the C++ one, or you just mentioned it because it's GML which allows that?"

The latter. I thought the GML one wouldn't recognise "=", but as Josh said it's just the standalone evaluator that doesn't.
Offline (Unknown gender) RetroX

Master of all things Linux
Contributor
Joined: Apr 2008
Posts: 1,055
View profile
Reply #6 Posted on: June 18, 2009, 12:51:54 PM
And on that note, I think using a single = in ENIGMA when compiling doesn't work either. >_>
Offline (Unknown gender) Game_boy

Member
Joined: Apr 2008
Posts: 228
View profile
Reply #7 Posted on: June 18, 2009, 03:21:08 PM
Quote from: RetroX on June 18, 2009, 12:51:54 PM
And on that note, I think using a single = in ENIGMA when compiling doesn't work either. >_>

Yeah, that's a bit more serious. The majority of existing GM projects use "=" rather than "==" I think.
Offline (Unknown gender) score_under

Member
Joined: Aug 2008
Posts: 308
View profile
Reply #8 Posted on: June 18, 2009, 08:22:41 PM
Quote from: Game_boy on June 18, 2009, 03:21:08 PMYeah, that's a bit more serious. The majority of existing GM projects use "=" rather than "==" I think.
People who do that instantly go down on my assimilate-as-soon-as-possible list.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #9 Posted on: June 19, 2009, 02:02:26 AM
I only replace them in if()'s and the like.
I find that a=b=c=0 is too damn useful to dispose of. I'll probably end up option-izing it.
Offline (Unknown gender) whaddsoft

Member
Joined: Jul 2008
Posts: 12
View profile
Reply #10 Posted on: June 21, 2009, 01:44:05 AM
Quote from: Josh @ Dreamland on June 16, 2009, 07:26:59 PM
Also, feel free to keep guessing at the secret from last topic.
I'll be working.

Are the games actually going to be posted on Steam?
Offline (Unknown gender) Game_boy

Member
Joined: Apr 2008
Posts: 228
View profile
Reply #11 Posted on: June 21, 2009, 11:24:39 AM
Quote from: whaddsoft on June 21, 2009, 01:44:05 AM
Quote from: Josh @ Dreamland on June 16, 2009, 07:26:59 PM
Also, feel free to keep guessing at the secret from last topic.
I'll be working.

Are the games actually going to be posted on Steam?

That's not only impractical, but also Steam does not run on Linux and has restrictive DRM.
Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #12 Posted on: June 22, 2009, 01:18:57 AM
They're going to be making YoYo steam though
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #13 Posted on: June 22, 2009, 02:26:04 AM
Yoyo's going to be making everything, just ask them.
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Reply #14 Posted on: June 22, 2009, 04:47:14 PM
Quote from: score_under on June 18, 2009, 08:22:41 PM
Quote from: Game_boy on June 18, 2009, 03:21:08 PMYeah, that's a bit more serious. The majority of existing GM projects use "=" rather than "==" I think.
People who do that instantly go down on my assimilate-as-soon-as-possible list.

Then there's the Pascal syntax.
if (a = b) then begin
b := 2;
end;

Valid GML syntax, valid Pascal syntax.
Pages: 1 2