private void Factor(Stack<ExpressionOperation> operations)
{
if (Accept(TokenType.OpenParentheses))
{
Expression(operations);
Require(TokenType.CloseParentheses);
}
else if (tokens[pos].Type == TokenType.Number)
{
short value;
if (!short.TryParse(tokens[pos].Value, out value))
throw new AssemblerException(String.Format("Expected number on line {0}.", tokens[pos].Line));
operations.Push(new ExpressionOperation(value));
++pos;
}
else if (tokens[pos].Type == TokenType.Label)
{
throw new NotImplementedException();
}
else
throw new AssemblerException(
String.Format("Expected open parentheses, number or label on line {0}, got \"{1}\" instead.",
tokens[pos].Line, tokens[pos].Value));
}