Pages: 1 2 »
  Print  
Author Topic: Expression Evaluator complete.  (Read 5040 times)
Offline (Male) Josh @ Dreamland
Posted on: June 16, 2009, 02:26:59 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2949

View Profile Email
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:
Both as 7z / as zip
C++ as 7z / as zip
GML as 7z / as zip
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.
« Last Edit: June 16, 2009, 02:41:44 PM by Josh @ Dreamland » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Game_boy
Reply #1 Posted on: June 17, 2009, 11:46:13 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
On the GML one:

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

1==1
1
Logged
Offline (Male) Rusky
Reply #2 Posted on: June 17, 2009, 03:54:51 PM

Resident Troll
Joined: Feb 2008
Posts: 955
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
Stupid GM with its context-specific expression/statement crap...
Logged
Offline (Male) RetroX
Reply #3 Posted on: June 17, 2009, 04:18:50 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
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?
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Josh @ Dreamland
Reply #4 Posted on: June 17, 2009, 09:20:53 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2949

View Profile Email
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.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Game_boy
Reply #5 Posted on: June 18, 2009, 12:53:12 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
"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.
Logged
Offline (Male) RetroX
Reply #6 Posted on: June 18, 2009, 07:51:54 AM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
And on that note, I think using a single = in ENIGMA when compiling doesn't work either. >_>
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) Game_boy
Reply #7 Posted on: June 18, 2009, 10:21:08 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
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.
Logged
Offline (Unknown gender) score_under
Reply #8 Posted on: June 18, 2009, 03:22:41 PM

Member
Joined: Aug 2008
Posts: 308

View Profile
Yeah, 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.
Logged
Offline (Male) Josh @ Dreamland
Reply #9 Posted on: June 18, 2009, 09:02:26 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2949

View Profile Email
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.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) whaddsoft
Reply #10 Posted on: June 20, 2009, 08:44:05 PM
Member
Joined: Jul 2008
Posts: 12

View Profile Email
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?
Logged
Offline (Unknown gender) Game_boy
Reply #11 Posted on: June 21, 2009, 06:24:39 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
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.
Logged
Offline (Male) Rusky
Reply #12 Posted on: June 21, 2009, 08:18:57 PM

Resident Troll
Joined: Feb 2008
Posts: 955
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
They're going to be making YoYo steam though
Logged
Offline (Male) Josh @ Dreamland
Reply #13 Posted on: June 21, 2009, 09:26:04 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2949

View Profile Email
Yoyo's going to be making everything, just ask them.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Female) IsmAvatar
Reply #14 Posted on: June 22, 2009, 11:47:14 AM

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 886

View Profile Email
Yeah, 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.
Logged
Pages: 1 2 »
  Print