2024-01-03 00:43:12 +00:00
|
|
|
%{
|
2024-01-03 16:58:44 +00:00
|
|
|
#define DEFINE_EXTERNS
|
2024-01-03 00:43:12 +00:00
|
|
|
#include "griddleDefs.h"
|
2024-01-03 16:58:44 +00:00
|
|
|
#define YYSTYPE intptr_t
|
2024-01-03 00:43:12 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
%token Name Number String BitString Rawline
|
|
|
|
%token INCLUDE DEFINE ENDDEFINE USE
|
|
|
|
%token AVAID BIN15 BIN31 BIT BYTE CHARACTER ENTITY FATWORD OBJID REGID
|
|
|
|
%token VARSTRING WORDS
|
|
|
|
|
|
|
|
%left A O R
|
|
|
|
%left OR
|
|
|
|
%left XOR
|
|
|
|
%left AND
|
|
|
|
%left ADD SUB
|
|
|
|
%left MUL DIV MOD
|
|
|
|
%right UMINUS NOT
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
statementList:
|
|
|
|
statement /* na */
|
|
|
|
| statementList statement /* na */
|
|
|
|
;
|
|
|
|
|
|
|
|
statement:
|
|
|
|
assignmentStatement /* na */
|
|
|
|
| includeStatement /* na */
|
|
|
|
| defineStatement /* na */
|
|
|
|
| objectUseStatement /* na */
|
|
|
|
| rawStatement /* na */
|
|
|
|
;
|
|
|
|
|
|
|
|
rawStatement:
|
|
|
|
Rawline
|
|
|
|
{
|
|
|
|
executeRawline($1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
assignmentStatement:
|
|
|
|
Name '=' expr
|
|
|
|
{
|
|
|
|
executeAssignment($1, $3);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
includeStatement:
|
|
|
|
INCLUDE String
|
|
|
|
{
|
|
|
|
executeInclude($2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
defineStatement:
|
|
|
|
DEFINE expr String fieldList ENDDEFINE
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
executeDefine($2, $3, $4);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| DEFINE expr String ENDDEFINE
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
executeDefine($2, $3, NULL);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
fieldList:
|
|
|
|
field
|
|
|
|
{
|
|
|
|
$$ = buildFieldList(NULL, $1);
|
|
|
|
}
|
|
|
|
| fieldList field
|
|
|
|
{
|
|
|
|
$$ = buildFieldList($1, $2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
field:
|
|
|
|
basicField
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
|
|
|
| '#' basicField
|
|
|
|
{
|
|
|
|
$$ = invisifyField($2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
basicField:
|
|
|
|
Name ':' fieldType
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildField($1, buildExprI(NUM_EXPR, 1), $3, NULL);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| Name '(' expr ')' ':' fieldType
|
|
|
|
{
|
|
|
|
$$ = buildField($1, $3, $6, NULL);
|
|
|
|
}
|
|
|
|
| Name ':' fieldType '=' exprList
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildField($1, buildExprI(NUM_EXPR, 1), $3, $5);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| Name '(' expr ')' ':' fieldType '=' exprList
|
|
|
|
{
|
|
|
|
$$ = buildField($1, $3, $6, $8);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
fieldType:
|
|
|
|
CHARACTER { $$ = (int) FIELD_CHARACTER; }
|
|
|
|
| BIN15 { $$ = (int) FIELD_BIN15; }
|
|
|
|
| BIN31 { $$ = (int) FIELD_BIN31; }
|
|
|
|
| BIT { $$ = (int) FIELD_BIT; }
|
|
|
|
| WORDS { $$ = (int) FIELD_WORDS; }
|
|
|
|
| REGID { $$ = (int) FIELD_REGID; }
|
|
|
|
| OBJID { $$ = (int) FIELD_OBJID; }
|
|
|
|
| AVAID { $$ = (int) FIELD_AVAID; }
|
|
|
|
| FATWORD { $$ = (int) FIELD_FATWORD; }
|
|
|
|
| ENTITY { $$ = (int) FIELD_ENTITY; }
|
|
|
|
| BYTE { $$ = (int) FIELD_BYTE; }
|
|
|
|
| VARSTRING { $$ = (int) FIELD_VARSTRING; }
|
|
|
|
;
|
|
|
|
|
|
|
|
objectUseStatement:
|
|
|
|
USE Name Name objectTail
|
|
|
|
{
|
|
|
|
executeUse($2, $3, $4);
|
|
|
|
}
|
|
|
|
| USE Name objectTail
|
|
|
|
{
|
|
|
|
executeUse($2, NULL, $3);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
objectTail:
|
|
|
|
'=' expr '{' properties '}'
|
|
|
|
{
|
|
|
|
$$ = buildObjectTail($2, $4);
|
|
|
|
}
|
|
|
|
| '{' properties '}'
|
|
|
|
{
|
|
|
|
$$ = buildObjectTail(NULL, $2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
properties:
|
|
|
|
property
|
|
|
|
{
|
|
|
|
$$ = buildPropertyList(NULL, $1);
|
|
|
|
}
|
|
|
|
| properties property
|
|
|
|
{
|
|
|
|
$$ = buildPropertyList($1, $2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
property:
|
|
|
|
Name ':' exprList
|
|
|
|
{
|
|
|
|
$$ = buildProperty($1, $3);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
exprList:
|
|
|
|
expr
|
|
|
|
{
|
|
|
|
$$ = buildExprList(NULL, $1);
|
|
|
|
}
|
|
|
|
| exprList ',' expr
|
|
|
|
{
|
|
|
|
$$ = buildExprList($1, $3);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
expr:
|
|
|
|
Name
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprP(ID_EXPR, $1);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| Number
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprI(NUM_EXPR, $1);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| String
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprP(STRING_EXPR, $1);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| BitString
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprP(BITSTRING_EXPR, $1);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| '(' expr ')'
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprP(EXPR_EXPR, $2);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| SUB expr %prec UMINUS
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprIP(UNOP_EXPR, UMINUS, $2);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| NOT expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprIP(UNOP_EXPR, NOT, $2);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| A expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprIP(UNOP_EXPR, A, $2);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| O expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprIP(UNOP_EXPR, O, $2);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| R expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprIP(UNOP_EXPR, R, $2);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| expr ADD expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprPIP(BIN_EXPR, $1, ADD, $3);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| expr SUB expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprPIP(BIN_EXPR, $1, SUB, $3);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| expr MUL expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprPIP(BIN_EXPR, $1, MUL, $3);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| expr DIV expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprPIP(BIN_EXPR, $1, DIV, $3);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| expr MOD expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprPIP(BIN_EXPR, $1, MOD, $3);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| expr AND expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprPIP(BIN_EXPR, $1, AND, $3);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| expr OR expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprPIP(BIN_EXPR, $1, OR, $3);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
| expr XOR expr
|
|
|
|
{
|
2024-01-03 16:58:44 +00:00
|
|
|
$$ = buildExprPIP(BIN_EXPR, $1, XOR, $3);
|
2024-01-03 00:43:12 +00:00
|
|
|
}
|
|
|
|
;
|