TinyMUSH 3.3
TinyMUSH Server
Loading...
Searching...
No Matches
Functions
boolexp.c File Reference

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>
Include dependency graph for boolexp.c:

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...
 
BOOLEXPalloc_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...
 
BOOLEXPtest_atr (char *s, dbref parse_player)
 Test attriutes. More...
 
BOOLEXPparse_boolexp_L (char **pBuf, dbref parse_player, bool parsing_internal)
 L -> (E); L -> object identifier. More...
 
BOOLEXPparse_boolexp_F (char **pBuf, dbref parse_player, bool parsing_internal)
 F -> !F; F -> @L; F -> =L; F -> +L; F -> $L. More...
 
BOOLEXPparse_boolexp_T (char **pBuf, dbref parse_player, bool parsing_internal)
 T -> F; T -> F & T. More...
 
BOOLEXPparse_boolexp_E (char **pBuf, dbref parse_player, bool parsing_internal)
 E -> T; E -> T | E. More...
 
BOOLEXPparse_boolexp (dbref player, const char *buf, bool internal)
 Parse a boolean expression. More...
 

Detailed Description

Handle boolean expressions.

Author
TinyMUSH development team (https://github.com/TinyMUSH)
Version
3.3
Date
2020-12-24

Function Documentation

◆ alloc_boolexp()

BOOLEXP * alloc_boolexp ( void  )

Prepare a BOOLEXP item.

Returns
BOOLEXP* Initialized BOOLEXP item.

◆ check_attr()

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

Parameters
playerDBref of player
lockobjDBref of locked object
attrAttribute
keyKey
Returns
bool

We can see control locks... else we'd break zones

◆ eval_boolexp()

bool eval_boolexp ( dbref  player,
dbref  thing,
dbref  from,
BOOLEXP b 
)

Evaluate a boolean expression.

Parameters
playerDBref of player
thingDBref of thing
fromDBref from
bBoolean expression
Returns
bool

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

◆ eval_boolexp_atr()

bool eval_boolexp_atr ( dbref  player,
dbref  thing,
dbref  from,
char *  key 
)

Evaluate attribute's boolean expression.

Parameters
playerDBref of player
thingDBref of thing
fromDBref from
keyAttribute's key
Returns
bool

◆ free_boolexp()

void free_boolexp ( BOOLEXP b)

Free a BOOLEXP item.

Parameters
bBOOLEXP item.

◆ parse_boolexp()

BOOLEXP * parse_boolexp ( dbref  player,
const char *  buf,
bool  internal 
)

Parse a boolean expression.

Parameters
playerDBref of player
bufAttribute buffer
internalInternal check?
Returns
BOOLEXP* Boolean expression result

◆ parse_boolexp_E()

BOOLEXP * parse_boolexp_E ( char **  pBuf,
dbref  parse_player,
bool  parsing_internal 
)

E -> T; E -> T | E.

Parameters
pBufAttribute buffer
parse_playerDBref of player
parsing_internalEngine or player triggered?
Returns
BOOLEXP* Boolean expression result

◆ parse_boolexp_F()

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

Parameters
pBufAttribute buffer
parse_playerDBref of player
parsing_internalEngine or player triggered?
Returns
BOOLEXP* Boolean expression result

◆ parse_boolexp_L()

BOOLEXP * parse_boolexp_L ( char **  pBuf,
dbref  parse_player,
bool  parsing_internal 
)

L -> (E); L -> object identifier.

Parameters
pBufAttribute buffer
parse_playerDBref of player
parsing_internalEngine or player triggered?
Returns
BOOLEXP* Boolean expression result

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.

◆ parse_boolexp_T()

BOOLEXP * parse_boolexp_T ( char **  pBuf,
dbref  parse_player,
bool  parsing_internal 
)

T -> F; T -> F & T.

Parameters
pBufAttribute buffer
parse_playerDBref of player
parsing_internalEngine or player triggered?
Returns
BOOLEXP* Boolean expression result

◆ skip_whitespace()

void skip_whitespace ( char **  pBuf)

Skip over whitespace in a string.

Attention
If the parser returns TRUE_BOOLEXP, you lose TRUE_BOOLEXP cannot be typed in by the user; use @unlock instead
Parameters
pBufBuffer to skip whitespace in

◆ test_atr()

BOOLEXP * test_atr ( char *  s,
dbref  parse_player 
)

Test attriutes.

Parameters
sAttribute to test
parse_playerDBref of player triggering the test
Returns
BOOLEXP* Boolean expression with the result of 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