25 lines
397 B
C#
25 lines
397 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
namespace sharp.parser
|
|
{
|
|
public class TokenQueue : Queue<Token>
|
|
{
|
|
public TokenQueue()
|
|
{
|
|
}
|
|
|
|
public Token Expect(params TokenDefinition[] tdefs)
|
|
{
|
|
Token t = Dequeue();
|
|
foreach (TokenDefinition tdef in tdefs){
|
|
if (t.Definition == tdef)
|
|
{
|
|
return t;
|
|
}
|
|
}
|
|
throw new UnexpectedTokenException(t, tdefs);
|
|
}
|
|
|
|
}
|
|
}
|