History

-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.

seyko committed 11 years ago

Commit dcb36581 parent e8ad3364 files · +13 −4Browse files

Unified · Split

4 files
  1. libtcc.c +1 −0
  2. tcc-doc.texi +3 −0
  3. tcc.h +1 −0
  4. tccpp.c +8 −4
libtcc.c+1−0
@@ -1482,6 +1482,7 @@ static const FlagDef flag_defs[] = { · 1481 unmodified lines
14821482 { offsetof(TCCState, leading_underscore), 0, "leading-underscore" },
14831483 { offsetof(TCCState, ms_extensions), 0, "ms-extensions" },
14841484 { offsetof(TCCState, old_struct_init_code), 0, "old-struct-init-code" },
1485+ { offsetof(TCCState, dollars_in_identifiers), 0, "dollars-in-identifiers" },
14851486 };
14861487
14871488 /* set/reset a flag */
tcc-doc.texi+3−0
@@ -241,6 +241,9 @@ Allow a MS C compiler extensions to the language. Curretly this · 240 unmodified lines
241241 assume a nested named structure declaration without identifier behave
242242 like an unnamed one.
243243
244+@item -fdollars-in-identifiers
245+Allow a dollars in identifiers
246+
244247 @end table
245248
246249 Warning options:
tcc.h+1−0
@@ -605,6 +605,7 @@ struct TCCState { · 604 unmodified lines
605605 int ms_extensions; /* allow nested named struct w/o identifier behave like unnamed */
606606 int old_struct_init_code; /* use old algorithm to init array in struct when there is no '{' used.
607607 Liuux 2.4.26 can't find initrd when compiled with a new algorithm */
608+ int dollars_in_identifiers; /* allows '$' char in indentifiers */
608609
609610 /* warning switches */
610611 int warn_write_strings;
tccpp.c+8−4
@@ -2286,7 +2286,10 @@ maybe_newline: · 2285 unmodified lines
22862286 }
22872287 }
22882288 break;
2289−
2289+
2290+ /* treat $ as allowed char in indentifier */
2291+ case '$': if (!tcc_state->dollars_in_identifiers) goto parse_simple;
2292+
22902293 case 'a': case 'b': case 'c': case 'd':
22912294 case 'e': case 'f': case 'g': case 'h':
22922295 case 'i': case 'j': case 'k': case 'l':
@@ -2589,8 +2592,8 @@ maybe_newline: · 296 unmodified lines
25892592 case ':':
25902593 case '?':
25912594 case '~':
2592− case '$': /* only used in assembler */
2593− case '@': /* dito */
2595+ case '@': /* only used in assembler */
2596+ parse_simple:
25942597 tok = c;
25952598 p++;
25962599 break;
@@ -3174,7 +3177,8 @@ ST_FUNC void preprocess_new(void) · 577 unmodified lines
31743177
31753178 /* init isid table */
31763179 for(i=CH_EOF;i<256;i++)
3177− isidnum_table[i-CH_EOF] = isid(i) || isnum(i);
3180+ isidnum_table[i-CH_EOF] = (isid(i) || isnum(i) ||
3181+ (tcc_state->dollars_in_identifiers ? i == '$' : 0));
31783182
31793183 /* add all tokens */
31803184 if (table_ident) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t