• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Révisionb96ebd7ef928b82e9c4cf1d943cc002c25c3ca7e (tree)
l'heure2009-06-13 05:56:12
AuteurAndroid (Google) Code Review <android-gerrit@goog...>
CommiterAndroid (Google) Code Review

Message de Log

Merge change 4092

* changes:

Reserve all C99 keywords.

Change Summary

Modification

--- a/libacc/acc.cpp
+++ b/libacc/acc.cpp
@@ -1502,6 +1502,41 @@ class Compiler : public ErrorSink {
15021502 // be able to have symbols named pragma or define.
15031503 put("pragma", TOK_PRAGMA);
15041504 put("define", TOK_DEFINE);
1505+
1506+ const char* unsupported[] = {
1507+ "auto",
1508+ "case",
1509+ "const",
1510+ "continue",
1511+ "default",
1512+ "do",
1513+ "double",
1514+ "enum",
1515+ "extern",
1516+ "float",
1517+ "goto",
1518+ "long",
1519+ "register",
1520+ "short",
1521+ "signed",
1522+ "sizeof",
1523+ "static",
1524+ "struct",
1525+ "switch",
1526+ "typedef",
1527+ "union",
1528+ "unsigned",
1529+ "volatile",
1530+ "_Bool",
1531+ "_Complex",
1532+ "_Imaginary",
1533+ "inline",
1534+ "restrict",
1535+ 0};
1536+
1537+ for(int i = 0; unsupported[i]; i++) {
1538+ put(unsupported[i], TOK_UNSUPPORTED_KEYWORD);
1539+ }
15051540 }
15061541
15071542 ~KeywordTable() {
@@ -1773,6 +1808,7 @@ class Compiler : public ErrorSink {
17731808 static const int TOK_FOR = TOK_KEYWORD + 8;
17741809 static const int TOK_PRAGMA = TOK_KEYWORD + 9;
17751810 static const int TOK_DEFINE = TOK_KEYWORD + 10;
1811+ static const int TOK_UNSUPPORTED_KEYWORD = TOK_KEYWORD + 0xff;
17761812
17771813 static const int TOK_UNDEFINED_SYMBOL = 0x200;
17781814
@@ -2463,12 +2499,6 @@ class Compiler : public ErrorSink {
24632499 }
24642500 }
24652501
2466- void checkSymbol() {
2467- if (tok < TOK_SYMBOL) {
2468- error("Expected a symbol");
2469- }
2470- }
2471-
24722502 void addGlobalSymbol() {
24732503 tok = (intptr_t) mSymbolTable.addGlobal(
24742504 new String(mTokenString));
@@ -2494,10 +2524,12 @@ class Compiler : public ErrorSink {
24942524 while (acceptType(base)) {
24952525 while (tok != ';' && tok != EOF) {
24962526 Type t = acceptPointerDeclaration(t);
2497- addLocalSymbol();
2498- if (tok) {
2499- loc = loc + 4;
2500- *(int *) tok = -loc;
2527+ if (checkSymbol()) {
2528+ addLocalSymbol();
2529+ if (tok) {
2530+ loc = loc + 4;
2531+ *(int *) tok = -loc;
2532+ }
25012533 }
25022534 next();
25032535 if (tok == ',')
@@ -2507,11 +2539,37 @@ class Compiler : public ErrorSink {
25072539 }
25082540 }
25092541
2542+ bool checkSymbol() {
2543+ bool result = isSymbol();
2544+ if (!result) {
2545+ String temp;
2546+ if (tok >= 0 && tok < 256) {
2547+ temp.printf("char \'%c\'", tok);
2548+ } else if (tok >= TOK_KEYWORD && tok < TOK_UNSUPPORTED_KEYWORD) {
2549+ temp.printf("keyword \"%s\"", mTokenString.getUnwrapped());
2550+ } else {
2551+ temp.printf("reserved keyword \"%s\"",
2552+ mTokenString.getUnwrapped());
2553+ }
2554+ error("Expected symbol. Got %s", temp.getUnwrapped());
2555+ }
2556+ return result;
2557+ }
2558+
2559+ /* Is a possibly undefined symbol */
2560+ bool isSymbol() {
2561+ return tok < EOF || tok >= TOK_UNDEFINED_SYMBOL;
2562+ }
2563+
25102564 void globalDeclarations() {
25112565 while (tok != EOF) {
25122566 Type base;
25132567 expectType(base);
25142568 Type t = acceptPointerDeclaration(t);
2569+ if (tok >= 0 && tok < TOK_UNDEFINED_SYMBOL) {
2570+ error("Unexpected token %d", tok);
2571+ break;
2572+ }
25152573 if (tok == TOK_UNDEFINED_SYMBOL) {
25162574 addGlobalSymbol();
25172575 }
@@ -2553,11 +2611,13 @@ class Compiler : public ErrorSink {
25532611 Type aType;
25542612 expectType(aType);
25552613 aType = acceptPointerDeclaration(aType);
2556- addLocalSymbol();
2557- if (tok) {
2558- /* read param name and compute offset */
2559- *(int *) tok = a;
2560- a = a + 4;
2614+ if (checkSymbol()) {
2615+ addLocalSymbol();
2616+ if (tok) {
2617+ /* read param name and compute offset */
2618+ *(int *) tok = a;
2619+ a = a + 4;
2620+ }
25612621 }
25622622 next();
25632623 if (tok == ',')