polserver/pol-core/bscript/operator.h
Eric Swanson 36d8603666 Add elvis operator:
a ?: b

Evaluates to a if a is true (not: false, 0, undefined, etc)
Otherwise evaluates to b

Short-circuit evaluation
2020-04-29 02:50:11 -07:00

49 lines
707 B
C++

/** @file
*
* @par History
*/
#ifndef __OPERATOR_H
#define __OPERATOR_H
#include "tokens.h"
namespace Pol
{
namespace Bscript
{
enum Precedence
{
PREC_PAREN = 14,
PREC_UNARY_OPS = 13,
PREC_MULT = 12,
PREC_PLUS = 11,
PREC_ELVIS = 10,
PREC_LESSTHAN = 9,
PREC_BSLEFT = 8,
PREC_BSRIGHT = 8,
PREC_BITAND = 8,
PREC_BITXOR = 7,
PREC_BITOR = 6,
PREC_EQUALTO = 5,
PREC_LOGAND = 4,
PREC_LOGOR = 3,
PREC_ASSIGN = 1,
PREC_COMMA = 0,
PREC_DEPRECATED = 0,
PREC_TERMINATOR = -1
};
typedef struct
{
char code[16];
BTokenId id;
Precedence precedence;
BTokenType type;
bool ambig; // if true, part of it matches part of another
bool deprecated;
} Operator;
}
}
#endif