}
/* Define the symbol */
- SymDef (SymName, GenLiteralExpr (Val), 0, 0);
+ SymDef (SymName, GenLiteralExpr (Val), SYM_DEFAULT);
}
/* If a colon follows, this is a label definition. If there
* is no colon, it's an assignment.
*/
- if (Tok == TOK_EQ) {
+ if (Tok == TOK_EQ || Tok == TOK_ASSIGN) {
+ /* If it's an assign token, we have a label */
+ unsigned Flags = (Tok == TOK_ASSIGN)? SYM_LABEL : SYM_DEFAULT;
/* Skip the '=' */
NextTok ();
/* Define the symbol with the expression following the '=' */
- SymDef (Ident, Expression(), 0, 0);
+ SymDef (Ident, Expression(), Flags);
/* Don't allow anything after a symbol definition */
Done = 1;
} else {
+ /* Define the symbol flags */
+ unsigned Flags = IsZPSeg ()? SYM_ZP | SYM_LABEL : SYM_LABEL;
/* Define a label */
- SymDef (Ident, GenCurrentPC(), IsZPSeg(), 1);
+ SymDef (Ident, GenCurrentPC (), Flags);
/* Skip the colon. If NoColonLabels is enabled, allow labels
* without a colon if there is no whitespace before the
* identifier.
{
if (Tok == TOK_IDENT) {
/* The new scope has a name */
- SymDef (SVal, GenCurrentPC (), IsZPSeg (), 1);
+ unsigned Flags = SYM_LABEL;
+ if (IsZPSeg ()) {
+ Flags |= SYM_ZP;
+ }
+ SymDef (SVal, GenCurrentPC (), Flags);
NextTok ();
}
SymEnterLevel ();
+static void DoStruct (void)
+/* Struct definition */
+{
+ Error (ERR_NOT_IMPLEMENTED);
+}
+
+
+
static void DoSunPlus (void)
/* Switch to the SUNPLUS CPU */
{
+static void DoUnion (void)
+/* Union definition */
+{
+ Error (ERR_NOT_IMPLEMENTED);
+}
+
+
+
static void DoUnexpected (void)
/* Got an unexpected keyword */
{
{ ccNone, DoUnexpected }, /* .ENDMACRO */
{ ccNone, DoEndProc },
{ ccNone, DoUnexpected }, /* .ENDREPEAT */
+ { ccNone, DoUnexpected }, /* .ENDSTRUCT */
{ ccNone, DoError },
{ ccNone, DoExitMacro },
{ ccNone, DoExport },
{ ccNone, DoUnexpected }, /* .STRAT */
{ ccNone, DoUnexpected }, /* .STRING */
{ ccNone, DoUnexpected }, /* .STRLEN */
+ { ccNone, DoStruct },
{ ccNone, DoSunPlus },
+ { ccNone, DoUnexpected }, /* .TAG */
{ ccNone, DoUnexpected }, /* .TCOUNT */
{ ccNone, DoUnexpected }, /* .TIME */
+ { ccNone, DoUnion },
{ ccNone, DoUnexpected }, /* .VERSION */
{ ccNone, DoWarning },
{ ccNone, DoWord },
{ ".ENDPROC", TOK_ENDPROC },
{ ".ENDREP", TOK_ENDREP },
{ ".ENDREPEAT", TOK_ENDREP },
+ { ".ENDSTRUCT", TOK_ENDSTRUCT },
{ ".ERROR", TOK_ERROR },
{ ".EXITMAC", TOK_EXITMACRO },
{ ".EXITMACRO", TOK_EXITMACRO },
{ ".STRAT", TOK_STRAT },
{ ".STRING", TOK_STRING },
{ ".STRLEN", TOK_STRLEN },
+ { ".STRUCT", TOK_STRUCT },
{ ".SUNPLUS", TOK_SUNPLUS },
+ { ".TAG", TOK_TAG },
{ ".TCOUNT", TOK_TCOUNT },
{ ".TIME", TOK_TIME },
+ { ".UNION", TOK_UNION },
{ ".VERSION", TOK_VERSION },
{ ".WARNING", TOK_WARNING },
{ ".WORD", TOK_WORD },
Tok = TOK_ULABEL;
break;
+ case '=':
+ NextChar ();
+ Tok = TOK_ASSIGN;
+ break;
+
default:
Tok = TOK_COLON;
break;
TOK_MNEMO, /* A mnemonic */
TOK_INTCON, /* Integer constant */
- TOK_CHARCON, /* Character constant */
- TOK_STRCON, /* String constant */
-
- TOK_A, /* A)ccu */
- TOK_X, /* X register */
- TOK_Y, /* Y register */
- TOK_S, /* S register */
-
- TOK_ULABEL, /* :++ or :-- */
-
- TOK_EQ, /* = */
- TOK_NE, /* <> */
- TOK_LT, /* < */
- TOK_GT, /* > */
- TOK_LE, /* <= */
- TOK_GE, /* >= */
-
- TOK_BAND, /* .and */
- TOK_BOR, /* .or */
- TOK_BXOR, /* .xor */
- TOK_BNOT, /* .not */
-
- TOK_PLUS, /* + */
- TOK_MINUS, /* - */
+ TOK_CHARCON, /* Character constant */
+ TOK_STRCON, /* String constant */
+
+ TOK_A, /* A)ccu */
+ TOK_X, /* X register */
+ TOK_Y, /* Y register */
+ TOK_S, /* S register */
+
+ TOK_ASSIGN, /* := */
+ TOK_ULABEL, /* :++ or :-- */
+
+ TOK_EQ, /* = */
+ TOK_NE, /* <> */
+ TOK_LT, /* < */
+ TOK_GT, /* > */
+ TOK_LE, /* <= */
+ TOK_GE, /* >= */
+
+ TOK_BAND, /* .and */
+ TOK_BOR, /* .or */
+ TOK_BXOR, /* .xor */
+ TOK_BNOT, /* .not */
+
+ TOK_PLUS, /* + */
+ TOK_MINUS, /* - */
TOK_MUL, /* * */
TOK_STAR = TOK_MUL, /* Alias */
- TOK_DIV, /* / */
- TOK_MOD, /* ! */
- TOK_OR, /* | */
- TOK_XOR, /* ^ */
- TOK_AND, /* & */
- TOK_SHL, /* << */
- TOK_SHR, /* >> */
- TOK_NOT, /* ~ */
-
- TOK_PC, /* $ if enabled */
+ TOK_DIV, /* / */
+ TOK_MOD, /* ! */
+ TOK_OR, /* | */
+ TOK_XOR, /* ^ */
+ TOK_AND, /* & */
+ TOK_SHL, /* << */
+ TOK_SHR, /* >> */
+ TOK_NOT, /* ~ */
+
+ TOK_PC, /* $ if enabled */
TOK_NAMESPACE, /* :: */
- TOK_DOT, /* . */
- TOK_COMMA, /* , */
- TOK_HASH, /* # */
- TOK_COLON, /* : */
- TOK_LPAREN, /* ( */
- TOK_RPAREN, /* ) */
- TOK_LBRACK, /* [ */
- TOK_RBRACK, /* ] */
+ TOK_DOT, /* . */
+ TOK_COMMA, /* , */
+ TOK_HASH, /* # */
+ TOK_COLON, /* : */
+ TOK_LPAREN, /* ( */
+ TOK_RPAREN, /* ) */
+ TOK_LBRACK, /* [ */
+ TOK_RBRACK, /* ] */
TOK_OVERRIDE_ZP, /* z: */
TOK_OVERRIDE_ABS, /* a: */
TOK_OVERRIDE_FAR, /* f: */
- TOK_MACPARAM, /* Macro parameter, not generated by scanner */
+ TOK_MACPARAM, /* Macro parameter, not generated by scanner */
TOK_REPCOUNTER, /* Repeat counter, not generated by scanner */
/* The next ones are tokens for the pseudo instructions. Keep together! */
TOK_ENDMACRO,
TOK_ENDPROC,
TOK_ENDREP,
+ TOK_ENDSTRUCT,
TOK_ERROR,
TOK_EXITMACRO,
TOK_EXPORT,
TOK_STRAT,
TOK_STRING,
TOK_STRLEN,
+ TOK_STRUCT,
TOK_SUNPLUS,
+ TOK_TAG,
TOK_TCOUNT,
TOK_TIME,
+ TOK_UNION,
TOK_VERSION,
TOK_WARNING,
TOK_WORD,
TOK_ZEROPAGE,
TOK_LASTPSEUDO = TOK_ZEROPAGE,
- TOK_COUNT /* Count of tokens */
+ TOK_COUNT /* Count of tokens */
};
-void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label)
+void SymDef (const char* Name, ExprNode* Expr, unsigned Flags)
/* Define a new symbol */
{
/* Do we have such a symbol? */
S->V.Expr = Expr;
}
S->Flags |= SF_DEFINED;
- if (ZP) {
+ if (Flags & SYM_ZP) {
S->Flags |= SF_ZP;
}
- if (Label) {
+ if (Flags & SYM_LABEL) {
S->Flags |= SF_LABEL;
}
#define SCOPE_GLOBAL 1
#define SCOPE_LOCAL 2
+/* Flags used in SymDef */
+#define SYM_DEFAULT 0x00
+#define SYM_ZP 0x01
+#define SYM_LABEL 0x02
+
/*****************************************************************************/
int SymIsLocalLevel (void);
/* Return true if we are on a local symbol table level. */
-void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label);
+void SymDef (const char* Name, ExprNode* Expr, unsigned Flags);
/* Define a new symbol */
SymEntry* SymRef (const char* Name, int Scope);