In PLY, grammar rules are defined similarly to tokens, that is, using docstrings. Here's what a few grammar rules for out language might look like:
expression : expression PLUS expression
p = p + t
expression : NUMBER
p = 
So the first docstring works is, an expression is defined as expression PLUS expression. Here PLUS is the token we defined earlier, and expression is any other way we've defined expression, so an expression is also a number(which is the token we defined earlier). The way the code works is essentially that p is the result, and each piece of the definition is it's own subscript, so p and p refer to the two expression in the plus expression we defined.
To actually use this parser we've defined we do:
parser = yacc.yacc()
if __name__ == '__main__':
s = raw_input('calc > ')
if not s:
result = parser.parse(s)
Try it out! As an exercise, the reader can implement other operations(remember the order of operations!), and perhaps variable. Tomorrow, I'll be discussing implementing these. As always, the PLY documentation is excellent, and available here.