kkoch986 / js-parse

A generic node.js based LR(1) shift-reduce parser.
12 stars 1 forks source link

Exclude from production #4

Open kkoch986 opened 10 years ago

kkoch986 commented 10 years ago

Currently, excludeFromProduction is only true or false, would be cool to allow specification of the circumstances under which it should be excluded.

For example, in regex,

 { 
    head: "REW.REX.RANGE",
    body: 
    [ 
        { head: "REW.REX.CHAR",
          body: [ { type: 'REW.REX.NONMETACHAR', value: '0' }, [length]: 1 ] },
        { type: 'REW.REX.-', value: '-' },
        { head: 'REW.REX.CHAR',
          body: [ { type: 'REW.REX.NONMETACHAR', value: '9' }, [length]: 1 ] },
        [length]: 3 
    ] 
}

Would like to exclude the "-" here but potentially not in other places.

This would also necessitate an includeInProductions which carries out the inverse effect, excluding from all but the specified productions.

kkoch986 commented 10 years ago

Closer inspection shows reopen #1, even the boolean version for non-terminals doesn't work.

My intuition is it should take all of the params to the production and add them as params to the parent in its place.