コード例 #1
0
 /// <summary>
 /// Do something! What you do is determined by the argument.
 /// Treats a string as a single character. Wow!
 /// Recognizes a regular expression if it is preceded by ( or , or =.
 /// </summary>
 /// <param name="d">
 /// 1   Output A. Copy B to A. Get the next B.
 /// 2   Copy B to A. Get the next B. (Delete A).
 /// 3   Get the next B. (Delete B).
 /// </param>
 private static void Action(ActionTask d)
 {
     if (d.Equals(ActionTask.OutputA))
     {
         Put(_theA);
     }
     if (d.Equals(ActionTask.OutputA) || d.Equals(ActionTask.CopyBtoA))
     {
         _theA = _theB;
         if (_theA.Equals('\'') || _theA.Equals('"'))
         {
             for (;;)
             {
                 Put(_theA);
                 _theA = Get();
                 if (_theA == _theB)
                 {
                     break;
                 }
                 if (_theA <= '\n')
                 {
                     throw new Exception(string.Format("Error: JSMIN unterminated string literal: {0}\n", _theA));
                 }
                 if (_theA.Equals('\\'))
                 {
                     Put(_theA);
                     _theA = Get();
                 }
             }
         }
     }
     //if (d.Equals(ActionTask.OutputA) || d.Equals(ActionTask.CopyBtoA) || d.Equals(ActionTask.GetNextB))
     //{
     _theB = Next();
     if (_theB.Equals('/') && (_theA.Equals('(') || _theA.Equals(',') || _theA.Equals('=') ||
                               _theA.Equals('[') || _theA.Equals('!') || _theA.Equals(':') ||
                               _theA.Equals('&') || _theA.Equals('|') || _theA.Equals('?')))
     {
         Put(_theA);
         Put(_theB);
         for (;;)
         {
             _theA = Get();
             if (_theA.Equals('/'))
             {
                 break;
             }
             else if (_theA.Equals('\\'))
             {
                 Put(_theA);
                 _theA = Get();
             }
             else if (_theA <= '\n')
             {
                 throw new Exception(string.Format("Error: JSMIN unterminated Regular Expression literal : {0}.\n", _theA));
             }
             Put(_theA);
         }
         _theB = Next();
     }
     //}
 }
コード例 #2
0
 /// <summary>
 /// Do something! What you do is determined by the argument.
 /// Treats a string as a single character. Wow!
 /// Recognizes a regular expression if it is preceded by ( or , or =.
 /// </summary>
 /// <param name="d">
 /// 1   Output A. Copy B to A. Get the next B.
 /// 2   Copy B to A. Get the next B. (Delete A).
 /// 3   Get the next B. (Delete B).
 /// </param>
 private static void Action(ActionTask d)
 {
     if (d.Equals(ActionTask.OutputA))
     {
         Put(_theA);
     }
     if (d.Equals(ActionTask.OutputA) || d.Equals(ActionTask.CopyBtoA))
     {
         _theA = _theB;
         if (_theA.Equals('\'') || _theA.Equals('"'))
         {
             for (;;)
             {
                 Put(_theA);
                 _theA = Get();
                 if (_theA == _theB)
                 {
                     break;
                 }
                 if (_theA <= '\n')
                 {
                     throw new Exception(string.Format("Error: JSMIN unterminated string literal: {0}\n", _theA));
                 }
                 if (_theA.Equals('\\'))
                 {
                     Put(_theA);
                     _theA = Get();
                 }
             }
         }
     }
     //if (d.Equals(ActionTask.OutputA) || d.Equals(ActionTask.CopyBtoA) || d.Equals(ActionTask.GetNextB))
     //{
     _theB = Next();
     if (_theB.Equals('/') && (_theA.Equals('(') || _theA.Equals(',') || _theA.Equals('=') ||
                               _theA.Equals('[') || _theA.Equals('!') || _theA.Equals(':') ||
                               _theA.Equals('&') || _theA.Equals('|') || _theA.Equals('?')))
     {
         Put(_theA);
         Put(_theB);
         for (;;)
         {
             _theA = Get();
             if (_theA.Equals('/'))
             {
                 break;
             }
             else if (_theA.Equals('\\'))
             {
                 Put(_theA);
                 _theA = Get();
             }
             else if (_theA <= '\n')
             {
                 throw new Exception(string.Format("Error: JSMIN unterminated Regular Expression literal : {0}.\n", _theA));
             }
             Put(_theA);
         }
         _theB = Next();
     }
     //}
 }