'factor ::= NUM | ( expr )'

def factor(self):

    if self._accept('NUM'):
        return int(self.tok.value)
    elif self._accept('LPAREN'):
        exprval = self.expr()
        self._expect('RPAREN')
        return exprval
    else:
        raise SyntaxError('Expected    NUMBER    or    LPAREN')
