[CODE] #if parser

From: Andrew Ritchie (object@alphalink.com.au)
Date: 06/30/99


I am trying to develop, at the moment, an #if #else-type parser for dynamic
room descriptions, much like that of the gnu-c #if parser. I think I have
worked out how to do most of it, the only things I am having trouble with
are the statements that are after the #if or #elseif statements. For example:

#if RAINING | HAILING | SNOWING
It's cold here ~
#else
It's warm here ~
#endif

Now the computer parses the 'RAINING | HAILING | SNOWING' to, let's say, '0
| 0 | 1', meaning that it's snowing here. Now for OR statements (|'s), I
simply cycle through all the 0s and 1s and make sure that at least one of
them is a 1, or true.

For AND statements (&), I simply cycle through them and make sure that ALL
of them are set to 1, or set true. What I'm not sure how to do is combine
the ORs and ANDs into one statement. For example:

#if SNOWING | (HAILING & RAINING)

Not sure how I would go about doing this. Obviously, I'd need a function to
parse () statements. Anyone got any ideas?

Cheers,

Andrew.

---
Andrew Ritchie,
object@alphalink.com.au.
www.alphalink.com.au/~object/


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST