Exemplo n.º 1
0
        public bool expectToken(TokenCategory tc)
        {
            if (Curs.TokenObj.TokenCategory == tc)
            {   // we match the category and dont care about the string.
                return(Curs.advance());
            }
            else if (AllowEOLs && EOLMissedCount < MaxMissedCount && (tc == TokenCategory.tokEOL))
            {   // missing EXPECTED EOLs is deemed Ok
                // If we ere called to expect an EOL and we havent seen more than the acceptable amount of them
                // okay ...
                // so dont eat the NON EOL token
                EOLMissedCount = EOLMissedCount + 1;
                return(true);
            }
            tc.ToString();

            throw new FormatException($"Fatal Format Error in {TokFile.FilePath}:\n\t At (L{Curs.LineNo}:T{Curs.TokNo}) Expected <{tc.ToString()}> got <{Curs.TokenObj.TokenCategory}>.");
            // return FileIsValid = false;
        }
Exemplo n.º 2
0
 public override string ToString()
 {
     return(string.Format("{0} : {1}", new object[] { Category.ToString(), Value }));
 }
 public Token Expect(TokenCategory category)
 {
     if (Current == category)
     {
         previous = stream.Current;
         stream.MoveNext();
         return(previous);
     }
     else
     {
         throw new SyntaxError(String.Format("Syntax Error: Expected {0}, given '{1}' at ({2}, {3})", ErrorFormat(category.ToString()), stream.Current.Value, previous.Row, previous.LastIndex()));
     }
 }
Exemplo n.º 4
0
 public override string ToString()
 {
     return(string.Format("[{0}, {1}, @({2}, {3})]", category.ToString(), value, row, column));
 }