/usr/share/doc/peg/examples/erract.leg 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 | %{
#include <stdio.h>
%}
Expr = a:NUMBER PLUS ~{ printf("fail at PLUS\n") } b:NUMBER { printf("got addition\n"); }
| ( a:NUMBER MINUS b:NUMBER { printf("got subtraction\n"); } ) ~{ printf("fail at subtraction\n") }
| a:NUMBER TIMES b:NUMBER { printf("got multiplication\n"); }
| a:NUMBER DIVIDE b:NUMBER { printf("got division\n"); }
NUMBER = < [0-9]+ > - { $$= atoi(yytext); }
PLUS = '+' -
MINUS = '-' -
TIMES = '*' -
DIVIDE = '/' -
- = (SPACE | EOL)*
SPACE = [ \t]
EOL = '\n' | '\r\n' | '\r' | ';'
%%
int main()
{
while (yyparse());
return 0;
}
|