Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/jay
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2008-09-09 23:16:15 +0400
committerMiguel de Icaza <miguel@gnome.org>2008-09-09 23:16:15 +0400
commitc272d7283473a88d4a9d96f116433bdbbb5dd74c (patch)
tree0c82a15c0159f3a680a7b78a8ba4116c4774de9b /mcs/jay
parentd06d4c3c58cc6545588daa4ce2b3a71f375af545 (diff)
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. svn path=/trunk/mcs/; revision=112612
Diffstat (limited to 'mcs/jay')
-rw-r--r--mcs/jay/ChangeLog6
-rw-r--r--mcs/jay/skeleton.cs17
2 files changed, 18 insertions, 5 deletions
diff --git a/mcs/jay/ChangeLog b/mcs/jay/ChangeLog
index c6d7089dd54..df8b18174ad 100644
--- a/mcs/jay/ChangeLog
+++ b/mcs/jay/ChangeLog
@@ -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.
diff --git a/mcs/jay/skeleton.cs b/mcs/jay/skeleton.cs
index 603a9dedc9c..f11cf4e2a3c 100644
--- a/mcs/jay/skeleton.cs
+++ b/mcs/jay/skeleton.cs
@@ -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 ();