|
|
|
@ -1325,13 +1325,27 @@ function generateJS( ast, options ) {
|
|
|
|
|
|
|
|
|
|
function generateWrapper( toplevelCode ) {
|
|
|
|
|
|
|
|
|
|
function generateGeneratedByComment() {
|
|
|
|
|
function generateHeaderComment() {
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
"// Generated by PEG.js 0.10.0.",
|
|
|
|
|
"//",
|
|
|
|
|
"// https://pegjs.org/"
|
|
|
|
|
].join( "\n" );
|
|
|
|
|
let comment = "// Generated by PEG.js v0.10.0, https://pegjs.org/";
|
|
|
|
|
const header = options.header;
|
|
|
|
|
|
|
|
|
|
if ( typeof header === "string" ) {
|
|
|
|
|
|
|
|
|
|
comment += "\n\n" + header;
|
|
|
|
|
|
|
|
|
|
} else if ( Array.isArray( header ) ) {
|
|
|
|
|
|
|
|
|
|
comment += "\n\n";
|
|
|
|
|
header.forEach( data => {
|
|
|
|
|
|
|
|
|
|
comment += "// " + data;
|
|
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return comment;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1377,7 +1391,7 @@ function generateJS( ast, options ) {
|
|
|
|
|
bare() {
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
generateGeneratedByComment(),
|
|
|
|
|
generateHeaderComment(),
|
|
|
|
|
"(function() {",
|
|
|
|
|
" \"use strict\";",
|
|
|
|
|
"",
|
|
|
|
@ -1395,7 +1409,7 @@ function generateJS( ast, options ) {
|
|
|
|
|
const dependencyVars = Object.keys( options.dependencies );
|
|
|
|
|
|
|
|
|
|
parts.push( [
|
|
|
|
|
generateGeneratedByComment(),
|
|
|
|
|
generateHeaderComment(),
|
|
|
|
|
"",
|
|
|
|
|
"\"use strict\";",
|
|
|
|
|
""
|
|
|
|
@ -1433,7 +1447,7 @@ function generateJS( ast, options ) {
|
|
|
|
|
const dependencyVars = Object.keys( options.dependencies );
|
|
|
|
|
|
|
|
|
|
parts.push(
|
|
|
|
|
generateGeneratedByComment(),
|
|
|
|
|
generateHeaderComment(),
|
|
|
|
|
""
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -1477,7 +1491,7 @@ function generateJS( ast, options ) {
|
|
|
|
|
const params = dependencyVars.join( ", " );
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
generateGeneratedByComment(),
|
|
|
|
|
generateHeaderComment(),
|
|
|
|
|
"define(" + dependencies + ", function(" + params + ") {",
|
|
|
|
|
" \"use strict\";",
|
|
|
|
|
"",
|
|
|
|
@ -1493,7 +1507,7 @@ function generateJS( ast, options ) {
|
|
|
|
|
globals() {
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
generateGeneratedByComment(),
|
|
|
|
|
generateHeaderComment(),
|
|
|
|
|
"(function(root) {",
|
|
|
|
|
" \"use strict\";",
|
|
|
|
|
"",
|
|
|
|
@ -1522,7 +1536,7 @@ function generateJS( ast, options ) {
|
|
|
|
|
const params = dependencyVars.join( ", " );
|
|
|
|
|
|
|
|
|
|
parts.push( [
|
|
|
|
|
generateGeneratedByComment(),
|
|
|
|
|
generateHeaderComment(),
|
|
|
|
|
"(function(root, factory) {",
|
|
|
|
|
" if (typeof define === \"function\" && define.amd) {",
|
|
|
|
|
" define(" + dependencies + ", factory);",
|
|
|
|
|