+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.
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)
. ++ 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;
. }
.
. 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 ();