#include <string.h>
/* common */
+#include "segdefs.h"
#include "tgttrans.h"
/* cc65 */
#include "litpool.h"
#include "scanner.h"
#include "scanstrbuf.h"
-#include "segments.h"
#include "symtab.h"
#include "pragma.h"
} else {
Error ("String literal expected");
- }
+ }
/* Call the string buf destructor */
DoneStrBuf (&S);
static void CharMapPragma (StrBuf* B)
/* Change the character map */
{
- unsigned Index, C;
-
- ExprDesc Val;
+ long Index, C;
/* Read the character index */
- ConstIntExpr (&Val);
- if (Val.ConstVal < 1 || Val.ConstVal > 255) {
- Error ("Character index out of range");
- Index = 'A';
- } else {
- Index = Val.ConstVal;
+ if (!SB_GetNumber (B, &Index)) {
+ return;
+ }
+ if (Index < 1 || Index > 255) {
+ Error ("Character index out of range");
+ return;
}
/* Comma follows */
- ConsumeComma ();
+ SB_SkipWhite (B);
+ if (SB_Get (B) != ',') {
+ Error ("Comma expected");
+ return;
+ }
+ SB_SkipWhite (B);
/* Read the character code */
- ConstIntExpr (&Val);
- if (Val.ConstVal < 1 || Val.ConstVal > 255) {
+ if (!SB_GetNumber (B, &C)) {
+ return;
+ }
+ if (C < 1 || C > 255) {
Error ("Character code out of range");
- C = 'A';
- } else {
- C = Val.ConstVal;
+ return;
}
/* Remap the character */
- TgtTranslateSet (Index, C);
+ TgtTranslateSet ((unsigned) Index, (unsigned char) C);
}
/* Handle a pragma that expects a boolean paramater */
{
ident Ident;
+ long Val;
- if (SB_Peek (B) == '0') {
- SB_Skip (B);
- *Flag = 0;
- } else if (SB_Peek (B) == '1') {
- SB_Skip (B);
- *Flag = 1;
- } else if (SB_GetSym (B, Ident)) {
+ if (SB_GetSym (B, Ident)) {
if (strcmp (Ident, "true") == 0 || strcmp (Ident, "on") == 0) {
*Flag = 1;
} else if (strcmp (Ident, "false") == 0 || strcmp (Ident, "off") == 0) {
} else {
Error ("Pragma argument must be one of `on', `off', `true' or `false'");
}
+ } else if (SB_GetNumber (B, &Val)) {
+ *Flag = (Val != 0);
} else {
Error ("Invalid pragma argument");
}
Error ("')' expected");
return;
}
+ SB_SkipWhite (&B);
+
+ /* Allow an optional semicolon to be compatible with the old syntax */
+ if (SB_Peek (&B) == ';') {
+ SB_Skip (&B);
+ SB_SkipWhite (&B);
+ }
/* Make sure nothing follows */
- SB_SkipWhite (&B);
if (SB_Peek (&B) != '\0') {
Error ("Unexpected input following pragma directive");
}