Boolean Express

posted in noaktree leaves
Published June 30, 2005
Advertisement
Oh the misery...

For those of you who have never owned a Ford Escort then you either know better or have really good karma. I bought one as a get-a-rounder last year for 2Gs and it has been in to the shop at least 3 times. As I write the transmission fluid is pouring out of the differential axels, estimated cost 2Gs! So I've been busy looking around for a new car and this has interfered with my usual routine. I want something that will last a little more than a year this time. My choice is a Honda Civic. If there is anybody here who has reason to protest this union, let them speak now or forever hold their peace.

What I have done...

I finished up on integers by adding the unary minus operator. I also redesigned the way vector and float types will be held in memory (more on this later). Before adding the rest of the built in types, however, I wanted to get some program control in place. The first step was to add a boolean expression parser. This will be used in if-then-else and while control statements.

I am currently using : as an equivalence operator and do not yet have >= , <=, or != operators in place. This is because my tokenizer cannot yet identify multiple character operators. I'll add those later. Here is an example of what the parser can handle:

evaluate( (0 | !( 5 < 5 )) & !0 );

output: 1
Previous Entry Magus Expressions
Next Entry If else
0 likes 9 comments

Comments

NickGeorgia
My Ford Ranger has lasted 10 years. Unfortunatey....
June 30, 2005 10:48 PM
stormrunner
No objection, Your Honor.
July 01, 2005 12:25 AM
jollyjeffers
> Honda Civic > Ford Escort.

Quote:This is because my tokenizer cannot yet identify multiple character operators.

You worked out how to do this yet? I know at least one of our implementations at university used a "maximal munch" rule for parsing variable and/or operator combinations. Dunno if thats of any interest?

Jack
July 01, 2005 03:28 AM
The Forgotten Mindset
I object!

Don't get a Honda, you wanna have some dignity don't you? (those cars dissenigrate after 10 years, I swear)

Get a Nissan 300zx baby!

They come in all shapes/sizes/speeds and fuel economy options.

I've got an 87 and it's good on gas. Highway @ 80mph: ~30 mpg (a really short road trip taught me that [grin])

'89 300zx - Looks like mine
eBay
July 01, 2005 08:53 PM
noaktree
Hey that 1989 Nissan 300ZX looks sort of like a Mazda RX-7 I used to have. I ended up getting a family type Mercury vehicle. It's got a Nissan V6 in it though.
July 02, 2005 02:58 PM
noaktree
Quote:You worked out how to do this yet? I know at least one of our implementations at university used a "maximal munch" rule for parsing variable and/or operator combinations.
What's a "maximal munch" rule? I did get it working. I have a function that determines the token type. I just made a special case for the equals ('=') operator. When it is encountered it switches the previous token for one of these ('<', '>', '!', or '='). If one is found then it changes the previous token and ignores the current token (never pushes it on the list). As a default the current token is set as an equals operator. Works very well.

I'd like to know more about compiler theory. Recommend any good text books? I only had an intro to formal language and automata in school no direct compiler education. [sad]
July 02, 2005 03:52 PM
jollyjeffers
Quote:What's a "maximal munch" rule?

I'd have to check my notes for the proper definition, but it was basically a case where "if there are a number of sequences that start the same, keeping on reading (munching) as far as possible"

By example, if you had these 3 possible sequences:
AABB
AABBCC
AABBCCD

and where parsing through
AABBAABBCCDEFG

you'd grab the AABB first, but then if you were to just carry on you'd actually match "AABBCC" before you matched "AABBCCD". I suppose it does depend on the characteristics of your language, so you might want it that way. 'Maximal Munch' would find the "AABBCCD" in the above sequence because it keeps on going until it can no longer match a symbol (e.g. when it gets to "E").

Quote:I'd like to know more about compiler theory. Recommend any good text books?

The 'Dragon Book' is supposed to be the definitive text on compiler theory. My lecturer went on-and-on about that book [smile] However, we were required to use a more applied book for the course that had all its examples in Java...

Jack
July 04, 2005 03:43 AM
The Forgotten Mindset
Yeah, mazda's been copying Nissan in style for a long time. [smile] (Nissan was first to have that style just so you know)

I think Nissan copyed corvette though :P
(notice the wheels design, t-top, and fenders)

And wow, I've never heard of anyone owning an Rx-7 for any reason other than racing. Or is that why you had it?

Those wankle engines aren't very ideal for normal street conditions, and they burn a ton of oil. But their perfect for racing. (very high RPMs)
July 05, 2005 01:38 PM
noaktree
I was given an RX-7 for my 16th birthday! [smile] No racing just chicks. [wink]
July 05, 2005 09:24 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement