aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-04-12 15:32:03 +0300
committerseyko <seyko2@gmail.com>2015-04-12 15:32:03 +0300
commitdcb36587b5950b000f536e374eeed3787937db27 (patch)
tree76b2fa0585760edeaa4eef1495daaa9335b5efff
parente8ad336ac5c05dc1bb747b621dbf504fe3d26ca0 (diff)
downloadtinycc-dcb36587b5950b000f536e374eeed3787937db27.tar.gz
tinycc-dcb36587b5950b000f536e374eeed3787937db27.tar.bz2
-fdollar-in-identifiers switch which enables '$' in identifiers
library Cello: http://libcello.org/ which uses `$` and several variations of as macros. There is also RayLanguage which also uses it as a macro for a kind of ObjC style message passing: https://github.com/kojiba/RayLanguage This is a patch from Daniel Holden.
-rw-r--r--libtcc.c1
-rw-r--r--tcc-doc.texi3
-rw-r--r--tcc.h1
-rw-r--r--tccpp.c12
4 files changed, 13 insertions, 4 deletions
diff --git a/libtcc.c b/libtcc.c
index bc784e7..e7d04fe 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1482,6 +1482,7 @@ static const FlagDef flag_defs[] = {
{ offsetof(TCCState, leading_underscore), 0, "leading-underscore" },
{ offsetof(TCCState, ms_extensions), 0, "ms-extensions" },
{ offsetof(TCCState, old_struct_init_code), 0, "old-struct-init-code" },
+ { offsetof(TCCState, dollars_in_identifiers), 0, "dollars-in-identifiers" },
};
/* set/reset a flag */
diff --git a/tcc-doc.texi b/tcc-doc.texi
index 909af72..a8849f0 100644
--- a/tcc-doc.texi
+++ b/tcc-doc.texi
@@ -241,6 +241,9 @@ Allow a MS C compiler extensions to the language. Curretly this
assume a nested named structure declaration without identifier behave
like an unnamed one.
+@item -fdollars-in-identifiers
+Allow a dollars in identifiers
+
@end table
Warning options:
diff --git a/tcc.h b/tcc.h
index d61b5b7..c5678a8 100644
--- a/tcc.h
+++ b/tcc.h
@@ -605,6 +605,7 @@ struct TCCState {
int ms_extensions; /* allow nested named struct w/o identifier behave like unnamed */
int old_struct_init_code; /* use old algorithm to init array in struct when there is no '{' used.
Liuux 2.4.26 can't find initrd when compiled with a new algorithm */
+ int dollars_in_identifiers; /* allows '$' char in indentifiers */
/* warning switches */
int warn_write_strings;
diff --git a/tccpp.c b/tccpp.c
index f38e41a..111ea2b 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -2286,7 +2286,10 @@ maybe_newline:
}
}
break;
-
+
+ /* treat $ as allowed char in indentifier */
+ case '$': if (!tcc_state->dollars_in_identifiers) goto parse_simple;
+
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l':
@@ -2589,8 +2592,8 @@ maybe_newline:
case ':':
case '?':
case '~':
- case '$': /* only used in assembler */
- case '@': /* dito */
+ case '@': /* only used in assembler */
+ parse_simple:
tok = c;
p++;
break;
@@ -3174,7 +3177,8 @@ ST_FUNC void preprocess_new(void)
/* init isid table */
for(i=CH_EOF;i<256;i++)
- isidnum_table[i-CH_EOF] = isid(i) || isnum(i);
+ isidnum_table[i-CH_EOF] = (isid(i) || isnum(i) ||
+ (tcc_state->dollars_in_identifiers ? i == '$' : 0));
/* add all tokens */
if (table_ident) {