Hi,
I like the idea of using std=c99 to disable. I believe this is how
gcc/clang handle it. But ultimately I don't mind too much. gcc/clang use
the switch "-fdollars-in-identifiers" (I've attached a modified patch)
although in almost all cases it is enabled by default so they also
provide "-fno-dollars-in-identifiers".
https://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html
I'm mainly interested in this change because I'm working on a new
version of my 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 . But I can also put together some
test cases using it in the various ways (variable, function, macro,
define, etc) so make sure it is completely covered.
Thanks,
Dan
On 11/04/2015 10:00, Thomas Preud'homme wrote:
Le samedi 11 avril 2015, 06:14:04 Sergey Korshunoff a écrit :
Hi! A modified version of the patch is attached.
Looks good at quick look. I'm not sure about the switch, we already accept
some gnu extension without any switch for that. Or maybe introduce a more
general switch for all C extensions. You could enable it by default en disable
it if std=c99 for instance?
Best regards,
Thomas
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
diff -urN tinycc.old/libtcc.c tinycc/libtcc.c
--- tinycc.old/libtcc.c 2015-04-10 23:43:55.000000000 +0300
+++ tinycc/libtcc.c 2015-04-11 06:08:03.000000000 +0300
@@ -1479,6 +1479,7 @@
{ 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 -urN tinycc.old/tcc-doc.texi tinycc/tcc-doc.texi
--- tinycc.old/tcc-doc.texi 2015-04-10 06:30:35.000000000 +0300
+++ tinycc/tcc-doc.texi 2015-04-11 06:10:22.000000000 +0300
@@ -241,6 +241,9 @@
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 -urN tinycc.old/tcc.h tinycc/tcc.h
--- tinycc.old/tcc.h 2015-04-10 23:43:55.000000000 +0300
+++ tinycc/tcc.h 2015-04-11 06:09:01.000000000 +0300
@@ -605,6 +605,7 @@
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 -urN tinycc.old/tccpp.c tinycc/tccpp.c
--- tinycc.old/tccpp.c 2015-04-10 16:53:03.000000000 +0300
+++ tinycc/tccpp.c 2015-04-11 06:06:42.000000000 +0300
@@ -2286,7 +2286,10 @@
}
}
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 @@
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 @@
/* 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) {
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel