Sign in to follow this  
  • entries
    149
  • comments
    510
  • views
    94474

Boolean Express

Sign in to follow this  
noaktree

90 views

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
Sign in to follow this  


9 Comments


Recommended Comments

> 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

Share this comment


Link to comment
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

Share this comment


Link to comment
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.

Share this comment


Link to comment
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]

Share this comment


Link to comment
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

Share this comment


Link to comment
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)

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now