From d27cd624654cdb2dd1191b85acd41e731a4a4a98 Mon Sep 17 00:00:00 2001 From: cuz Date: Sat, 2 Sep 2000 12:01:40 +0000 Subject: [PATCH] Added new emulation feature: loose_char_term git-svn-id: svn://svn.cc65.org/cc65/trunk@316 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/expr.c | 9 +++++++-- src/ca65/feature.c | 4 +++- src/ca65/feature.h | 3 ++- src/ca65/global.c | 1 + src/ca65/global.h | 1 + src/ca65/scanner.c | 1 + 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ca65/expr.c b/src/ca65/expr.c index 0675a8c7b..4ada4317a 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -609,8 +609,13 @@ static ExprNode* Factor (void) break; default: - N = LiteralExpr (0); /* Dummy */ - Error (ERR_SYNTAX); + if (LooseCharTerm && Tok == TOK_STRCON && strlen(SVal) == 1) { + /* A character constant */ + N = LiteralExpr (TgtTranslateChar (SVal[0])); + } else { + N = LiteralExpr (0); /* Dummy */ + Error (ERR_SYNTAX); + } NextTok (); break; } diff --git a/src/ca65/feature.c b/src/ca65/feature.c index 71f5f055b..3059757b5 100644 --- a/src/ca65/feature.c +++ b/src/ca65/feature.c @@ -52,6 +52,7 @@ static const char* FeatureKeys[FEAT_COUNT] = { "dollar_is_pc", "labels_without_colons", "loose_string_term", + "loose_char_term", "at_in_identifiers", "dollar_in_identifiers", "pc_assignment", @@ -100,11 +101,12 @@ feature_t SetFeature (const char* Key) case FEAT_DOLLAR_IS_PC: DollarIsPC = 1; break; case FEAT_LABELS_WITHOUT_COLONS: NoColonLabels = 1; break; case FEAT_LOOSE_STRING_TERM: LooseStringTerm= 1; break; + case FEAT_LOOSE_CHAR_TERM: LooseCharTerm = 1; break; case FEAT_AT_IN_IDENTIFIERS: AtInIdents = 1; break; case FEAT_DOLLAR_IN_IDENTIFIERS: DollarInIdents = 1; break; case FEAT_PC_ASSIGNMENT: PCAssignment = 1; break; default: /* Keep gcc silent */ break; - } + } /* Return the value found */ return Feature; diff --git a/src/ca65/feature.h b/src/ca65/feature.h index c366cd9d7..2f46cfc77 100644 --- a/src/ca65/feature.h +++ b/src/ca65/feature.h @@ -49,10 +49,11 @@ typedef enum { FEAT_DOLLAR_IS_PC, FEAT_LABELS_WITHOUT_COLONS, FEAT_LOOSE_STRING_TERM, + FEAT_LOOSE_CHAR_TERM, FEAT_AT_IN_IDENTIFIERS, FEAT_DOLLAR_IN_IDENTIFIERS, FEAT_PC_ASSIGNMENT, - + /* Special value: Number of features available */ FEAT_COUNT } feature_t; diff --git a/src/ca65/global.c b/src/ca65/global.c index ac3227d80..0bd7a54ee 100644 --- a/src/ca65/global.c +++ b/src/ca65/global.c @@ -66,6 +66,7 @@ unsigned char LineCont = 0; /* Allow line continuation */ unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */ unsigned char NoColonLabels = 0; /* Allow labels without a colon */ unsigned char LooseStringTerm = 0; /* Allow ' as string terminator */ +unsigned char LooseCharTerm = 0; /* Allow " for char constants */ unsigned char AtInIdents = 0; /* Allow '@' in identifiers */ unsigned char DollarInIdents = 0; /* Allow '$' in identifiers */ unsigned char PCAssignment = 0; /* Allow "* = $XXX" or "$ = $XXX" */ diff --git a/src/ca65/global.h b/src/ca65/global.h index 759202122..7288bb61c 100644 --- a/src/ca65/global.h +++ b/src/ca65/global.h @@ -67,6 +67,7 @@ extern unsigned char LineCont; /* Allow line continuation */ extern unsigned char DollarIsPC; /* Allow the $ symbol as current PC */ extern unsigned char NoColonLabels; /* Allow labels without a colon */ extern unsigned char LooseStringTerm;/* Allow ' as string terminator */ +extern unsigned char LooseCharTerm; /* Allow " for char constants */ extern unsigned char AtInIdents; /* Allow '@' in identifiers */ extern unsigned char DollarInIdents; /* Allow '$' in identifiers */ extern unsigned char PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */ diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 69733a3cd..fb5212a3c 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -128,6 +128,7 @@ struct DotKeyword { { "BITXOR", TOK_XOR }, { "BLANK", TOK_BLANK }, { "BSS", TOK_BSS }, + { "BYT", TOK_BYTE }, { "BYTE", TOK_BYTE }, { "CASE", TOK_CASE }, { "CODE", TOK_CODE }, -- 2.39.5