Use default arguments

master
Futago-za Ryuu 5 years ago
parent 2dc0a1b64a
commit e17cdabd4d

@ -49,9 +49,7 @@ const compiler = {
// if the AST contains a semantic error. Note that not all errors are detected // 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 // during the generation and some may protrude to the generated parser and
// cause its malfunction. // cause its malfunction.
compile( ast, session, options ) { compile( ast, session, options = {} ) {
options = typeof options !== "undefined" ? options : {};
options = util.processOptions( options, { options = util.processOptions( options, {
allowedStartRules: [ ast.rules[ 0 ].name ], allowedStartRules: [ ast.rules[ 0 ].name ],

@ -19,9 +19,7 @@ function fatal( message, location ) {
class Session { class Session {
constructor( config ) { constructor( config = {} ) {
config = typeof config !== "undefined" ? config : {};
this.opcodes = config.opcodes || opcodes; this.opcodes = config.opcodes || opcodes;
this.parser = config.parser || parser; this.parser = config.parser || parser;

@ -25,9 +25,7 @@ const peg = {
// |peg.GrammarError| if it contains a semantic error. Note that not all // |peg.GrammarError| if it contains a semantic error. Note that not all
// errors are detected during the generation and some may protrude to the // errors are detected during the generation and some may protrude to the
// generated parser and cause its malfunction. // generated parser and cause its malfunction.
generate( grammar, options ) { generate( grammar, options = {} ) {
options = typeof options !== "undefined" ? options : {};
const session = new compiler.Session( { const session = new compiler.Session( {
passes: util.convertPasses( compiler.passes ) passes: util.convertPasses( compiler.passes )

Loading…
Cancel
Save