2007-05-10 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / jay / skeleton.cs
index d999dae6b4bcac1d089f96e0879a91a612fea228..8584cb24a18f1056d02da6038e9aed19aec2ff99 100644 (file)
@@ -29,7 +29,7 @@
 .      @param expected vector of acceptable tokens, if available.
 .    */
 .  public void yyerror (string message, string[] expected) {
-.    if ((expected != null) && (expected.Length  > 0)) {
+.    if ((yacc_verbose_flag > 0) && (expected != null) && (expected.Length  > 0)) {
 .      ErrorOutput.Write (message+", expecting");
 .      for (int n = 0; n < expected.Length; ++ n)
 .        ErrorOutput.Write (" "+expected[n]);
@@ -41,7 +41,7 @@
 .  /** debugging support, requires the package jay.yydebug.
 .      Set to null to suppress debugging messages.
 .    */
-t  protected yydebug.yyDebug debug;
+t  internal yydebug.yyDebug debug;
 .
  debug                 ## tables for debugging support
 .
@@ -92,7 +92,7 @@ t  }
 .      @return result of the last reduction, if any.
 .      @throws yyException on irrecoverable parse error.
 .    */
-.  public Object yyparse (yyParser.yyInput yyLex, Object yyd)
+.  internal Object yyparse (yyParser.yyInput yyLex, Object yyd)
 .                               {
 t    this.debug = (yydebug.yyDebug)yyd;
 .    return yyparse(yyLex);
@@ -120,8 +120,8 @@ t    this.debug = (yydebug.yyDebug)yyd;
 .      @return result of the last reduction, if any.
 .      @throws yyException on irrecoverable parse error.
 .    */
-.  public Object yyparse (yyParser.yyInput yyLex)
-.                              {
+.  internal Object yyparse (yyParser.yyInput yyLex)
+.  {
 .    if (yyMax <= 0) yyMax = 256;                      // initial size
 .    int yyState = 0;                                   // state stack ptr
 .    int [] yyStates = new int[yyMax];                 // state stack 
@@ -132,12 +132,7 @@ t    this.debug = (yydebug.yyDebug)yyd;
 .
  local         ## %{ ... %} after the first %%
 
-.    int yyTop = 0;
-.    goto skip;
-.    yyLoop:
-.    yyTop++;
-.    skip:
-.    for (;; ++ yyTop) {
+.    /*yyLoop:*/ for (int yyTop = 0;; ++ yyTop) {
 .      if (yyTop >= yyStates.Length) {                 // dynamically increase
 .        int[] i = new int[yyStates.Length+yyMax];
 .        yyStates.CopyTo (i, 0);
@@ -150,7 +145,7 @@ t    this.debug = (yydebug.yyDebug)yyd;
 .      yyVals[yyTop] = yyVal;
 t      if (debug != null) debug.push(yyState, yyVal);
 .
-.      yyDiscarded: for (;;) { // discarding a token does not change stack
+.      /*yyDiscarded:*/ for (;;) {     // discarding a token does not change stack
 .        int yyN;
 .        if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN)
 .          if (yyToken < 0) {
@@ -167,7 +162,7 @@ t              debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
 .            yyVal = yyLex.value();
 .            yyToken = -1;
 .            if (yyErrorFlag > 0) -- yyErrorFlag;
-.            goto yyLoop;
+.            goto continue_yyLoop;
 .          }
 .          if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0
 .              && yyN < yyTable.Length && yyCheck[yyN] == yyToken)
@@ -176,7 +171,7 @@ t              debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
 .            switch (yyErrorFlag) {
 .  
 .            case 0:
-.              yyerror("syntax error", yyExpecting(yyState));
+.              // yyerror(String.Format ("syntax error, got token `{0}'", yyname (yyToken)), yyExpecting(yyState));
 t              if (debug != null) debug.error("syntax error");
 .              goto case 1;
 .            case 1: case 2:
@@ -189,7 +184,7 @@ t                  if (debug != null)
 t                    debug.shift(yyStates[yyTop], yyTable[yyN], 3);
 .                  yyState = yyTable[yyN];
 .                  yyVal = yyLex.value();
-.                  goto yyLoop;
+.                  goto continue_yyLoop;
 .                }
 t                if (debug != null) debug.pop(yyStates[yyTop]);
 .              } while (-- yyTop >= 0);
@@ -205,12 +200,12 @@ t              if (debug != null)
 t                debug.discard(yyState, yyToken, yyname(yyToken),
 t                                                      yyLex.value());
 .              yyToken = -1;
-.              goto yyDiscarded;               // leave stack alone
+.              goto continue_yyDiscarded;              // leave stack alone
 .            }
 .        }
 .        int yyV = yyTop + 1-yyLen[yyN];
 t        if (debug != null)
-t          debug.reduce(yyState, yyStates[yyV-1], yyN, yyRule[yyN], yyLen[yyN]);
+t          debug.reduce(yyState, yyStates[yyV-1], yyN, YYRules.getRule (yyN), yyLen[yyN]);
 .        yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]);
 .        switch (yyN) {
 
@@ -233,7 +228,7 @@ t               debug.lex(yyState, yyToken,yyname(yyToken), yyLex.value());
 t            if (debug != null) debug.accept(yyVal);
 .            return yyVal;
 .          }
-.          goto yyLoop;
+.          goto continue_yyLoop;
 .        }
 .        if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0)
 .            && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState))
@@ -241,8 +236,10 @@ t            if (debug != null) debug.accept(yyVal);
 .        else
 .          yyState = yyDgoto[yyM];
 t        if (debug != null) debug.shift(yyStates[yyTop], yyState);
-.       goto yyLoop;
+.       goto continue_yyLoop;
+.      continue_yyDiscarded: continue; // implements the named-loop continue: 'continue yyDiscarded'
 .      }
+.    continue_yyLoop: continue;                // implements the named-loop continue: 'continue yyLoop'
 .    }
 .  }
 .
@@ -251,7 +248,7 @@ t        if (debug != null) debug.shift(yyStates[yyTop], yyState);
  epilog                        ## text following second %%
 .namespace yydebug {
 .        using System;
-.       public interface yyDebug {
+.       internal interface yyDebug {
 .               void push (int state, Object value);
 .               void lex (int state, int token, string name, Object value);
 .               void shift (int from, int to, int errorFlag);
@@ -331,14 +328,14 @@ t        if (debug != null) debug.shift(yyStates[yyTop], yyState);
 .  using System;
 .  /** thrown for irrecoverable syntax errors and stack overflow.
 .    */
-.  public class yyException : System.Exception {
+.  internal class yyException : System.Exception {
 .    public yyException (string message) : base (message) {
 .    }
 .  }
 .
 .  /** must be implemented by a scanner object to supply input to the parser.
 .    */
-.  public interface yyInput {
+.  internal interface yyInput {
 .    /** move on to next token.
 .        @return false if positioned beyond tokens.
 .        @throws IOException on input error.