Improve JAY: now we support EOF detection
authorMiguel de Icaza <miguel@gnome.org>
Tue, 26 Aug 2008 22:01:41 +0000 (22:01 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 26 Aug 2008 22:01:41 +0000 (22:01 -0000)
svn path=/trunk/mcs/; revision=111664

mcs/jay/skeleton.cs

index 8584cb24a18f1056d02da6038e9aed19aec2ff99..603a9dedc9cdafefa869cbd32fbe4372997eea6a 100644 (file)
@@ -23,6 +23,9 @@
 .    yyerror(message, null);
 .  }
 .
+.  /* An EOF token */
+.  public int eof_token;
+.
 .  /** (syntax) error message.
 .      Can be overwritten to control message format.
 .      @param message text to be displayed.
@@ -173,6 +176,7 @@ t              debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
 .            case 0:
 .              // 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 ();
 .              goto case 1;
 .            case 1: case 2:
 .              yyErrorFlag = 3;
@@ -332,6 +336,12 @@ t        if (debug != null) debug.shift(yyStates[yyTop], yyState);
 .    public yyException (string message) : base (message) {
 .    }
 .  }
+.  internal class yyUnexpectedEof : yyException {
+.    public yyUnexpectedEof (string message) : base (message) {
+.    }
+.    public yyUnexpectedEof () : base ("") {
+.    }
+.  }
 .
 .  /** must be implemented by a scanner object to supply input to the parser.
 .    */