1[example {
2snit::type a_pe_grammar {
3    constructor {} {
4        install myg using pt::peg::container ${selfns}::G
5        $myg start {n Expression}
6        $myg add   AddOp Digit Expression Factor MulOp Number Sign Term
7        $myg modes {
8            AddOp      value
9            Digit      value
10            Expression value
11            Factor     value
12            MulOp      value
13            Number     value
14            Sign       value
15            Term       value
16        }
17        $myg rules {
18            AddOp      {/ {t -} {t +}}
19            Digit      {/ {t 0} {t 1} {t 2} {t 3} {t 4} {t 5} {t 6} {t 7} {t 8} {t 9}}
20            Expression {/ {x {t \50} {n Expression} {t \51}} {x {n Factor} {* {x {n MulOp} {n Factor}}}}}
21            Factor     {x {n Term} {* {x {n AddOp} {n Term}}}}
22            MulOp      {/ {t *} {t /}}
23            Number     {x {? {n Sign}} {+ {n Digit}}}
24            Sign       {/ {t -} {t +}}
25            Term       {n Number}
26        }
27        return
28    }
29
30    component myg
31    delegate method * to myg
32}
33}]
34