From 5c63b08d26cf167bfe8ef1a52f6e6f1dd0746a83 Mon Sep 17 00:00:00 2001 From: cuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81> Date: Mon, 29 Mar 2004 15:58:34 +0000 Subject: [PATCH] New feature missing_char_term git-svn-id: svn://svn.cc65.org/cc65/trunk@2964 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- doc/ca65.sgml | 12 +++++++++++- src/ca65/feature.c | 10 ++++++---- src/ca65/feature.h | 9 +++++---- src/ca65/global.c | 1 + src/ca65/global.h | 1 + src/ca65/scanner.c | 14 ++++++++------ 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index debbc4cd0..72679f323 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -908,7 +908,7 @@ if you want to access the "other" symbol <tt/bar/, you would have to write: .endscope </verb></tscreen> - + <sect>Address sizes<label id="address-sizes"><p> @@ -2075,6 +2075,16 @@ Here's a list of all control commands and a description, what they do: removing the lines with the assignments may also be an option when porting code written for older assemblers). + <tag><tt>missing_char_term</tt></tag> + + Accept single quoted character constants where the terminating quote is + missing. + <tscreen><verb> + lda #'a + </verb></tscreen> + <bf/Note:/ This does not work in conjunction with <tt/.FEATURE + loose_string_term/, since in this case the input would be ambigous. + </descrip> It is also possible to specify features on the command line using the diff --git a/src/ca65/feature.c b/src/ca65/feature.c index b19c0a07d..3983270ec 100644 --- a/src/ca65/feature.c +++ b/src/ca65/feature.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2000-2003 Ullrich von Bassewitz */ +/* R�merstra�e 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -57,6 +57,7 @@ static const char* FeatureKeys[FEAT_COUNT] = { "dollar_in_identifiers", "leading_dot_in_identifiers", "pc_assignment", + "missing_char_term", }; @@ -107,6 +108,7 @@ feature_t SetFeature (const char* Key) case FEAT_DOLLAR_IN_IDENTIFIERS: DollarInIdents = 1; break; case FEAT_LEADING_DOT_IN_IDENTIFIERS: LeadingDotInIdents= 1; break; case FEAT_PC_ASSIGNMENT: PCAssignment = 1; break; + case FEAT_MISSING_CHAR_TERM: MissingCharTerm = 1; break; default: /* Keep gcc silent */ break; } diff --git a/src/ca65/feature.h b/src/ca65/feature.h index 2766396dc..df91e77f1 100644 --- a/src/ca65/feature.h +++ b/src/ca65/feature.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2000-2003 Ullrich von Bassewitz */ +/* R�merstra�e 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -54,6 +54,7 @@ typedef enum { FEAT_DOLLAR_IN_IDENTIFIERS, FEAT_LEADING_DOT_IN_IDENTIFIERS, FEAT_PC_ASSIGNMENT, + FEAT_MISSING_CHAR_TERM, /* Special value: Number of features available */ FEAT_COUNT diff --git a/src/ca65/global.c b/src/ca65/global.c index 8da92298f..f9d29bea9 100644 --- a/src/ca65/global.c +++ b/src/ca65/global.c @@ -74,6 +74,7 @@ unsigned char AtInIdents = 0; /* Allow '@' in identifiers */ unsigned char DollarInIdents = 0; /* Allow '$' in identifiers */ unsigned char LeadingDotInIdents = 0; /* Allow '.' to start an identifier */ unsigned char PCAssignment = 0; /* Allow "* = $XXX" or "$ = $XXX" */ +unsigned char MissingCharTerm = 0; /* Allow lda #'a (no closing term) */ /* Misc stuff */ const char Copyright[] = "(C) Copyright 1998-2004 Ullrich von Bassewitz"; diff --git a/src/ca65/global.h b/src/ca65/global.h index 68670ad9b..f75d12335 100644 --- a/src/ca65/global.h +++ b/src/ca65/global.h @@ -71,6 +71,7 @@ extern unsigned char AtInIdents; /* Allow '@' in identifiers */ extern unsigned char DollarInIdents; /* Allow '$' in identifiers */ extern unsigned char LeadingDotInIdents; /* Allow '.' to start an identifier */ extern unsigned char PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */ +extern unsigned char MissingCharTerm; /* Allow lda #'a (no closing term) */ /* Misc stuff */ extern const char Copyright[]; /* Copyright string */ diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index c33edcb38..6c0e06d9c 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2003 Ullrich von Bassewitz */ +/* (C) 1998-2004 Ullrich von Bassewitz */ /* R�merstra�e 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -469,8 +469,8 @@ static void NextChar (void) /* End of current line reached, read next line */ if (fgets (IFile->Line, sizeof (IFile->Line), IFile->F) == 0) { /* End of file. Add an empty line to the listing. This is a - * small hack needed to keep the PC output in sync. - */ + * small hack needed to keep the PC output in sync. + */ NewListingLine ("", IFile->Pos.Name, ICount); C = EOF; return; @@ -617,7 +617,7 @@ static unsigned ReadStringConst (int StringTerm) /* Return the length of the string */ return I; -} +} @@ -1043,7 +1043,7 @@ CharAgain: } else { /* Always a character constant */ NextChar (); - if (C == '\n' || C == EOF) { + if (C == EOF || IsControl (C)) { Error ("Illegal character constant"); goto CharAgain; } @@ -1051,7 +1051,9 @@ CharAgain: Tok = TOK_CHARCON; NextChar (); if (C != '\'') { - Error ("Illegal character constant"); + if (!MissingCharTerm) { + Error ("Illegal character constant"); + } } else { NextChar (); }