diff --git a/packages/pegjs/lib/compiler/index.js b/packages/pegjs/lib/compiler/index.js index dd35d7d..3620086 100644 --- a/packages/pegjs/lib/compiler/index.js +++ b/packages/pegjs/lib/compiler/index.js @@ -49,9 +49,7 @@ const compiler = { // if the AST contains a semantic error. Note that not all errors are detected // during the generation and some may protrude to the generated parser and // cause its malfunction. - compile( ast, session, options ) { - - options = typeof options !== "undefined" ? options : {}; + compile( ast, session, options = {} ) { options = util.processOptions( options, { allowedStartRules: [ ast.rules[ 0 ].name ], diff --git a/packages/pegjs/lib/compiler/session.js b/packages/pegjs/lib/compiler/session.js index 64ea3cf..1ed7bfc 100644 --- a/packages/pegjs/lib/compiler/session.js +++ b/packages/pegjs/lib/compiler/session.js @@ -19,9 +19,7 @@ function fatal( message, location ) { class Session { - constructor( config ) { - - config = typeof config !== "undefined" ? config : {}; + constructor( config = {} ) { this.opcodes = config.opcodes || opcodes; this.parser = config.parser || parser; diff --git a/packages/pegjs/lib/peg.js b/packages/pegjs/lib/peg.js index befcadd..15e9e26 100644 --- a/packages/pegjs/lib/peg.js +++ b/packages/pegjs/lib/peg.js @@ -25,9 +25,7 @@ const peg = { // |peg.GrammarError| if it contains a semantic error. Note that not all // errors are detected during the generation and some may protrude to the // generated parser and cause its malfunction. - generate( grammar, options ) { - - options = typeof options !== "undefined" ? options : {}; + generate( grammar, options = {} ) { const session = new compiler.Session( { passes: util.convertPasses( compiler.passes )