Exemple #1
0
        Token ExpectMatch(Symbol right, Symbol left, SourceLocation leftStart)
        {
            if (Current.Symbol != right)
            {
                if (Current.Line == leftStart.Line)
                {
                    throw ReportSyntaxErrorNear("'{0}' expected",
                        right.ToTokenString());
                }

                throw ReportSyntaxErrorNear("'{0}' expected (to close '{1}' at line {2})",
                    right.ToTokenString(),
                    left.ToTokenString(),
                    leftStart.Line);
            }
            return Consume();
        }
Exemple #2
0
 Token Expect(Symbol symbol)
 {
     if (Current.Symbol != symbol)
     {
         throw ReportSyntaxErrorNear("'{0}' expected",
             symbol.ToTokenString());
     }
     return Consume();
 }