librelist archives

« back to archive

If I did this, would it be accepted as a pull request?

If I did this, would it be accepted as a pull request?

From:
Robert Plummer
Date:
2014-09-29 @ 19:37
I'm working in a scenario where I need to handle errors to cut down on
resources (jQuery.sheet).  In short we are loading a MASSIVE amount of json
spreadsheets into jQuery.sheet, and of course using Jison as the means to
parse the formulas.  When someone puts in an erroneous formula, as you
would expect, an exception is thrown.  I did notice there are the very
handy yy.parseError and yy.lexerError overloads available, and I have taken
advantage of them, but I get to the following line:

if (action[0] instanceof Array && action.length > 1) {
    throw new Error('Parse Error: multiple actions possible at state:
' + state + ', token: ' + symbol);
}

If we detect that yy.parseError/yy.lexerError has been overloaded, and
inside the overload set this.done to true, couldn't we check that before
throwing this exception and gracefully return the error to the system that
is using Jison for parsing?  If we did that, I wouldn't have to put Jison
in a try, and the end user couldn't break anything.  If my calculations are
correct, it should also save a ton of resources.

Just a side note, Jison is handling this massive amount of formulas with
ease, it is really both a testament to Zach Charter, open source, and
javascript... Just plain cool.

-- 
Robert Plummer

Re: If I did this, would it be accepted as a pull request?

From:
Robert Plummer
Date:
2014-09-29 @ 19:44
I just tested with the following:

var error = this.parseError(errStr, {
                text: lexer.match,
                token: this.terminals_[symbol] || symbol,
                line: lexer.yylineno,
                loc: yyloc,
                expected: expected
            });
if (this.done) {
   if (error !== undefined) {
      return error;
   } else {
      return null;
   }
}
        }
    if (action[0] instanceof Array && action.length > 1) {
        throw new Error('Parse Error: multiple actions possible at
state: ' + state + ', token: ' + symbol);
    }

And this seems to have a huge performance increase!

On Mon, Sep 29, 2014 at 3:37 PM, Robert Plummer <
robertleeplummerjr@gmail.com> wrote:

> I'm working in a scenario where I need to handle errors to cut down on
> resources (jQuery.sheet).  In short we are loading a MASSIVE amount of json
> spreadsheets into jQuery.sheet, and of course using Jison as the means to
> parse the formulas.  When someone puts in an erroneous formula, as you
> would expect, an exception is thrown.  I did notice there are the very
> handy yy.parseError and yy.lexerError overloads available, and I have taken
> advantage of them, but I get to the following line:
>
> if (action[0] instanceof Array && action.length > 1) {
>     throw new Error('Parse Error: multiple actions possible at state: ' 
+ state + ', token: ' + symbol);
> }
>
> If we detect that yy.parseError/yy.lexerError has been overloaded, and
> inside the overload set this.done to true, couldn't we check that before
> throwing this exception and gracefully return the error to the system that
> is using Jison for parsing?  If we did that, I wouldn't have to put Jison
> in a try, and the end user couldn't break anything.  If my calculations are
> correct, it should also save a ton of resources.
>
> Just a side note, Jison is handling this massive amount of formulas with
> ease, it is really both a testament to Zach Charter, open source, and
> javascript... Just plain cool.
>
> --
> Robert Plummer
>



-- 
Robert Plummer

Re: If I did this, would it be accepted as a pull request?

From:
Robert Plummer
Date:
2014-09-29 @ 20:32
And pull requested: https://github.com/zaach/jison/pull/220

On Mon, Sep 29, 2014 at 3:44 PM, Robert Plummer <
robertleeplummerjr@gmail.com> wrote:

> I just tested with the following:
>
> var error = this.parseError(errStr, {
>                 text: lexer.match,
>                 token: this.terminals_[symbol] || symbol,
>                 line: lexer.yylineno,
>                 loc: yyloc,
>                 expected: expected
>             });
> if (this.done) {
>    if (error !== undefined) {
>       return error;
>    } else {
>       return null;
>    }
> }
>         }
>     if (action[0] instanceof Array && action.length > 1) {
>         throw new Error('Parse Error: multiple actions possible at 
state: ' + state + ', token: ' + symbol);
>     }
>
> And this seems to have a huge performance increase!
>
> On Mon, Sep 29, 2014 at 3:37 PM, Robert Plummer <
> robertleeplummerjr@gmail.com> wrote:
>
>> I'm working in a scenario where I need to handle errors to cut down on
>> resources (jQuery.sheet).  In short we are loading a MASSIVE amount of json
>> spreadsheets into jQuery.sheet, and of course using Jison as the means to
>> parse the formulas.  When someone puts in an erroneous formula, as you
>> would expect, an exception is thrown.  I did notice there are the very
>> handy yy.parseError and yy.lexerError overloads available, and I have taken
>> advantage of them, but I get to the following line:
>>
>> if (action[0] instanceof Array && action.length > 1) {
>>     throw new Error('Parse Error: multiple actions possible at state: '
+ state + ', token: ' + symbol);
>> }
>>
>> If we detect that yy.parseError/yy.lexerError has been overloaded, and
>> inside the overload set this.done to true, couldn't we check that before
>> throwing this exception and gracefully return the error to the system that
>> is using Jison for parsing?  If we did that, I wouldn't have to put Jison
>> in a try, and the end user couldn't break anything.  If my calculations are
>> correct, it should also save a ton of resources.
>>
>> Just a side note, Jison is handling this massive amount of formulas with
>> ease, it is really both a testament to Zach Charter, open source, and
>> javascript... Just plain cool.
>>
>> --
>> Robert Plummer
>>
>
>
>
> --
> Robert Plummer
>



-- 
Robert Plummer