Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to browserify parsers generated by Jison #55

Closed
codedot opened this issue Aug 27, 2015 · 3 comments
Closed

Failing to browserify parsers generated by Jison #55

codedot opened this issue Aug 27, 2015 · 3 comments

Comments

@codedot
Copy link

codedot commented Aug 27, 2015

$ ls
calc.jison
$ cat calc.jison 
/* description: Parses end executes mathematical expressions. */

/* lexical grammar */
%lex

%%
\s+                   /* skip whitespace */
[0-9]+("."[0-9]+)?\b  return 'NUMBER';
"*"                   return '*';
"/"                   return '/';
"-"                   return '-';
"+"                   return '+';
"^"                   return '^';
"("                   return '(';
")"                   return ')';
"PI"                  return 'PI';
"E"                   return 'E';
<<EOF>>               return 'EOF';

/lex

/* operator associations and precedence */

%left '+' '-'
%left '*' '/'
%left '^'
%left UMINUS

%start expressions

%% /* language grammar */

expressions
    : e EOF
        {print($1); return $1;}
    ;

e
    : e '+' e
        {$$ = $1+$3;}
    | e '-' e
        {$$ = $1-$3;}
    | e '*' e
        {$$ = $1*$3;}
    | e '/' e
        {$$ = $1/$3;}
    | e '^' e
        {$$ = Math.pow($1, $3);}
    | '-' e %prec UMINUS
        {$$ = -$2;}
    | '(' e ')'
        {$$ = $2;}
    | NUMBER
        {$$ = Number(yytext);}
    | E
        {$$ = Math.E;}
    | PI
        {$$ = Math.PI;}
    ;
$ npm install browserify brfs jison
[...]
$ node_modules/.bin/jison calc.jison 
$ node_modules/.bin/browserify calc.js -o bundle.js
$ node_modules/.bin/browserify calc.js -o bundle.js -t brfs
TypeError: Object #<Object> has no method 'apply' while parsing file: /tmp/test/calc.js
    at walk (/tmp/test/node_modules/brfs/node_modules/static-module/node_modules/static-eval/index.js:89:27)
    at walk (/tmp/test/node_modules/brfs/node_modules/static-module/node_modules/static-eval/index.js:92:23)
    at walk (/tmp/test/node_modules/brfs/node_modules/static-module/node_modules/static-eval/index.js:77:26)
    at walk (/tmp/test/node_modules/brfs/node_modules/static-module/node_modules/static-eval/index.js:85:25)
    at module.exports (/tmp/test/node_modules/brfs/node_modules/static-module/node_modules/static-eval/index.js:114:7)
    at traverse (/tmp/test/node_modules/brfs/node_modules/static-module/index.js:256:23)
    at walk (/tmp/test/node_modules/brfs/node_modules/static-module/index.js:208:13)
    at walk (/tmp/test/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:49:9)
    at /tmp/test/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:46:17
    at forEach (/tmp/test/node_modules/brfs/node_modules/static-module/node_modules/falafel/node_modules/foreach/index.js:12:16)
$ 
@nahidakbar
Copy link

+1 for this please

It works if I require jison and use that. However the generated parsers give the above error.

@mattdesl
Copy link
Collaborator

Can you explain in more detail what this problem is and what you are trying to solve? I'm not sure what jison is, or where the problem in brfs lies.

Cheers 🍻

@goto-bus-stop
Copy link
Member

Can't reproduce with the latest browserify and brfs versions; please open a new issue if this is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants