Exemple #1
0
 private void Error(string nonterm, AlphaTexSymbols expected, bool symbolError = true)
 {
     if (symbolError)
     {
         throw new AlphaTexException(_curChPos, nonterm, expected, _sy);
     }
     throw new AlphaTexException(_curChPos, nonterm, expected, expected, _syData);
 }
Exemple #2
0
 private void Error(string nonterm, AlphaTexSymbols expected, bool symbolError = true)
 {
     if (symbolError)
     {
         throw new AlphaTexException(_curChPos, nonterm, expected, _sy);
     }
     throw new AlphaTexException(_curChPos, nonterm, expected, expected, _syData);
 }
Exemple #3
0
 public AlphaTexException(int position, string nonTerm, AlphaTexSymbols expected, AlphaTexSymbols symbol, object symbolData = null)
 {
     Position = position;
     NonTerm = nonTerm;
     Expected = expected;
     Symbol = symbol;
     SymbolData = symbolData;
 }
 public AlphaTexException(int position, string nonTerm, AlphaTexSymbols expected, AlphaTexSymbols symbol, object symbolData = null)
 {
     Position   = position;
     NonTerm    = nonTerm;
     Expected   = expected;
     Symbol     = symbol;
     SymbolData = symbolData;
 }
 public AlphaTexException(int position, string nonTerm, AlphaTexSymbols expected, AlphaTexSymbols symbol, object symbolData = null)
     : base(BuildMessage(position, nonTerm, expected, symbol, symbolData))
 {
     Position   = position;
     NonTerm    = nonTerm;
     Expected   = expected;
     Symbol     = symbol;
     SymbolData = symbolData;
 }
 private static string BuildMessage(int position, string nonTerm, AlphaTexSymbols expected, AlphaTexSymbols symbol, object symbolData)
 {
     if (symbolData == null)
     {
         return("MalFormed AlphaTex: @" + position + ": Error on block " + nonTerm +
                ", expected a " + expected + " found a " + symbol);
     }
     else
     {
         return("MalFormed AlphaTex: @" + position + ": Error on block " + nonTerm +
                ", invalid value: " + symbolData);
     }
 }
Exemple #7
0
        private void Error(string nonterm, AlphaTexSymbols expected, bool symbolError = true)
        {
            AlphaTexException e;

            if (symbolError)
            {
                e = new AlphaTexException(_curChPos, nonterm, expected, _sy);
            }
            else
            {
                e = new AlphaTexException(_curChPos, nonterm, expected, expected, _syData);
            }
            Logger.Error(Name, e.Message);
            throw e;
        }
        public AlphaTexException(int position, string nonTerm, AlphaTexSymbols expected, AlphaTexSymbols symbol, object symbolData = null)
            : base("")
        {
            Position   = position;
            NonTerm    = nonTerm;
            Expected   = expected;
            Symbol     = symbol;
            SymbolData = symbolData;

            if (SymbolData == null)
            {
                Description = "MalFormed AlphaTex: @" + Position + ": Error on block " + NonTerm +
                              ", expected a " + Expected + " found a " + Symbol;
            }
            else
            {
                Description = "MalFormed AlphaTex: @" + Position + ": Error on block " + NonTerm +
                              ", invalid value: " + SymbolData;
            }
        }
Exemple #9
0
 /// <summary>
 /// Reads the next terminal symbol.
 /// </summary>
 private void NewSy()
 {
     _sy = AlphaTexSymbols.No;
     do
     {
         if (_ch == Eof)
         {
             _sy = AlphaTexSymbols.Eof;
         }
         else if (Std.IsWhiteSpace(_ch))
         {
             // skip whitespaces 
             NextChar();
         }
         else if (_ch == 0x2F /* / */)
         {
             NextChar();
             if (_ch == 0x2F /* / */)
             {
                 // single line comment
                 while (_ch != 0x0D /* \r */ && _ch != 0x0A /* \n */ && _ch != Eof)
                 {
                     NextChar();
                 }
             }
             else if (_ch == 0x2A /* * */)
             {
                 // multiline comment
                 while (_ch != Eof)
                 {
                     if (_ch == 0x2A /* * */) // possible end
                     {
                         NextChar();
                         if (_ch == 0x2F /* / */)
                         {
                             NextChar();
                             break;
                         }
                     }
                     else
                     {
                         NextChar();
                     }
                 }
             }
             else
             {
                 Error("symbol", AlphaTexSymbols.String, false);
             }
         }
         else if (_ch == 0x22 /* " */ || _ch == 0x27 /* ' */)
         {
             NextChar();
             var s = new StringBuilder();
             _sy = AlphaTexSymbols.String;
             while (_ch != 0x22 /* " */ && _ch != 0x27 /* ' */ && _ch != Eof)
             {
                 s.AppendChar(_ch);
                 NextChar();
             }
             _syData = s.ToString();
             NextChar();
         }
         else if (_ch == 0x2D /* - */) // negative number
         {
             // is number?
             if (_allowNegatives && IsDigit(_ch))
             {
                 var number = ReadNumber();
                 _sy = AlphaTexSymbols.Number;
                 _syData = number;
             }
             else
             {
                 _sy = AlphaTexSymbols.String;
                 _syData = ReadName();
             }
         }
         else if (_ch == 0x2E /* . */)
         {
             _sy = AlphaTexSymbols.Dot;
             NextChar();
         }
         else if (_ch == 0x3A /* : */)
         {
             _sy = AlphaTexSymbols.DoubleDot;
             NextChar();
         }
         else if (_ch == 0x28 /* ( */)
         {
             _sy = AlphaTexSymbols.LParensis;
             NextChar();
         }
         else if (_ch == 0x5C /* \ */)
         {
             NextChar();
             var name = ReadName();
             _sy = AlphaTexSymbols.MetaCommand;
             _syData = name;
         }
         else if (_ch == 0x29 /* ) */)
         {
             _sy = AlphaTexSymbols.RParensis;
             NextChar();
         }
         else if (_ch == 0x7B /* { */)
         {
             _sy = AlphaTexSymbols.LBrace;
             NextChar();
         }
         else if (_ch == 0x7D /* } */)
         {
             _sy = AlphaTexSymbols.RBrace;
             NextChar();
         }
         else if (_ch == 0x7C /* | */)
         {
             _sy = AlphaTexSymbols.Pipe;
             NextChar();
         }
         else if (_ch == 0x2A /* * */)
         {
             _sy = AlphaTexSymbols.Multiply;
             NextChar();
         }
         else if (IsDigit(_ch))
         {
             var number = ReadNumber();
             _sy = AlphaTexSymbols.Number;
             _syData = number;
         }
         else if (IsLetter(_ch))
         {
             var name = ReadName();
             if (TuningParser.IsTuning(name))
             {
                 _sy = AlphaTexSymbols.Tuning;
                 _syData = name.ToLower();
             }
             else
             {
                 _sy = AlphaTexSymbols.String;
                 _syData = name;
             }
         }
         else
         {
             Error("symbol", AlphaTexSymbols.String, false);
         }
     } while (_sy == AlphaTexSymbols.No);
 }
Exemple #10
0
 /// <summary>
 /// Reads the next terminal symbol.
 /// </summary>
 private void NewSy()
 {
     _sy = AlphaTexSymbols.No;
     do
     {
         if (_ch == Eof)
         {
             _sy = AlphaTexSymbols.Eof;
         }
         else if (Std.IsWhiteSpace(_ch))
         {
             // skip whitespaces
             NextChar();
         }
         else if (_ch == 0x2F /* / */)
         {
             NextChar();
             if (_ch == 0x2F /* / */)
             {
                 // single line comment
                 while (_ch != 0x0D /* \r */ && _ch != 0x0A /* \n */ && _ch != Eof)
                 {
                     NextChar();
                 }
             }
             else if (_ch == 0x2A /* * */)
             {
                 // multiline comment
                 while (_ch != Eof)
                 {
                     if (_ch == 0x2A /* * */) // possible end
                     {
                         NextChar();
                         if (_ch == 0x2F /* / */)
                         {
                             NextChar();
                             break;
                         }
                     }
                     else
                     {
                         NextChar();
                     }
                 }
             }
             else
             {
                 Error("symbol", AlphaTexSymbols.String, false);
             }
         }
         else if (_ch == 0x22 /* " */ || _ch == 0x27 /* ' */)
         {
             var startChar = _ch;
             NextChar();
             var s = new StringBuilder();
             _sy = AlphaTexSymbols.String;
             while (_ch != startChar && _ch != Eof)
             {
                 s.AppendChar(_ch);
                 NextChar();
             }
             _syData = s.ToString();
             NextChar();
         }
         else if (_ch == 0x2D /* - */) // negative number
         {
             // is number?
             if (_allowNegatives && IsDigit(_ch))
             {
                 var number = ReadNumber();
                 _sy     = AlphaTexSymbols.Number;
                 _syData = number;
             }
             else
             {
                 _sy     = AlphaTexSymbols.String;
                 _syData = ReadName();
             }
         }
         else if (_ch == 0x2E /* . */)
         {
             _sy = AlphaTexSymbols.Dot;
             NextChar();
         }
         else if (_ch == 0x3A /* : */)
         {
             _sy = AlphaTexSymbols.DoubleDot;
             NextChar();
         }
         else if (_ch == 0x28 /* ( */)
         {
             _sy = AlphaTexSymbols.LParensis;
             NextChar();
         }
         else if (_ch == 0x5C /* \ */)
         {
             NextChar();
             var name = ReadName();
             _sy     = AlphaTexSymbols.MetaCommand;
             _syData = name;
         }
         else if (_ch == 0x29 /* ) */)
         {
             _sy = AlphaTexSymbols.RParensis;
             NextChar();
         }
         else if (_ch == 0x7B /* { */)
         {
             _sy = AlphaTexSymbols.LBrace;
             NextChar();
         }
         else if (_ch == 0x7D /* } */)
         {
             _sy = AlphaTexSymbols.RBrace;
             NextChar();
         }
         else if (_ch == 0x7C /* | */)
         {
             _sy = AlphaTexSymbols.Pipe;
             NextChar();
         }
         else if (_ch == 0x2A /* * */)
         {
             _sy = AlphaTexSymbols.Multiply;
             NextChar();
         }
         else if (IsDigit(_ch))
         {
             var number = ReadNumber();
             _sy     = AlphaTexSymbols.Number;
             _syData = number;
         }
         else if (IsLetter(_ch))
         {
             var name   = ReadName();
             var tuning = TuningParser.Parse(name);
             if (tuning != null)
             {
                 _sy     = AlphaTexSymbols.Tuning;
                 _syData = tuning;
             }
             else
             {
                 _sy     = AlphaTexSymbols.String;
                 _syData = name;
             }
         }
         else
         {
             Error("symbol", AlphaTexSymbols.String, false);
         }
     } while (_sy == AlphaTexSymbols.No);
 }