How to include both precedence and associativity in following grammar?

For the following grammar, how can I include both precedence and associativity of operators:

S -> S|S

S -> SS

S -> S*

S -> (S)

S -> a|b

Note: In the first rule S -> S|S, the symbol | is the OR symbol and not two rules.