File tree Expand file tree Collapse file tree 5 files changed +54
-0
lines changed Expand file tree Collapse file tree 5 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 11test
2+ example
Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < script src ="bundle.js "> </ script >
4+ </ head >
5+ < body >
6+ < form onsubmit ="run(); return false; ">
7+ < input type ="text " id ="input " value ="50 + 2 - 10 " />
8+ < input type ="submit " />
9+ Result: < span id ="output "> –</ span >
10+ </ form >
11+ </ body >
12+ </ html >
Original file line number Diff line number Diff line change 1+ %lex
2+ %%
3+
4+ \s + /* Skip whitespace. */
5+ [0-9] + return ' NUMBER'
6+ "-" return ' -'
7+ "+" return ' +'
8+ <<EOF>> return ' EOF'
9+ . return ' INVALID'
10+
11+ /lex
12+
13+ %left '+' '-'
14+ %start expressions
15+ %%
16+
17+ expressions
18+ : expr EOF { return $1 ; }
19+ ;
20+
21+ expr
22+ : expr '+' expr { $$ = $1 + $3 ; }
23+ | expr '-' expr { $$ = $1 - $3 ; }
24+ | NUMBER { $$ = Number (yytext ); }
25+ ;
Original file line number Diff line number Diff line change 1+ var parser = require ( './calc.jison' ) . parser ;
2+
3+ exports = run = function ( ) {
4+ var input = document . getElementById ( 'input' ) ;
5+ var output = document . getElementById ( 'output' ) ;
6+ output . innerText = parser . parse ( input . value ) ;
7+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " jisonify-example" ,
3+ "description" : " Jisonify example." ,
4+ "version" : " 0.0.1" ,
5+ "dependencies" : {
6+ "jisonify" : " *" ,
7+ "browserify" : " *"
8+ }
9+ }
You can’t perform that action at this time.
0 commit comments