2008-09-09 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Tue, 9 Sep 2008 19:16:15 +0000 (19:16 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 9 Sep 2008 19:16:15 +0000 (19:16 -0000)
* skeleton.cs: A little refactoring to support producing a list of
tokens as opposed to a list of token strings for code that uses
the yyExpecting code.

svn path=/trunk/mcs/; revision=112612

mcs/jay/ChangeLog
mcs/jay/skeleton.cs

index c6d7089dd54dc04926822209df1fb40aad3d92e8..df8b18174adaba1ee1d86638bc7b9d26f8df138c 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-09  Miguel de Icaza  <miguel@novell.com>
+
+       * skeleton.cs: A little refactoring to support producing a list of
+       tokens as opposed to a list of token strings for code that uses
+       the yyExpecting code.
+
 2006-05-29  Raja R Harinath  <rharinath@novell.com>
 
        * skeleton.cs: Implement a better translation for named-loop continues.
index 603a9dedc9cdafefa869cbd32fbe4372997eea6a..f11cf4e2a3c3da5e209ba2a8c1ccdf4b79581953 100644 (file)
@@ -59,14 +59,14 @@ t    if ((name = yyNames[token]) != null) return name;
 t    return "[unknown]";
 t  }
 .
+.  int yyExpectingState;
 .  /** computes list of expected tokens on error by tracing the tables.
 .      @param state for which to compute the list.
 .      @return list of token names.
 .    */
-.  protected string[] yyExpecting (int state) {
+.  protected int [] yyExpectingTokens (int state){
 .    int token, n, len = 0;
 .    bool[] ok = new bool[yyNames.Length];
-.
 .    if ((n = yySindex[state]) != 0)
 .      for (token = n < 0 ? -n : 0;
 .           (token < yyNames.Length) && (n+token < yyTable.Length); ++ token)
@@ -81,10 +81,16 @@ t  }
 .          ++ len;
 .          ok[token] = true;
 .        }
-.
-.    string [] result = new string[len];
+.    int [] result = new int [len];
 .    for (n = token = 0; n < len;  ++ token)
-.      if (ok[token]) result[n++] = yyNames[token];
+.      if (ok[token]) result[n++] = token;
+.    return result;
+.  }
+.  protected string[] yyExpecting (int state) {
+.    int [] tokens = yyExpectingTokens (state);
+.    string [] result = new string[tokens.Length];
+.    for (int n = 0; n < tokens.Length;  n++)
+.      result[n++] = yyNames[tokens [n]];
 .    return result;
 .  }
 .
@@ -174,6 +180,7 @@ t              debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
 .            switch (yyErrorFlag) {
 .  
 .            case 0:
+.              yyExpectingState = yyState;
 .              // yyerror(String.Format ("syntax error, got token `{0}'", yyname (yyToken)), yyExpecting(yyState));
 t              if (debug != null) debug.error("syntax error");
 .              if (yyToken == 0 || yyToken == eof_token /* eof */) throw new yyParser.yyUnexpectedEof ();