/usr/share/doc/peg/examples/dc.peg is in peg 0.1.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Grammar
Expr <- SPACE Sum EOL { printf("%d\n", pop()); }
/ (!EOL .)* EOL { printf("error\n"); }
Sum <- Product ( PLUS Product { int r= pop(), l= pop(); push(l + r); }
/ MINUS Product { int r= pop(), l= pop(); push(l - r); }
)*
Product <- Value ( TIMES Value { int r= pop(), l= pop(); push(l * r); }
/ DIVIDE Value { int r= pop(), l= pop(); push(l / r); }
)*
Value <- NUMBER { push(atoi(yytext)); }
/ OPEN Sum CLOSE
# Lexemes
NUMBER <- < [0-9]+ > SPACE
PLUS <- '+' SPACE
MINUS <- '-' SPACE
TIMES <- '*' SPACE
DIVIDE <- '/' SPACE
OPEN <- '(' SPACE
CLOSE <- ')' SPACE
SPACE <- [ \t]*
EOL <- '\n' / '\r\n' / '\r'
|