diff --git a/README.md b/README.md index 79af9274..6550edc0 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,18 @@ $ bundle exec lrama --version $ lrama -d sample/parse.y ``` +```shell +# "calc", "calc.c", and "calc.h" are generated +$ lrama -d sample/calc.y -o calc.c && gcc -Wall calc.c -o calc && ./calc +Enter the formula: +1 +=> 1 +1+2*3 +=> 7 +(1+2)*3 +=> 9 +``` + ## Build Ruby 1. Install Lrama diff --git a/sample/calc.y b/sample/calc.y index cbd553d0..c03d6adf 100644 --- a/sample/calc.y +++ b/sample/calc.y @@ -92,6 +92,7 @@ static int yyerror(YYLTYPE *loc, const char *str) { } int main() { + printf("Enter the formula:\n"); yyparse(); return 0; }