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
// 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 ],

@ -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;

@ -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 )

Loading…
Cancel
Save