Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleaned up operator enumeration, put it into ranges, fixed data ops.
--HG--
branch : calculator-experiment
  • Loading branch information
icculus committed Feb 8, 2010
1 parent 963fd46 commit e7818ac
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions calculator.c
Expand Up @@ -53,17 +53,21 @@ static inline void Free(Context *ctx, void *ptr)

typedef enum Operator
{
OP_DEREF_ARRAY,
OP_CALLFUNC,
OP_DEREF_STRUCT,
OP_START_RANGE_UNARY_OPERATORS,
OP_POSTINCREMENT,
OP_POSTDECREMENT,
OP_COMMA,
OP_PREINCREMENT,
OP_PREDECREMENT,
OP_NEGATE,
OP_COMPLEMENT,
OP_NOT,
OP_END_RANGE_UNARY_OPERATORS,

OP_START_RANGE_BINARY_OPERATORS,
OP_DEREF_ARRAY,
OP_CALLFUNC,
OP_DEREF_STRUCT,
OP_COMMA,
OP_MULTIPLY,
OP_DIVIDE,
OP_MODULO,
Expand All @@ -82,7 +86,6 @@ typedef enum Operator
OP_BINARYOR,
OP_LOGICALAND,
OP_LOGICALOR,
OP_CONDITIONAL,
OP_ASSIGN,
OP_MULASSIGN,
OP_DIVASSIGN,
Expand All @@ -94,6 +97,18 @@ typedef enum Operator
OP_ANDASSIGN,
OP_XORASSIGN,
OP_ORASSIGN,
OP_END_RANGE_BINARY_OPERATORS,

OP_START_RANGE_TERNARY_OPERATORS,
OP_CONDITIONAL,
OP_END_RANGE_TERNARY_OPERATORS,

OP_START_RANGE_DATA,
OP_IDENTIFIER,
OP_INT_LITERAL,
OP_FLOAT_LITERAL,
OP_STRING_LITERAL,
OP_END_RANGE_DATA,
} Operator;

typedef struct Expression
Expand Down Expand Up @@ -128,25 +143,25 @@ typedef struct ExpressionTernary

typedef struct ExpressionIdentifier
{
Operator op; // Always TOKEN_CALC_IDENTIFIER
Operator op; // Always OP_IDENTIFIER
const char *identifier;
} ExpressionIdentifier;

typedef struct ExpressionLiteralInt
{
Operator op; // Always TOKEN_CALC_INT_CONSTANT
Operator op; // Always OP_INT_LITERAL
int64 value;
} ExpressionLiteralInt;

typedef struct ExpressionLiteralFloat
{
Operator op; // Always TOKEN_CALC_FLOAT_CONSTANT
Operator op; // Always OP_FLOAT_LITERAL
double value;
} ExpressionLiteralFloat;

typedef struct ExpressionLiteralString
{
Operator op; // Always TOKEN_CALC_STRING_LITERAL
Operator op; // Always OP_STRING_LITERAL
const char *string;
} ExpressionLiteralString;

Expand Down

0 comments on commit e7818ac

Please sign in to comment.