From e5e9ce27788135ea8dc0e1a12e3fb987b7c98f8c Mon Sep 17 00:00:00 2001 From: David Majda Date: Mon, 22 Oct 2012 11:37:18 +0200 Subject: [PATCH] README.md: Wrap lines at column 80 --- README.md | 273 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 204 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 4532c8b..4c93b69 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ PEG.js ====== -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. +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. Features -------- @@ -9,13 +12,18 @@ Features * Simple and expressive grammar syntax * Integrates both lexical and syntactical analysis * Parsers have excellent error reporting out of the box - * Based on [parsing expression grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar) formalism — more powerful than traditional LL(*k*) and LR(*k*) parsers - * Usable [from your browser](http://pegjs.majda.cz/online), from the command line, or via JavaScript API + * Based on [parsing expression + grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar) formalism + — more powerful than traditional LL(*k*) and LR(*k*) parsers + * Usable [from your browser](http://pegjs.majda.cz/online), from the command + line, or via JavaScript API Getting Started --------------- -[Online version](http://pegjs.majda.cz/online) is the easiest way to generate a parser. Just enter your grammar, try parsing few inputs, and download generated parser code. +[Online version](http://pegjs.majda.cz/online) is the easiest way to generate a +parser. Just enter your grammar, try parsing few inputs, and download generated +parser code. Installation ------------ @@ -30,16 +38,20 @@ To use the JavaScript API, install PEG.js locally: $ npm install pegjs -If you need both the `pegjs` command and the JavaScript API, install PEG.js both ways. +If you need both the `pegjs` command and the JavaScript API, install PEG.js both +ways. ### Browser -[Download](http://pegjs.majda.cz/#download) the PEG.js library (regular or minified version). +[Download](http://pegjs.majda.cz/#download) the PEG.js library (regular or +minified version). Generating a Parser ------------------- -PEG.js generates parser from a grammar that describes expected input and can specify what the parser returns (using semantic actions on matched parts of the input). Generated parser itself is a JavaScript object with a simple API. +PEG.js generates parser from a grammar that describes expected input and can +specify what the parser returns (using semantic actions on matched parts of the +input). Generated parser itself is a JavaScript object with a simple API. ### Command Line @@ -47,19 +59,26 @@ To generate a parser from your grammar, use the `pegjs` command: $ pegjs arithmetics.pegjs -This writes parser source code into a file with the same name as the grammar file but with “.js” extension. You can also specify the output file explicitly: +This writes parser source code into a file with the same name as the grammar +file but with “.js” extension. You can also specify the output file explicitly: $ pegjs arithmetics.pegjs arithmetics-parser.js If you omit both input and ouptut file, standard input and output are used. -By default, the parser object is assigned to `module.exports`, which makes the output a Node.js module. You can assign it to another variable by passing a variable name using the `-e`/`--export-var` option. This may be helpful if you want to use the parser in browser environment. +By default, the parser object is assigned to `module.exports`, which makes the +output a Node.js module. You can assign it to another variable by passing a +variable name using the `-e`/`--export-var` option. This may be helpful if you +want to use the parser in browser environment. You can tweak the generated parser with several options: - * `--cache` — makes the parser cache results, avoiding exponential parsing time in pathological cases but making the parser slower - * `--track-line-and-column` — makes the parser track line and column (available as `line` and `column` variables in the actions and predicates) - * `--allowed-start-rules` — comma-separated list of rules the parser will be allowed to start parsing from (default: the first rule in the grammar) + * `--cache` — makes the parser cache results, avoiding exponential parsing + time in pathological cases but making the parser slower + * `--track-line-and-column` — makes the parser track line and column + (available as `line` and `column` variables in the actions and predicates) + * `--allowed-start-rules` — comma-separated list of rules the parser will be + allowed to start parsing from (default: the first rule in the grammar) ### JavaScript API @@ -67,32 +86,47 @@ In Node.js, require the PEG.js parser generator module: var PEG = require("pegjs"); -In browser, include the PEG.js library in your web page or application using the `