The easiest way of doing these things is to first formulate the grammar as (E)BNF, including operator priorities, and then translating that to the format your favourite parser generator (yacc/bison, Boost.Spirit, antlr, ...) expects.
Operator priorities can be built into the grammar by correct grouping. For example, the grammar of basic algebra looks something like this:
This grammar builds a correctly prioritized expression tree (dot before dash, left to right) from any simple algebraic expression: in "1 + 2 * 3" the parse tree is this:
start := add_expression
add_expression := mul_expression
| mul_expression '+' add_expression
| mul_expression '-' add_expression
mul_expression := term
| term '*' mul_expression
| term '/' mul_expression
term := '(' add_expression ')'
This leads to this expression tree:
-> number ("1")
-> number ("2")
-> number ("3")
Because expression trees are evaluated depth-first, the multiplication is correctly applied before the addition.