TinyMUSH 3.3
TinyMUSH Server
|
Handle boolean expressions. More...
#include "config.h"
#include "constants.h"
#include "typedefs.h"
#include "macros.h"
#include "externs.h"
#include "prototypes.h"
#include <stdbool.h>
#include <ctype.h>
Functions | |
bool | check_attr (dbref player, dbref lockobj, ATTR *attr, char *key) |
indicate if attribute ATTR on player passes key when checked by the object lockobj More... | |
BOOLEXP * | alloc_boolexp (void) |
Prepare a BOOLEXP item. More... | |
void | free_boolexp (BOOLEXP *b) |
Free a BOOLEXP item. More... | |
bool | eval_boolexp (dbref player, dbref thing, dbref from, BOOLEXP *b) |
Evaluate a boolean expression. More... | |
bool | eval_boolexp_atr (dbref player, dbref thing, dbref from, char *key) |
Evaluate attribute's boolean expression. More... | |
void | skip_whitespace (char **pBuf) |
Skip over whitespace in a string. More... | |
BOOLEXP * | test_atr (char *s, dbref parse_player) |
Test attriutes. More... | |
BOOLEXP * | parse_boolexp_L (char **pBuf, dbref parse_player, bool parsing_internal) |
L -> (E); L -> object identifier. More... | |
BOOLEXP * | parse_boolexp_F (char **pBuf, dbref parse_player, bool parsing_internal) |
F -> !F; F -> @L; F -> =L; F -> +L; F -> $L. More... | |
BOOLEXP * | parse_boolexp_T (char **pBuf, dbref parse_player, bool parsing_internal) |
T -> F; T -> F & T. More... | |
BOOLEXP * | parse_boolexp_E (char **pBuf, dbref parse_player, bool parsing_internal) |
E -> T; E -> T | E. More... | |
BOOLEXP * | parse_boolexp (dbref player, const char *buf, bool internal) |
Parse a boolean expression. More... | |
Handle boolean expressions.
BOOLEXP * alloc_boolexp | ( | void | ) |
Prepare a BOOLEXP item.
bool check_attr | ( | dbref | player, |
dbref | lockobj, | ||
ATTR * | attr, | ||
char * | key | ||
) |
indicate if attribute ATTR on player passes key when checked by the object lockobj
player | DBref of player |
lockobj | DBref of locked object |
attr | Attribute |
key | Key |
We can see control locks... else we'd break zones
bool eval_boolexp | ( | dbref | player, |
dbref | thing, | ||
dbref | from, | ||
BOOLEXP * | b | ||
) |
Evaluate a boolean expression.
player | DBref of player |
thing | DBref of thing |
from | DBref from |
b | Boolean expression |
BOOLEXP_INDIR (i.e. @) is a unary operation which is replaced at evaluation time by the lock of the object whose number is the argument of the operation.
no such attribute
First check the object itself, then its contents
no such attribute
If an object check, do that
Nope, do an attribute check
If an object check, do that
Nope, do an attribute check
bad type
bool eval_boolexp_atr | ( | dbref | player, |
dbref | thing, | ||
dbref | from, | ||
char * | key | ||
) |
Evaluate attribute's boolean expression.
player | DBref of player |
thing | DBref of thing |
from | DBref from |
key | Attribute's key |
void free_boolexp | ( | BOOLEXP * | b | ) |
Free a BOOLEXP item.
b | BOOLEXP item. |
BOOLEXP * parse_boolexp | ( | dbref | player, |
const char * | buf, | ||
bool | internal | ||
) |
Parse a boolean expression.
player | DBref of player |
buf | Attribute buffer |
internal | Internal check? |
BOOLEXP * parse_boolexp_E | ( | char ** | pBuf, |
dbref | parse_player, | ||
bool | parsing_internal | ||
) |
E -> T; E -> T | E.
pBuf | Attribute buffer |
parse_player | DBref of player |
parsing_internal | Engine or player triggered? |
BOOLEXP * parse_boolexp_F | ( | char ** | pBuf, |
dbref | parse_player, | ||
bool | parsing_internal | ||
) |
F -> !F; F -> @L; F -> =L; F -> +L; F -> $L.
The argument L must be type BOOLEXP_CONST
pBuf | Attribute buffer |
parse_player | DBref of player |
parsing_internal | Engine or player triggered? |
BOOLEXP * parse_boolexp_L | ( | char ** | pBuf, |
dbref | parse_player, | ||
bool | parsing_internal | ||
) |
L -> (E); L -> object identifier.
pBuf | Attribute buffer |
parse_player | DBref of player |
parsing_internal | Engine or player triggered? |
must have hit an object ref. Load the name into our buffer
check for an attribute
Do the match. If we are parsing a boolexp that was a stored lock then we know that object refs are all dbrefs, so we skip the expensive match code.
BOOLEXP * parse_boolexp_T | ( | char ** | pBuf, |
dbref | parse_player, | ||
bool | parsing_internal | ||
) |
T -> F; T -> F & T.
pBuf | Attribute buffer |
parse_player | DBref of player |
parsing_internal | Engine or player triggered? |
void skip_whitespace | ( | char ** | pBuf | ) |
Skip over whitespace in a string.
pBuf | Buffer to skip whitespace in |
BOOLEXP * test_atr | ( | char * | s, |
dbref | parse_player | ||
) |
Test attriutes.
s | Attribute to test |
parse_player | DBref of player triggering the test |
See if left side is valid attribute. Access to attr is checked on eval. Also allow numeric references to attributes. It can't hurt us, and lets us import stuff that stores attr locks by number instead of by name.
Only #1 can lock on numbers
made it now make the parse tree node