@ -1,8 +1,8 @@ |
|||
!.eslintrc.js |
|||
/.idea |
|||
/.nyc_output |
|||
/public |
|||
/packages/pegjs/dist |
|||
/coverage |
|||
node_modules |
|||
/website/*/** |
|||
/dist |
|||
/website/assets |
|||
|
@ -1,12 +1,11 @@ |
|||
/.idea |
|||
/packages/pegjs/dist |
|||
/packages/pegjs/.npmrc |
|||
/dist |
|||
/public |
|||
/examples/*.js |
|||
node_modules |
|||
/coverage |
|||
/.nyc_output |
|||
/website/js/*-bundle.js |
|||
/*.log |
|||
/sh.exe.stackdump |
|||
/test/junit-results.xml |
|||
|
@ -1,9 +1,12 @@ |
|||
.github |
|||
.idea |
|||
.nyc_output |
|||
coverage |
|||
dist |
|||
/.github |
|||
/.idea |
|||
/.nyc_output |
|||
/coverage |
|||
node_modules |
|||
.eslint* |
|||
.nycrc |
|||
azure-pipelines.yml |
|||
/public |
|||
/.codecov.yml |
|||
/.eslint* |
|||
/.nycrc |
|||
/CHANGELOG.md |
|||
/tsconfig.json |
|||
/README.md |
|||
|
@ -1,13 +1,21 @@ |
|||
{ |
|||
"version": 2, |
|||
"name": "pegjs-next-website", |
|||
"name": "pegjs", |
|||
"alias": [ |
|||
"next.pegjs.org" |
|||
"pegjs.org", |
|||
"www.pegjs.org" |
|||
], |
|||
"builds": [ |
|||
"routes": [ |
|||
{ |
|||
"src": "package.json", |
|||
"use": "@now/static-build" |
|||
"handle": "filesystem" |
|||
}, |
|||
{ |
|||
"src": "/", |
|||
"dest": "/index.html" |
|||
}, |
|||
{ |
|||
"src": "/([^\\.*]+)", |
|||
"dest": "/$1.html" |
|||
} |
|||
] |
|||
} |
|||
|
@ -1 +0,0 @@ |
|||
dist/*-bundle.min.js |
@ -1,5 +1,5 @@ |
|||
{ |
|||
"name": "@pegjs/publish-dev", |
|||
"version": "2.2.0", |
|||
"version": "2.3.0", |
|||
"private": true |
|||
} |
|||
|
@ -0,0 +1,13 @@ |
|||
This directory contains content used to generate the [PEG.js website](https://pegjs.org/). |
|||
|
|||
### [assets](./assets) |
|||
|
|||
Static files that will be served by Zeit's CDN. |
|||
|
|||
### [pages](./pages), [templates](./templates) |
|||
|
|||
Contains scripts, source files & templates used to generate the actual pages served on the website. |
|||
|
|||
### [export.js](./export.js) |
|||
|
|||
Running this script will build a static site, deployable via `now` |
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
@ -0,0 +1,35 @@ |
|||
"use strict"; |
|||
|
|||
const { bluebird, fs, expand, refresh } = require( "./export.utils" ); |
|||
|
|||
( async () => { |
|||
|
|||
// Copy static content
|
|||
await fs.copy( expand( "website/assets" ), expand( "public" ) ); |
|||
|
|||
// Generate pages
|
|||
await bluebird.each( fs.glob( "pages/**/*.js", __dirname ), async input => { |
|||
|
|||
const output = input |
|||
.replace( expand( "website/pages" ), expand( "public" ) ) |
|||
.slice( 0, -3 ) + ".html"; |
|||
|
|||
await refresh( input, output, async () => { |
|||
|
|||
let page = require( input ); |
|||
|
|||
if ( typeof page === "function" ) page = await bluebird.method( page )(); |
|||
|
|||
await fs.ensureDir( fs.dirname( output ) ); |
|||
await fs.writeFile( output, page.trim() ); |
|||
|
|||
} ); |
|||
|
|||
} ); |
|||
|
|||
} )().catch( err => { |
|||
|
|||
console.trace( err ); |
|||
process.exit( 1 ); |
|||
|
|||
} ); |
@ -0,0 +1,190 @@ |
|||
"use strict"; |
|||
|
|||
const bluebird = require( "bluebird" ); |
|||
const BundlerTarget = require( "@pegjs/bundler/target" ); |
|||
const cp = require( "@futagoza/child-process" ); |
|||
const fse = require( "fs-extra-plus" ); |
|||
const isSourceNewer = require( "@tache/is-source-newer" ); |
|||
const path = require( "path" ); |
|||
|
|||
/** |
|||
* This flag can be used to: |
|||
* |
|||
* 1. Force building content even if it hasn't changed. |
|||
* 2. Delete and write content instead of overwriting. |
|||
*/ |
|||
|
|||
const FRESH_BUILD = process.argv.includes( "--fresh" ); |
|||
|
|||
/** |
|||
* A conveniant object that has the following merged: |
|||
* |
|||
* - The `fs-extra-plus` module |
|||
* - The `path` module |
|||
* - Custom overwrides of the above 2 modules |
|||
* |
|||
* @type {path & fse} |
|||
*/ |
|||
|
|||
const fs = Object.assign( {}, path, fse, { |
|||
|
|||
copy( source, target, opts ) { |
|||
|
|||
return refresh( source, target, async () => { |
|||
|
|||
if ( FRESH_BUILD ) await fse.remove( target ); |
|||
|
|||
await fse.copy( source, target, opts ); |
|||
|
|||
} ); |
|||
|
|||
}, |
|||
|
|||
} ); |
|||
|
|||
/** |
|||
* A bundler wrapper that simplfies bundler interaction across child process's via async functions. |
|||
*/ |
|||
|
|||
const Bundler = { |
|||
|
|||
/** |
|||
* The CLI argument used to get/set a script that actually contains the bundles config. |
|||
*/ |
|||
|
|||
argv: "--get-config-from", |
|||
|
|||
/** |
|||
* The CLI used to run the actual bundler. |
|||
*/ |
|||
|
|||
cli: require.resolve( "@pegjs/bundler/bundler.js" ), |
|||
|
|||
/** |
|||
* The property exported from a script that contains the bundler's config. |
|||
*/ |
|||
|
|||
property: Symbol( "BundlerConfig" ), |
|||
|
|||
/** |
|||
* This method must be called from a bundler's `*.js` config file to get the actual config. |
|||
*/ |
|||
|
|||
load() { |
|||
|
|||
const { argv } = process; |
|||
|
|||
return require( argv[ argv.indexOf( Bundler.argv ) + 1 ] )[ Bundler.property ]; |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* This will create an async function that first executes the bundler if required, then calls `next` |
|||
* |
|||
* @template T |
|||
* @param {{check?: string, config: {}, cwd?: string, next: () => T, script: string, targets?: {}[]}} param0 |
|||
*/ |
|||
|
|||
create( { check, config, cwd = __dirname, next, script, targets } ) { |
|||
|
|||
if ( targets && ! config ) config = targets[ 0 ]; |
|||
|
|||
/** @returns {Promise<T>} */ |
|||
|
|||
async function executer() { |
|||
|
|||
const run = () => cp.run( "node", [ Bundler.cli, Bundler.argv, script ], { cwd } ); |
|||
|
|||
await check ? refresh( check, config.output, run ) : run(); |
|||
|
|||
return bluebird.method( next )(); |
|||
|
|||
} |
|||
|
|||
Object.defineProperty( executer, Bundler.property, { |
|||
get: () => targets || [ BundlerTarget( config ) ], |
|||
} ); |
|||
|
|||
return executer; |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* A wrapper function to help create a configuration for the bundler. |
|||
*/ |
|||
|
|||
target: BundlerTarget, |
|||
|
|||
}; |
|||
|
|||
/** |
|||
* Helps to cleanly get the full filesystem path of `p`. |
|||
* |
|||
* @param {string} p The path to expand |
|||
* @param {string|string[]} cwd The current working directory (prepended to `p`) |
|||
*/ |
|||
|
|||
function expand( p = ".", cwd = [ __dirname, ".." ] ) { |
|||
|
|||
let resolved = expand.cache[ p ]; |
|||
|
|||
if ( ! resolved ) { |
|||
|
|||
if ( typeof cwd === "string" ) cwd = [ cwd ]; |
|||
|
|||
const right = p |
|||
.replace( "\\", "/" ) |
|||
.split( "/" ); |
|||
|
|||
resolved = path.join( ...cwd, ...right ); |
|||
|
|||
expand.cache[ p ] = resolved; |
|||
|
|||
} |
|||
|
|||
return resolved; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* A cache of the expaneded paths. |
|||
* |
|||
* @type {{ [key: string]: string }} |
|||
*/ |
|||
|
|||
expand.cache = {}; |
|||
|
|||
/** |
|||
* Will execute `cb` if `source` is newer then `target`. Can be used to only build changed files. |
|||
* |
|||
* _NOTE:_ If the `--fresh` flag is defined, this will always call `cb` |
|||
* |
|||
* @template T |
|||
* @param {string} source The source file or directory |
|||
* @param {string} target The generated output |
|||
* @param {(paths:{ source:string, target:string })=>Promise<T>} cb Called if `source` is newer. |
|||
*/ |
|||
|
|||
async function refresh( source, target, cb ) { |
|||
|
|||
const paths = { source, target }; |
|||
|
|||
return FRESH_BUILD || await isSourceNewer( paths ) |
|||
? cb( paths ) |
|||
: Promise.resolve(); |
|||
|
|||
} |
|||
|
|||
module.exports = { |
|||
|
|||
FRESH_BUILD, |
|||
|
|||
bluebird, |
|||
cp, |
|||
fs, |
|||
|
|||
Bundler, |
|||
expand, |
|||
refresh, |
|||
|
|||
}; |
@ -1,12 +1,11 @@ |
|||
{ |
|||
"name": "@pegjs/website", |
|||
"version": "1.3.0", |
|||
"version": "2.0.0", |
|||
"private": true, |
|||
"dependencies": { |
|||
"body-parser": "1.19.0", |
|||
"ejs": "2.7.2", |
|||
"express": "4.17.1", |
|||
"express-layout": "0.1.0", |
|||
"morgan": "1.9.1" |
|||
"@futagoza/child-process": "1.0.0", |
|||
"@tache/is-source-newer": "1.0.0-beta.5", |
|||
"bluebird": "3.7.1", |
|||
"fs-extra-plus": "0.5.11" |
|||
} |
|||
} |
|||
|
@ -0,0 +1,61 @@ |
|||
"use strict"; |
|||
|
|||
const { Bundler, expand } = require( "../../export.utils" ); |
|||
|
|||
const template = require( "../../templates/article" ); |
|||
|
|||
module.exports = Bundler.create( { |
|||
|
|||
script: __filename, |
|||
check: expand( "tools/benchmark" ), |
|||
config: { |
|||
|
|||
entry: expand( "tools/benchmark/browser.stub.js" ), |
|||
library: [ "peg", "benchmark" ], |
|||
output: expand( "public/js/benchmark-bundle.min.js" ), |
|||
|
|||
}, |
|||
|
|||
next() { |
|||
|
|||
return template( { |
|||
title: "Benchmark", |
|||
content: ` |
|||
|
|||
<link rel="stylesheet" href="/css/benchmark.css"> |
|||
|
|||
<div id="options"> |
|||
<label for="run-count">Run each test</label> |
|||
<input type="text" id="run-count" value="10"> times |
|||
<input type="checkbox" id="cache"> |
|||
<label for="cache">Use results cache</label> |
|||
<label for="optimize">Optimize:</label> |
|||
<select id="optimize"> |
|||
<option value="speed">Speed</option> |
|||
<option value="size">Size</option> |
|||
</select> |
|||
<input type="button" id="run" value="Run"> |
|||
</div> |
|||
|
|||
<table id="results-table"> |
|||
<tr class="columns"> |
|||
<th>Test</th> |
|||
<th>Input Size</th> |
|||
<th>Average Parse Time</th> |
|||
<th>Average Parse Speed</th> |
|||
</tr> |
|||
<tr> |
|||
<td class="no-results" colspan="4">No results available yet.</td> |
|||
</tr> |
|||
</table> |
|||
|
|||
<script src="https://unpkg.com/jquery@1.12.4/dist/jquery.min.js"></script> |
|||
<script src="https://unpkg.com/jquery.scrollto@2.1.2/jquery.scrollTo.min.js"></script> |
|||
<script src="/js/benchmark-bundle.min.js"></script> |
|||
|
|||
`,
|
|||
} ); |
|||
|
|||
}, |
|||
|
|||
} ); |
@ -0,0 +1,40 @@ |
|||
"use strict"; |
|||
|
|||
const template = require( "../../templates/article" ); |
|||
|
|||
module.exports = template( { |
|||
title: "Development", |
|||
content: ` |
|||
|
|||
<h1>Development</h1> |
|||
|
|||
<ul> |
|||
<li><a href="https://github.com/pegjs/pegjs/wiki">Wiki</a></li> |
|||
<li><a href="https://github.com/pegjs/pegjs">Source code</a></li> |
|||
<li><a href="/development/benchmark">Benchmark Suite</a></li> |
|||
<li><a href="/development/test">Test Suite</a></li> |
|||
<li><a href="/development/try">Try Development Version online</a></li> |
|||
<li><a href="https://github.com/pegjs/pegjs/issues">Issue tracker</a></li> |
|||
<li><a href="https://groups.google.com/group/pegjs">Google Group</a></li> |
|||
<li><a href="https://twitter.com/pegjs">Twitter</a></li> |
|||
</ul> |
|||
|
|||
<p>PEG.js is currently maintained by <a href="https://github.com/futagoza">Futago-za Ryuu</a>. |
|||
Since it's <a href="https://www.google.com/search?q=inception+meaning">inception</a> in 2010, PEG.js was |
|||
maintained by <a href="https://majda.cz/">David Majda</a> (<a href="https://twitter.com/dmajda">@dmajda</a>), |
|||
until <a href="https://github.com/pegjs/pegjs/issues/503">May 2017</a>.</p> |
|||
|
|||
<p>The <a href="https://github.com/pegjs/bower">Bower package</a> is maintained by |
|||
<a href="https://www.michel-kraemer.com/">Michel Krรคmer</a> |
|||
(<a href="https://twitter.com/michelkraemer">@michelkraemer</a>).</p> |
|||
|
|||
<p>You are welcome to contribute code. Unless your contribution is really |
|||
trivial you should get in touch with me first — this can prevent wasted |
|||
effort on both sides. You can send code both as a patch or a GitHub pull |
|||
request.</p> |
|||
|
|||
<p>Note that PEG.js is still very much work in progress. There are no |
|||
compatibility guarantees until version 1.0.</p> |
|||
|
|||
`,
|
|||
} ); |
@ -0,0 +1,44 @@ |
|||
"use strict"; |
|||
|
|||
const { Bundler, expand } = require( "../../export.utils" ); |
|||
|
|||
const template = require( "../../templates/article" ); |
|||
|
|||
module.exports = Bundler.create( { |
|||
|
|||
script: __filename, |
|||
check: expand( "test" ), |
|||
config: { |
|||
|
|||
entry: expand( "test/browser.stub.js" ), |
|||
library: [ "peg", "test" ], |
|||
output: expand( "public/js/test-bundle.min.js" ), |
|||
|
|||
}, |
|||
|
|||
next() { |
|||
|
|||
return template( { |
|||
title: "Test", |
|||
content: ` |
|||
|
|||
<div id="mocha"></div> |
|||
|
|||
<link href="/css/test.css" rel="stylesheet" /> |
|||
|
|||
<script> |
|||
if ( window.MSInputMethodContext && document.documentMode ) |
|||
|
|||
document.getElementById( "mocha" ).innerHTML = "Sorry, IE11 is not supported by the Spec Runner's dependencies."; |
|||
|
|||
else |
|||
|
|||
document.write( "<script src='/js/test-bundle.min.js'><\\/script>" ); |
|||
</script> |
|||
|
|||
`,
|
|||
} ); |
|||
|
|||
}, |
|||
|
|||
} ); |
@ -0,0 +1,29 @@ |
|||
"use strict"; |
|||
|
|||
const { Bundler, fs, expand } = require( "../../export.utils" ); |
|||
|
|||
const template = require( "../../templates/editor" ); |
|||
|
|||
module.exports = Bundler.create( { |
|||
|
|||
script: __filename, |
|||
check: expand( "packages" ), |
|||
config: { |
|||
|
|||
entry: require.resolve( "pegjs" ), |
|||
library: "peg", |
|||
output: expand( "public/js/peg-bundle.min.js" ), |
|||
|
|||
}, |
|||
|
|||
async next() { |
|||
|
|||
return template( { |
|||
title: "Try Development Version", |
|||
lib: "/js/peg-bundle.min.js", |
|||
input: await fs.readFile( expand( "examples/arithmetics.pegjs" ), "utf8" ), |
|||
} ); |
|||
|
|||
}, |
|||
|
|||
} ); |
@ -0,0 +1,10 @@ |
|||
"use strict"; |
|||
|
|||
const { fs, expand } = require( "../export.utils" ); |
|||
|
|||
const template = require( "../templates/article" ); |
|||
|
|||
module.exports = async () => template( { |
|||
title: "Documentation", |
|||
content: await fs.readFile( expand( "documentation.html", __dirname ), "utf8" ), |
|||
} ); |
@ -0,0 +1,61 @@ |
|||
"use strict"; |
|||
|
|||
const template = require( "../templates/article" ); |
|||
|
|||
module.exports = template( { |
|||
title: "Home", |
|||
content: ` |
|||
|
|||
<div id="sidebar"> |
|||
<a class="try" href="online">Try PEG.js online</a> |
|||
<div class="separator">— or —</div> |
|||
<pre class="install">npm install pegjs</pre> |
|||
<div class="separator">— or —</div> |
|||
<pre class="install">bower install pegjs</pre> |
|||
<div class="separator">— or —</div> |
|||
<div class="label">Download browser version</div> |
|||
<span id="download"> |
|||
<a |
|||
title="Download a minified version of PEG.js for the browser" |
|||
href="https://github.com/pegjs/pegjs/releases/download/v0.10.0/peg-0.10.0.min.js" |
|||
>minified</a> |
|||
| |
|||
<a |
|||
title="Download PEG.js for the browser" |
|||
href="https://github.com/pegjs/pegjs/releases/download/v0.10.0/peg-0.10.0.js" |
|||
>development</a> |
|||
</span> |
|||
</div> |
|||
|
|||
<div id="left-column"> |
|||
<p> |
|||
PEG.js is a simple parser generator for JavaScript that produces fast |
|||
parsers with excellent error reporting. You can use it to process complex data |
|||
or computer languages and build transformers, interpreters, compilers and |
|||
other tools easily. |
|||
</p> |
|||
|
|||
<h2>Features</h2> |
|||
|
|||
<ul> |
|||
<li>Simple and expressive grammar syntax</li> |
|||
|
|||
<li>Integrates both lexical and syntactical analysis</li> |
|||
|
|||
<li>Parsers have excellent error reporting out of the box</li> |
|||
|
|||
<li> |
|||
Based on <a href="https://en.wikipedia.org/wiki/Parsing_expression_grammar">parsing |
|||
expression grammar</a> formalism — more powerful than traditional LL(<em>k</em>) |
|||
and LR(<em>k</em>) parsers |
|||
</li> |
|||
|
|||
<li> |
|||
Usable <a href="https://pegjs.org/online">from your browser</a>, from the command |
|||
line, or via JavaScript API |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
|
|||
`,
|
|||
} ); |
@ -0,0 +1,19 @@ |
|||
"use strict"; |
|||
|
|||
const template = require( "./html" ); |
|||
|
|||
module.exports = ( { content, ga, layout, title } = {} ) => { |
|||
|
|||
content = ` |
|||
|
|||
<div id="content"> |
|||
|
|||
${ content } |
|||
|
|||
</div> |
|||
|
|||
`;
|
|||
|
|||
return template( { content, ga, layout, title } ); |
|||
|
|||
}; |
@ -0,0 +1,86 @@ |
|||
<table id="columns"> |
|||
<tr> |
|||
<td> |
|||
<table class="column online" id="left-column"> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<h2 class="suggestion top"> |
|||
<span class="step-number">1</span> |
|||
<div class="step-title">Write your PEG.js grammar</div> |
|||
</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div class="textarea-wrapper"> |
|||
<textarea class="code" id="grammar" autocomplete="off" autocorrect="off" |
|||
autocapitalize="off" spellcheck="false" disabled>$$DEFAULT_INPUT</textarea> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<div id="build-message" class="message progress">Loading...</div> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td> |
|||
<table class="column" id="right-column"> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<h2 class="suggestion top"> |
|||
<span class="step-number">2</span> |
|||
<div class="step-title">Test the generated parser with some input</div> |
|||
</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div class="textarea-wrapper"> |
|||
<textarea class="code" id="input" autocomplete="off" autocorrect="off" autocapitalize="off" |
|||
spellcheck="false" disabled>2 * (3 + 4)</textarea> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<div id="parse-message" class="message disabled">Parser not available.</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<h2 id="output-header">Output</h2> |
|||
<pre id="output" class="disabled">Output not available.</pre> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<h2 class="suggestion"> |
|||
<span class="step-number">3</span> |
|||
<div class="step-title">Download the parser code</div> |
|||
</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<input type="submit" id="parser-download" value="Download parser" disabled> |
|||
<div id="settings"> |
|||
<label for="parser-var">Parser variable:</label> |
|||
<input type="text" id="parser-var" value="module.exports" disabled> |
|||
<div id="options"> |
|||
<input type="checkbox" id="option-cache" disabled> |
|||
<label for="option-cache">Use results cache</label> |
|||
<label for="option-optimize">Optimize:</label> |
|||
<select id="option-optimize" disabled> |
|||
<option value="speed">Parsing speed</option> |
|||
<option value="size">Code size</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
</tr> |
|||
</table> |
@ -0,0 +1,40 @@ |
|||
"use strict"; |
|||
|
|||
const { fs, expand } = require( "../export.utils" ); |
|||
|
|||
const template = require( "./html" ); |
|||
|
|||
module.exports = async ( { ga, input, lib, layout, title } = {} ) => { |
|||
|
|||
const EDITOR_VIEW = await fs.readFile( expand( "editor.html", __dirname ), "utf8" ); |
|||
|
|||
const content = ` |
|||
|
|||
<div id="loader"> <div id="loader-inner">Loading...</div> </div> |
|||
|
|||
<div id="content"> |
|||
|
|||
${ EDITOR_VIEW.replace( "$$DEFAULT_INPUT", input ) } |
|||
|
|||
</div> |
|||
|
|||
<script src="https://unpkg.com/jquery@1.12.4/dist/jquery.min.js"></script> |
|||
<script src="https://unpkg.com/file-saver@2.0.2/dist/FileSaver.min.js"></script> |
|||
<script src="${ lib }"></script> |
|||
<script src="/vendor/jsdump/jsDump.js"></script> |
|||
<script src="/vendor/codemirror/codemirror.js"></script> |
|||
<script src="/js/online.js"></script> |
|||
|
|||
`;
|
|||
|
|||
return template( { |
|||
bodyStart: "", |
|||
bodyEnd: "", |
|||
content, |
|||
ga, |
|||
head: `<link rel="stylesheet" href="/vendor/codemirror/codemirror.css">`, |
|||
layout: layout || "online", |
|||
title, |
|||
} ); |
|||
|
|||
}; |
@ -0,0 +1,89 @@ |
|||
"use strict"; |
|||
|
|||
const defaultEnd = ` |
|||
<footer id="footer"> |
|||
Copyright © 2017+ <a href="https://futagoza.github.io/">Futago-za Ryuu</a> |
|||
• |
|||
<a href="https://github.com/pegjs/pegjs">Source code</a> |
|||
• |
|||
<a href="https://twitter.com/pegjs" title="Follow PEG.js on Twitter">Twitter</a> |
|||
<br /> |
|||
Copyright © 2010–2016 <a href="https://majda.cz/">David Majda</a> |
|||
</footer> |
|||
</div> |
|||
`;
|
|||
|
|||
function menuItem( title, url, text ) { |
|||
|
|||
const className = title === text ? " class=\"current\"" : ""; |
|||
|
|||
return `<a ${ className } href="/${ url }">${ text }</a>`; |
|||
|
|||
} |
|||
|
|||
module.exports = ( { |
|||
bodyStart = "<div id='main'>", |
|||
bodyEnd = " " + defaultEnd.trimLeft(), |
|||
content = "", |
|||
ga = "UA-100728112-1", |
|||
head = "", |
|||
layout = "default", |
|||
title = null, |
|||
} = {} ) => ` |
|||
|
|||
<!DOCTYPE html> |
|||
<html> |
|||
|
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta name="author" content="Futago-za Ryuu (futagoza.ryuu@gmail.com)"> |
|||
<meta name="copyright" content="Copyright © 2017 Futago-za Ryuu"> |
|||
<meta name="keywords" content="parser generator, PEG, JavaScript"> |
|||
<meta name="description" content="PEG.js is a parser generator for JavaScript based on the parsing expression grammar formalism."> |
|||
<title>${ title && title !== "Home" ? title + " » " : "" }PEG.js – Parser Generator for JavaScript</title> |
|||
<link rel="stylesheet" href="/css/common.css"> |
|||
<link rel="stylesheet" href="/css/layout-${ layout }.css"> |
|||
<link rel="stylesheet" href="/css/content.css"> |
|||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> |
|||
<!--[if IE]> |
|||
<script> |
|||
var html5elements = ["aside", "footer", "header", "nav"]; |
|||
for (var i = 0; i < html5elements.length; i++) { |
|||
document.createElement(html5elements[i]); |
|||
} |
|||
</script> |
|||
<![endif]--> |
|||
${ head } |
|||
</head> |
|||
|
|||
<body> |
|||
${ bodyStart } |
|||
<header id="header"> |
|||
<h1><a href="/">PEG.js</a></h1> |
|||
<h2>Parser Generator for JavaScript</h2> |
|||
</header> |
|||
|
|||
<nav id="menu"> |
|||
${ menuItem( title, "", "Home" ) } |
|||
${ menuItem( title, "online", "Online Version" ) } |
|||
${ menuItem( title, "documentation", "Documentation" ) } |
|||
${ menuItem( title, "development", "Development" ) } |
|||
</nav> |
|||
|
|||
${ content.trim() } |
|||
|
|||
${ bodyEnd } |
|||
|
|||
<script type="text/javascript"> |
|||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
|||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
|||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
|||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
|||
ga('create', '${ ga }', 'auto'); |
|||
ga('send', 'pageview'); |
|||
</script> |
|||
</body> |
|||
|
|||
</html> |
|||
|
|||
`.trim();
|
@ -1,30 +0,0 @@ |
|||
<link rel="stylesheet" href="/css/benchmark.css"> |
|||
|
|||
<div id="options"> |
|||
<label for="run-count">Run each test</label> |
|||
<input type="text" id="run-count" value="10"> times |
|||
<input type="checkbox" id="cache"> |
|||
<label for="cache">Use results cache</label> |
|||
<label for="optimize">Optimize:</label> |
|||
<select id="optimize"> |
|||
<option value="speed">Speed</option> |
|||
<option value="size">Size</option> |
|||
</select> |
|||
<input type="button" id="run" value="Run"> |
|||
</div> |
|||
|
|||
<table id="results-table"> |
|||
<tr class="columns"> |
|||
<th>Test</th> |
|||
<th>Input Size</th> |
|||
<th>Average Parse Time</th> |
|||
<th>Average Parse Speed</th> |
|||
</tr> |
|||
<tr> |
|||
<td class="no-results" colspan="4">No results available yet.</td> |
|||
</tr> |
|||
</table> |
|||
|
|||
<script src="https://unpkg.com/jquery@1.12.4/dist/jquery.min.js"></script> |
|||
<script src="https://unpkg.com/jquery.scrollto@2.1.2/jquery.scrollTo.min.js"></script> |
|||
<script src="/js/benchmark-bundle.js"></script> |
@ -1,28 +0,0 @@ |
|||
<h1>Development</h1> |
|||
|
|||
<ul> |
|||
<li><a href="https://github.com/pegjs/pegjs/wiki">Wiki</a></li> |
|||
<li><a href="https://github.com/pegjs/pegjs">Source code</a></li> |
|||
<li><a href="/development/benchmark">Benchmark Suite</a></li> |
|||
<li><a href="/development/test">Test Suite</a></li> |
|||
<li><a href="https://github.com/pegjs/pegjs/issues">Issue tracker</a></li> |
|||
<li><a href="https://groups.google.com/group/pegjs">Google Group</a></li> |
|||
<li><a href="https://twitter.com/pegjs">Twitter</a></li> |
|||
</ul> |
|||
|
|||
<p>PEG.js is currently maintained by <a href="https://github.com/futagoza">Futago-za Ryuu</a>. |
|||
Since it's <a href="https://www.google.com/search?q=inception+meaning">inception</a> in 2010, PEG.js was |
|||
maintained by <a href="https://majda.cz/">David Majda</a> (<a href="https://twitter.com/dmajda">@dmajda</a>), |
|||
until <a href="https://github.com/pegjs/pegjs/issues/503">May 2017</a>.</p> |
|||
|
|||
<p>The <a href="https://github.com/pegjs/bower">Bower package</a> is maintained by |
|||
<a href="https://www.michel-kraemer.com/">Michel Krรคmer</a> |
|||
(<a href="https://twitter.com/michelkraemer">@michelkraemer</a>).</p> |
|||
|
|||
<p>You are welcome to contribute code. Unless your contribution is really |
|||
trivial you should get in touch with me first — this can prevent wasted |
|||
effort on both sides. You can send code both as a patch or a GitHub pull |
|||
request.</p> |
|||
|
|||
<p>Note that PEG.js is still very much work in progress. There are no |
|||
compatibility guarantees until version 1.0.</p> |
@ -1,39 +0,0 @@ |
|||
<div id="sidebar"> |
|||
<a class="try" href="online">Try PEG.js online</a> |
|||
<div class="separator">— or —</div> |
|||
<pre class="install">npm install pegjs</pre> |
|||
<div class="separator">— or —</div> |
|||
<pre class="install">bower install pegjs</pre> |
|||
<div class="separator">— or —</div> |
|||
<div class="label">Download browser version</div> |
|||
<span id="download"> |
|||
<a title="Download a minified version of PEG.js for the browser" href="https://github.com/pegjs/pegjs/releases/download/v0.10.0/peg-0.10.0.min.js">minified</a> |
|||
| |
|||
<a title="Download PEG.js for the browser" href="https://github.com/pegjs/pegjs/releases/download/v0.10.0/peg-0.10.0.js">development</a> |
|||
</span> |
|||
</div> |
|||
|
|||
<div id="left-column"> |
|||
<p>PEG.js is a simple parser generator for JavaScript that produces fast |
|||
parsers with excellent error reporting. You can use it to process complex data |
|||
or computer languages and build transformers, interpreters, compilers and |
|||
other tools easily.</p> |
|||
|
|||
<h2>Features</h2> |
|||
|
|||
<ul> |
|||
<li>Simple and expressive grammar syntax</li> |
|||
|
|||
<li>Integrates both lexical and syntactical analysis</li> |
|||
|
|||
<li>Parsers have excellent error reporting out of the box</li> |
|||
|
|||
<li>Based on <a |
|||
href="https://en.wikipedia.org/wiki/Parsing_expression_grammar">parsing |
|||
expression grammar</a> formalism — more powerful than traditional |
|||
LL(<em>k</em>) and LR(<em>k</em>) parsers</li> |
|||
|
|||
<li>Usable <a href="https://pegjs.org/online">from your browser</a>, |
|||
from the command line, or via JavaScript API</li> |
|||
</ul> |
|||
</div> |
@ -1,53 +0,0 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta name="author" content="Futago-za Ryuu (futagoza.ryuu@gmail.com)"> |
|||
<meta name="copyright" content="Copyright © 2017 Futago-za Ryuu"> |
|||
<meta name="keywords" content="parser generator, PEG, JavaScript"> |
|||
<meta name="description" content="PEG.js is a parser generator for JavaScript based on the parsing expression grammar formalism."> |
|||
<title><%- title ? title + " » " : "" %>PEG.js – Parser Generator for JavaScript</title> |
|||
<link rel="stylesheet" href="/css/common.css"> |
|||
<link rel="stylesheet" href="/css/layout-online.css"> |
|||
<link rel="stylesheet" href="/css/content.css"> |
|||
<link rel="stylesheet" href="/vendor/codemirror/codemirror.css"> |
|||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> |
|||
<!--[if IE]> |
|||
<script> |
|||
var html5elements = ["aside", "footer", "header", "nav"]; |
|||
for (var i = 0; i < html5elements.length; i++) { |
|||
document.createElement(html5elements[i]); |
|||
} |
|||
</script> |
|||
<![endif]--> |
|||
</head> |
|||
<body> |
|||
<header id="header"> |
|||
<h1><a href="/">PEG.js</a></h1> |
|||
<h2>Parser Generator for JavaScript</h2> |
|||
</header> |
|||
<nav id="menu"> |
|||
<%- menuItem(req, "", "Home") %> |
|||
<%- menuItem(req, "online", "Online Version") %> |
|||
<%- menuItem(req, "documentation", "Documentation") %> |
|||
<%- menuItem(req, "development", "Development") %> |
|||
</nav> |
|||
|
|||
<div id="loader"> |
|||
<div id="loader-inner">Loading...</div> |
|||
</div> |
|||
|
|||
<div id="content"> |
|||
<%- body %> |
|||
</div> |
|||
|
|||
<script type="text/javascript"> |
|||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
|||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
|||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
|||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
|||
ga('create', 'UA-100728112-1', 'auto'); |
|||
ga('send', 'pageview'); |
|||
</script> |
|||
</body> |
|||
</html> |
@ -1,61 +0,0 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta name="author" content="Futago-za Ryuu (futagoza.ryuu@gmail.com)"> |
|||
<meta name="copyright" content="Copyright © 2017 Futago-za Ryuu"> |
|||
<meta name="keywords" content="parser generator, PEG, JavaScript"> |
|||
<meta name="description" content="PEG.js is a parser generator for JavaScript based on the parsing expression grammar formalism."> |
|||
<title><%- title ? title + " » " : "" %>PEG.js – Parser Generator for JavaScript</title> |
|||
<link rel="stylesheet" href="/css/common.css"> |
|||
<link rel="stylesheet" href="/css/layout-default.css"> |
|||
<link rel="stylesheet" href="/css/content.css"> |
|||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> |
|||
<!--[if IE]> |
|||
<script> |
|||
var html5elements = ["aside", "footer", "header", "nav"]; |
|||
for (var i = 0; i < html5elements.length; i++) { |
|||
document.createElement(html5elements[i]); |
|||
} |
|||
</script> |
|||
<![endif]--> |
|||
</head> |
|||
<body> |
|||
<div id="main"> |
|||
<header id="header"> |
|||
<h1><a href="/">PEG.js</a></h1> |
|||
<h2>Parser Generator for JavaScript</h2> |
|||
</header> |
|||
|
|||
<nav id="menu"> |
|||
<%- menuItem(req, "", "Home") %> |
|||
<%- menuItem(req, "online", "Online Version") %> |
|||
<%- menuItem(req, "documentation", "Documentation") %> |
|||
<%- menuItem(req, "development", "Development") %> |
|||
</nav> |
|||
|
|||
<div id="content"> |
|||
<%- body %> |
|||
</div> |
|||
|
|||
<footer id="footer"> |
|||
Copyright © 2017+ <a href="https://futagoza.github.io/">Futago-za Ryuu</a> |
|||
• |
|||
<a href="https://github.com/pegjs/pegjs">Source code</a> |
|||
• |
|||
<a href="https://twitter.com/pegjs" title="Follow PEG.js on Twitter">Twitter</a> |
|||
<br /> |
|||
Copyright © 2010–2016 <a href="https://majda.cz/">David Majda</a> |
|||
</footer> |
|||
</div> |
|||
|
|||
<script type="text/javascript"> |
|||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
|||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
|||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
|||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
|||
ga('create', 'UA-100728112-1', 'auto'); |
|||
ga('send', 'pageview'); |
|||
</script> |
|||
</body> |
|||
</html> |
@ -1,95 +0,0 @@ |
|||
<table id="columns"> |
|||
<tr> |
|||
<td> |
|||
<table class="column online" id="left-column"> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<h2 class="suggestion top"> |
|||
<span class="step-number">1</span> |
|||
<div class="step-title">Write your PEG.js grammar</div> |
|||
</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div class="textarea-wrapper"> |
|||
<textarea class="code" id="grammar" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" disabled> |
|||
<%- example %> |
|||
</textarea> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<div id="build-message" class="message progress">Loading...</div> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td> |
|||
<table class="column" id="right-column"> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<h2 class="suggestion top"> |
|||
<span class="step-number">2</span> |
|||
<div class="step-title">Test the generated parser with some input</div> |
|||
</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div class="textarea-wrapper"> |
|||
<textarea class="code" id="input" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" disabled>2 * (3 + 4)</textarea> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<div id="parse-message" class="message disabled">Parser not available.</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<h2 id="output-header">Output</h2> |
|||
<pre id="output" class="disabled">Output not available.</pre> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<h2 class="suggestion"> |
|||
<span class="step-number">3</span> |
|||
<div class="step-title">Download the parser code</div> |
|||
</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="content-height"> |
|||
<form method="post" action="/online/download"> |
|||
<input type="hidden" id="parser-source" name="source"> |
|||
<input type="submit" id="parser-download" value="Download parser" disabled> |
|||
<div id="settings"> |
|||
<label for="parser-var">Parser variable:</label> |
|||
<input type="text" id="parser-var" value="module.exports" disabled> |
|||
<div id="options"> |
|||
<input type="checkbox" id="option-cache" disabled> |
|||
<label for="option-cache">Use results cache</label> |
|||
<label for="option-optimize">Optimize:</label> |
|||
<select id="option-optimize" disabled> |
|||
<option value="speed">Parsing speed</option> |
|||
<option value="size">Code size</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
</from> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
|
|||
<script src="https://unpkg.com/jquery@1.12.4/dist/jquery.min.js"></script> |
|||
<script src="<%- pegjs %>"></script> |
|||
<script src="/vendor/jsdump/jsDump.js"></script> |
|||
<script src="/vendor/codemirror/codemirror.js"></script> |
|||
<script src="/js/online.js"></script> |
@ -1,16 +0,0 @@ |
|||
<div id="mocha"></div> |
|||
|
|||
<link href="/css/test.css" rel="stylesheet" /> |
|||
<script src="https://unpkg.com/mocha@5.2.0/mocha.js"></script> |
|||
|
|||
<script> |
|||
mocha.setup( { ui: "bdd" } ); |
|||
|
|||
if ( window.MSInputMethodContext && document.documentMode ) |
|||
|
|||
document.getElementById( "mocha" ).innerHTML = "Sorry, IE11 is not supported by the Spec Runner's dependencies."; |
|||
|
|||
else |
|||
|
|||
document.write( "<script src='/js/test-bundle.js' onload='mocha.run()'><\/script>" ); |
|||
</script> |
@ -0,0 +1,3 @@ |
|||
"use strict"; |
|||
|
|||
module.exports = require( "./export.utils" ).Bundler.load(); |