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

A pathological example that blows up #398

Open
panyam opened this issue Apr 6, 2021 · 0 comments
Open

A pathological example that blows up #398

panyam opened this issue Apr 6, 2021 · 0 comments

Comments

@panyam
Copy link

panyam commented Apr 6, 2021

Ive been using Jison as a validator for test cases (for another generator I have been building) and found that for some cases the LR1 table construction blows up.

Here is a very minimal example:


%%
S : S E ;
S : ;

E : A ;

A : A a ;
A : ;

Running this on the command line (jison -p lr1 -t ) causes the number of canonical closure items to balloon up (resulting in node's heap getting overflown).

My generator produces this parse table (each entry is a state number, set if lr1 items, next set (the goto set) and entries in the parse table) but Id love to be able to validate this using Jison too:

{
  '0': {
    items: [
      'Start ->  . S   /   <EOF>',
      'S ->  . S E   /   <EOF>',
      'S ->  .    /   <EOF>',
      'S ->  . S E   /   a',
      'S ->  .    /   a'
    ],
    actions: { '<EOF>': [ 'R <S -> >' ], S: [ '1' ], a: [ 'R <S -> >' ] },
    next: { S: 1 }
  },
  '1': {
    items: [
      'A ->  . A a   /   <EOF>',
      'A ->  .    /   <EOF>',
      'A ->  . A a   /   a',
      'A ->  .    /   a',
      'Start -> S .    /   <EOF>',
      'S -> S . E   /   <EOF>',
      'S -> S . E   /   a',
      'E ->  . A   /   <EOF>',
      'E ->  . A   /   a'
    ],
    actions: {
      '<EOF>': [ 'R <A -> >', 'Acc' ],
      E: [ '2' ],
      A: [ '3' ],
      a: [ 'R <A -> >' ]
    },
    next: { E: 2, A: 3 }
  },
  '2': {
    items: [ 'S -> S E .    /   <EOF>', 'S -> S E .    /   a' ],
    actions: { '<EOF>': [ 'R <S -> S E>' ], a: [ 'R <S -> S E>' ] },
    next: {}
  },
  '3': {
    items: [
      'A -> A . a   /   <EOF>',
      'A -> A . a   /   a',
      'E -> A .    /   <EOF>',
      'E -> A .    /   a'
    ],
    actions: { '<EOF>': [ 'R <E -> A>' ], a: [ 'S4', 'R <E -> A>' ] },
    next: { a: 4 }
  },
  '4': {
    items: [ 'A -> A a .    /   <EOF>', 'A -> A a .    /   a' ],
    actions: { '<EOF>': [ 'R <A -> A a>' ], a: [ 'R <A -> A a>' ] },
    next: {}
  }
}
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

1 participant