Skip to content

Commit

Permalink
Merge pull request #20 from ima1zumi/add-calc-to-usage
Browse files Browse the repository at this point in the history
Add calc.y to usage
  • Loading branch information
yui-knk authored May 17, 2023
2 parents 07e6175 + 10c74c1 commit a3ffaf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sample/calc.y
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static int yyerror(YYLTYPE *loc, const char *str) {
}

int main() {
printf("Enter the formula:\n");
yyparse();
return 0;
}

0 comments on commit a3ffaf3

Please sign in to comment.