http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/node-uuid/test/test.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/node-uuid/test/test.js b/bin/node_modules/xcode/node_modules/node-uuid/test/test.js new file mode 100644 index 0000000..be23919 --- /dev/null +++ b/bin/node_modules/xcode/node_modules/node-uuid/test/test.js @@ -0,0 +1,240 @@ +if (!this.uuid) { + // node.js + uuid = require('../uuid'); +} + +// +// x-platform log/assert shims +// + +function _log(msg, type) { + type = type || 'log'; + + if (typeof(document) != 'undefined') { + document.write('<div class="' + type + '">' + msg.replace(/\n/g, '<br />') + '</div>'); + } + if (typeof(console) != 'undefined') { + var color = { + log: '\033[39m', + warn: '\033[33m', + error: '\033[31m' + } + console[type](color[type] + msg + color.log); + } +} + +function log(msg) {_log(msg, 'log');} +function warn(msg) {_log(msg, 'warn');} +function error(msg) {_log(msg, 'error');} + +function assert(res, msg) { + if (!res) { + error('FAIL: ' + msg); + } else { + log('Pass: ' + msg); + } +} + +// +// Unit tests +// + +// Verify ordering of v1 ids created with explicit times +var TIME = 1321644961388; // 2011-11-18 11:36:01.388-08:00 + +function compare(name, ids) { + ids = ids.map(function(id) { + return id.split('-').reverse().join('-'); + }).sort(); + var sorted = ([].concat(ids)).sort(); + + assert(sorted.toString() == ids.toString(), name + ' have expected order'); +} + +// Verify ordering of v1 ids created using default behavior +compare('uuids with current time', [ + uuid.v1(), + uuid.v1(), + uuid.v1(), + uuid.v1(), + uuid.v1() +]); + +// Verify ordering of v1 ids created with explicit times +compare('uuids with time option', [ + uuid.v1({msecs: TIME - 10*3600*1000}), + uuid.v1({msecs: TIME - 1}), + uuid.v1({msecs: TIME}), + uuid.v1({msecs: TIME + 1}), + uuid.v1({msecs: TIME + 28*24*3600*1000}), +]); + +assert( + uuid.v1({msecs: TIME}) != uuid.v1({msecs: TIME}), + 'IDs created at same msec are different' +); + +// Verify throw if too many ids created +var thrown = false; +try { + uuid.v1({msecs: TIME, nsecs: 10000}); +} catch (e) { + thrown = true; +} +assert(thrown, 'Exception thrown when > 10K ids created in 1 ms'); + +// Verify clock regression bumps clockseq +var uidt = uuid.v1({msecs: TIME}); +var uidtb = uuid.v1({msecs: TIME - 1}); +assert( + parseInt(uidtb.split('-')[3], 16) - parseInt(uidt.split('-')[3], 16) === 1, + 'Clock regression by msec increments the clockseq' +); + +// Verify clock regression bumps clockseq +var uidtn = uuid.v1({msecs: TIME, nsecs: 10}); +var uidtnb = uuid.v1({msecs: TIME, nsecs: 9}); +assert( + parseInt(uidtnb.split('-')[3], 16) - parseInt(uidtn.split('-')[3], 16) === 1, + 'Clock regression by nsec increments the clockseq' +); + +// Verify explicit options produce expected id +var id = uuid.v1({ + msecs: 1321651533573, + nsecs: 5432, + clockseq: 0x385c, + node: [ 0x61, 0xcd, 0x3c, 0xbb, 0x32, 0x10 ] +}); +assert(id == 'd9428888-122b-11e1-b85c-61cd3cbb3210', 'Explicit options produce expected id'); + +// Verify adjacent ids across a msec boundary are 1 time unit apart +var u0 = uuid.v1({msecs: TIME, nsecs: 9999}); +var u1 = uuid.v1({msecs: TIME + 1, nsecs: 0}); + +var before = u0.split('-')[0], after = u1.split('-')[0]; +var dt = parseInt(after, 16) - parseInt(before, 16); +assert(dt === 1, 'Ids spanning 1ms boundary are 100ns apart'); + +// +// Test parse/unparse +// + +id = '00112233445566778899aabbccddeeff'; +assert(uuid.unparse(uuid.parse(id.substr(0,10))) == + '00112233-4400-0000-0000-000000000000', 'Short parse'); +assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) == + '00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse'); + +// +// Perf tests +// + +var generators = { + v1: uuid.v1, + v4: uuid.v4 +}; + +var UUID_FORMAT = { + v1: /[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i, + v4: /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i +}; + +var N = 1e4; + +// Get %'age an actual value differs from the ideal value +function divergence(actual, ideal) { + return Math.round(100*100*(actual - ideal)/ideal)/100; +} + +function rate(msg, t) { + log(msg + ': ' + (N / (Date.now() - t) * 1e3 | 0) + ' uuids\/second'); +} + +for (var version in generators) { + var counts = {}, max = 0; + var generator = generators[version]; + var format = UUID_FORMAT[version]; + + log('\nSanity check ' + N + ' ' + version + ' uuids'); + for (var i = 0, ok = 0; i < N; i++) { + id = generator(); + if (!format.test(id)) { + throw Error(id + ' is not a valid UUID string'); + } + + if (id != uuid.unparse(uuid.parse(id))) { + assert(fail, id + ' is not a valid id'); + } + + // Count digits for our randomness check + if (version == 'v4') { + var digits = id.replace(/-/g, '').split(''); + for (var j = digits.length-1; j >= 0; j--) { + var c = digits[j]; + max = Math.max(max, counts[c] = (counts[c] || 0) + 1); + } + } + } + + // Check randomness for v4 UUIDs + if (version == 'v4') { + // Limit that we get worried about randomness. (Purely empirical choice, this!) + var limit = 2*100*Math.sqrt(1/N); + + log('\nChecking v4 randomness. Distribution of Hex Digits (% deviation from ideal)'); + + for (var i = 0; i < 16; i++) { + var c = i.toString(16); + var bar = '', n = counts[c], p = Math.round(n/max*100|0); + + // 1-3,5-8, and D-F: 1:16 odds over 30 digits + var ideal = N*30/16; + if (i == 4) { + // 4: 1:1 odds on 1 digit, plus 1:16 odds on 30 digits + ideal = N*(1 + 30/16); + } else if (i >= 8 && i <= 11) { + // 8-B: 1:4 odds on 1 digit, plus 1:16 odds on 30 digits + ideal = N*(1/4 + 30/16); + } else { + // Otherwise: 1:16 odds on 30 digits + ideal = N*30/16; + } + var d = divergence(n, ideal); + + // Draw bar using UTF squares (just for grins) + var s = n/max*50 | 0; + while (s--) bar += '='; + + assert(Math.abs(d) < limit, c + ' |' + bar + '| ' + counts[c] + ' (' + d + '% < ' + limit + '%)'); + } + } +} + +// Perf tests +for (var version in generators) { + log('\nPerformance testing ' + version + ' UUIDs'); + var generator = generators[version]; + var buf = new uuid.BufferClass(16); + + if (version == 'v4') { + ['mathRNG', 'whatwgRNG', 'nodeRNG'].forEach(function(rng) { + if (uuid[rng]) { + var options = {rng: uuid[rng]}; + for (var i = 0, t = Date.now(); i < N; i++) generator(options); + rate('uuid.' + version + '() with ' + rng, t); + } else { + log('uuid.' + version + '() with ' + rng + ': not defined'); + } + }); + } else { + for (var i = 0, t = Date.now(); i < N; i++) generator(); + rate('uuid.' + version + '()', t); + } + + for (var i = 0, t = Date.now(); i < N; i++) generator('binary'); + rate('uuid.' + version + '(\'binary\')', t); + + for (var i = 0, t = Date.now(); i < N; i++) generator('binary', buf); + rate('uuid.' + version + '(\'binary\', buffer)', t); +}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/node-uuid/uuid.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/node-uuid/uuid.js b/bin/node_modules/xcode/node_modules/node-uuid/uuid.js new file mode 100644 index 0000000..27f1d12 --- /dev/null +++ b/bin/node_modules/xcode/node_modules/node-uuid/uuid.js @@ -0,0 +1,249 @@ +// node-uuid/uuid.js +// +// Copyright (c) 2010 Robert Kieffer +// Dual licensed under the MIT and GPL licenses. +// Documentation and details at https://github.com/broofa/node-uuid +(function() { + var _global = this; + + // Unique ID creation requires a high quality random # generator, but + // Math.random() does not guarantee "cryptographic quality". So we feature + // detect for more robust APIs, normalizing each method to return 128-bits + // (16 bytes) of random data. + var mathRNG, nodeRNG, whatwgRNG; + + // Math.random()-based RNG. All platforms, very fast, unknown quality + var _rndBytes = new Array(16); + mathRNG = function() { + var r, b = _rndBytes, i = 0; + + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) == 0) r = Math.random() * 0x100000000; + b[i] = r >>> ((i & 0x03) << 3) & 0xff; + } + + return b; + } + + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // WebKit only (currently), moderately fast, high quality + if (_global.crypto && crypto.getRandomValues) { + var _rnds = new Uint32Array(4); + whatwgRNG = function() { + crypto.getRandomValues(_rnds); + + for (var c = 0 ; c < 16; c++) { + _rndBytes[c] = _rnds[c >> 2] >>> ((c & 0x03) * 8) & 0xff; + } + return _rndBytes; + } + } + + // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html + // Node.js only, moderately fast, high quality + try { + var _rb = require('crypto').randomBytes; + nodeRNG = _rb && function() { + return _rb(16); + }; + } catch (e) {} + + // Select RNG with best quality + var _rng = nodeRNG || whatwgRNG || mathRNG; + + // Buffer class to use + var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array; + + // Maps for number <-> hex string conversion + var _byteToHex = []; + var _hexToByte = {}; + for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 0x100).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; + } + + // **`parse()` - Parse a UUID into it's component bytes** + function parse(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; + + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(byte) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[byte]; + } + }); + + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } + + return buf; + } + + // **`unparse()` - Convert UUID byte array (ala parse()) into a string** + function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]]; + } + + // **`v1()` - Generate time-based UUID** + // + // Inspired by https://github.com/LiosK/UUID.js + // and http://docs.python.org/library/uuid.html + + // random #'s we need to init node and clockseq + var _seedBytes = _rng(); + + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + var _nodeId = [ + _seedBytes[0] | 0x01, + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] + ]; + + // Per 4.2.2, randomize (14 bit) clockseq + var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; + + // Previous uuid creation time + var _lastMSecs = 0, _lastNSecs = 0; + + // See https://github.com/broofa/node-uuid for API details + function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + + options = options || {}; + + var clockseq = options.clockseq != null ? options.clockseq : _clockseq; + + // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + var msecs = options.msecs != null ? options.msecs : new Date().getTime(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq == null) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + + return buf ? buf : unparse(b); + } + + // **`v4()` - Generate random UUID** + + // See https://github.com/broofa/node-uuid for API details + function v4(options, buf, offset) { + // Deprecated - 'format' argument, as supported in v1.2 + var i = buf && offset || 0; + + if (typeof(options) == 'string') { + buf = options == 'binary' ? new BufferClass(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || _rng)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || unparse(rnds); + } + + // Export public API + var uuid = v4; + uuid.v1 = v1; + uuid.v4 = v4; + uuid.parse = parse; + uuid.unparse = unparse; + uuid.BufferClass = BufferClass; + + // Export RNG options + uuid.mathRNG = mathRNG; + uuid.nodeRNG = nodeRNG; + uuid.whatwgRNG = whatwgRNG; + + if (typeof(module) != 'undefined') { + // Play nice with node.js + module.exports = uuid; + } else { + // Play nice with browsers + var _previousRoot = _global.uuid; + + // **`noConflict()` - (browser only) to reset global 'uuid' var** + uuid.noConflict = function() { + _global.uuid = _previousRoot; + return uuid; + } + _global.uuid = uuid; + } +}()); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/pegjs/CHANGELOG ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/pegjs/CHANGELOG b/bin/node_modules/xcode/node_modules/pegjs/CHANGELOG new file mode 100644 index 0000000..e5967cf --- /dev/null +++ b/bin/node_modules/xcode/node_modules/pegjs/CHANGELOG @@ -0,0 +1,146 @@ +0.6.2 (2011-08-20) +------------------ + +Small Changes: + +* Reset parser position when action returns |null|. +* Fixed typo in JavaScript example grammar. + +0.6.1 (2011-04-14) +------------------ + +Small Changes: + +* Use --ascii option when generating a minified version. + +0.6.0 (2011-04-14) +------------------ + +Big Changes: + +* Rewrote the command-line mode to be based on Node.js instead of Rhino -- no + more Java dependency. This also means that PEG.js is available as a Node.js + package and can be required as a module. +* Version for the browser is built separately from the command-ine one in two + flavors (normal and minified). +* Parser variable name is no longer required argument of bin/pegjs -- it is + "module.exports" by default and can be set using the -e/--export-var option. + This makes parsers generated by /bin/pegjs Node.js modules by default. +* Added ability to start parsing from any grammar rule. +* Added several compiler optimizations -- 0.6 is ~12% faster than 0.5.1 in the + benchmark on V8. + +Small Changes: + +* Split the source code into multiple files combined together using a build + system. +* Jake is now used instead of Rake for build scripts -- no more Ruby dependency. +* Test suite can be run from the command-line. +* Benchmark suite can be run from the command-line. +* Benchmark browser runner improvements (users can specify number of runs, + benchmarks are run using |setTimeout|, table is centered and fixed-width). +* Added PEG.js version to "Generated by..." line in generated parsers. +* Added PEG.js version information and homepage header to peg.js. +* Generated code improvements and fixes. +* Internal code improvements and fixes. +* Rewrote README.md. + +0.5.1 (2010-11-28) +------------------ + +Small Changes: + +* Fixed a problem where "SyntaxError: Invalid range in character class." error + appeared when using command-line version on Widnows (GH-13). +* Fixed wrong version reported by "bin/pegjs --version". +* Removed two unused variables in the code. +* Fixed incorrect variable name on two places. + +0.5 (2010-06-10) +---------------- + +Big Changes: + +* Syntax change: Use labeled expressions and variables instead of $1, $2, etc. +* Syntax change: Replaced ":" after a rule name with "=". +* Syntax change: Allow trailing semicolon (";") for rules +* Semantic change: Start rule of the grammar is now implicitly its first rule. +* Implemented semantic predicates. +* Implemented initializers. +* Removed ability to change the start rule when generating the parser. +* Added several compiler optimizations -- 0.5 is ~11% faster than 0.4 in the + benchmark on V8. + +Small Changes: + +* PEG.buildParser now accepts grammars only in string format. +* Added "Generated by ..." message to the generated parsers. +* Formatted all grammars more consistently and transparently. +* Added notes about ECMA-262, 5th ed. compatibility to the JSON example grammar. +* Guarded against redefinition of |undefined|. +* Made bin/pegjs work when called via a symlink (issue #1). +* Fixed bug causing incorrect error messages (issue #2). +* Fixed error message for invalid character range. +* Fixed string literal parsing in the JavaScript grammar. +* Generated code improvements and fixes. +* Internal code improvements and fixes. +* Improved README.md. + +0.4 (2010-04-17) +---------------- + +Big Changes: + +* Improved IE compatibility -- IE6+ is now fully supported. +* Generated parsers are now standalone (no runtime is required). +* Added example grammars for JavaScript, CSS and JSON. +* Added a benchmark suite. +* Implemented negative character classes (e.g. [^a-z]). +* Project moved from BitBucket to GitHub. + +Small Changes: + +* Code generated for the character classes is now regexp-based (= simpler and + more scalable). +* Added \uFEFF (BOM) to the definition of whitespace in the metagrammar. +* When building a parser, left-recursive rules (both direct and indirect) are + reported as errors. +* When building a parser, missing rules are reported as errors. +* Expected items in the error messages do not contain duplicates and they are + sorted. +* Fixed several bugs in the example arithmetics grammar. +* Converted README to GitHub Flavored Markdown and improved it. +* Added CHANGELOG. +* Internal code improvements. + +0.3 (2010-03-14) +---------------- + +* Wrote README. +* Bootstrapped the grammar parser. +* Metagrammar recognizes JavaScript-like comments. +* Changed standard grammar extension from .peg to .pegjs (it is more specific). +* Simplified the example arithmetics grammar + added comment. +* Fixed a bug with reporting of invalid ranges such as [b-a] in the metagrammar. +* Fixed --start vs. --start-rule inconsistency between help and actual option + processing code. +* Avoided ugliness in QUnit output. +* Fixed typo in help: "parserVar" -> "parser_var". +* Internal code improvements. + +0.2.1 (2010-03-08) +------------------ + +* Added "pegjs-" prefix to the name of the minified runtime file. + +0.2 (2010-03-08) +---------------- + +* Added Rakefile that builds minified runtime using Google Closure Compiler API. +* Removed trailing commas in object initializers (Google Closure does not like + them). + +0.1 (2010-03-08) +---------------- + +* Initial release. http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/pegjs/LICENSE ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/pegjs/LICENSE b/bin/node_modules/xcode/node_modules/pegjs/LICENSE new file mode 100644 index 0000000..48ab3e5 --- /dev/null +++ b/bin/node_modules/xcode/node_modules/pegjs/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2010-2011 David Majda + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/pegjs/README.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/pegjs/README.md b/bin/node_modules/xcode/node_modules/pegjs/README.md new file mode 100644 index 0000000..7a4c17e --- /dev/null +++ b/bin/node_modules/xcode/node_modules/pegjs/README.md @@ -0,0 +1,226 @@ +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. + +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 + +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. + +Installation +------------ + +### Command Line / Server-side + +To use command-line version, install [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) first. You can then install PEG.js: + + $ npm install pegjs + +Once installed, you can use the `pegjs` command to generate your parser from a grammar and use the JavaScript API from Node.js. + +### Browser + +[Download](http://pegjs.majda.cz/#download) the PEG.js library (regular or minified version) and include it in your web page or application using the `<script>` tag. + +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. + +### Command Line + +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: + + $ 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. + +### JavaScript API + +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 `<script>` tag. The API will be available through the `PEG` global object. + +To generate a parser, call the `PEG.buildParser` method and pass your grammar as a parameter: + + var parser = PEG.buildParser("start = ('a' / 'b')+"); + +The method will return generated parser object or throw an exception if the grammar is invalid. The exception will contain `message` property with more details about the error. + +To get parserâs source code, call the `toSource` method on the parser. + +Using the Parser +---------------- + +Using the generated parser is simple â just call its `parse` method and pass an input string as a parameter. The method will return a parse result (the exact value depends on the grammar used to build the parser) or throw an exception if the input is invalid. The exception will contain `line`, `column` and `message` properties with more details about the error. + + parser.parse("abba"); // returns ["a", "b", "b", "a"] + + parser.parse("abcd"); // throws an exception + +You can also start parsing from a specific rule in the grammar. Just pass the rule name to the `parse` method as a second parameter. + +Grammar Syntax and Semantics +---------------------------- + +The grammar syntax is similar to JavaScript in that it is not line-oriented and ignores whitespace between tokens. You can also use JavaScript-style comments (`// ...` and `/* ... */`). + +Let's look at example grammar that recognizes simple arithmetic expressions like `2*(3+4)`. A parser generated from this grammar computes their values. + + start + = additive + + additive + = left:multiplicative "+" right:additive { return left + right; } + / multiplicative + + multiplicative + = left:primary "*" right:multiplicative { return left * right; } + / primary + + primary + = integer + / "(" additive:additive ")" { return additive; } + + integer "integer" + = digits:[0-9]+ { return parseInt(digits.join(""), 10); } + +On the top level, the grammar consists of *rules* (in our example, there are five of them). Each rule has a *name* (e.g. `integer`) that identifies the rule, and a *parsing expression* (e.g. `digits:[0-9]+ { return parseInt(digits.join(""), 10); }`) that defines a pattern to match against the input text and possibly contains some JavaScript code that determines what happens when the pattern matches successfully. A rule can also contain *human-readable name* that is used in error messages (in our example, only the `integer` rule has a human-readable name). The parsing starts at the first rule, which is also called the *start rule*. + +A rule name must be a JavaScript identifier. It is followed by an equality sign (â=â) and a parsing expression. If the rule has a human-readable name, it is written as a JavaScript string between the name and separating equality sign. Rules need to be separated only by whitespace (their beginning is easily recognizable), but a semicolon (â;â) after the parsing expression is allowed. + +Rules can be preceded by an *initializer* â a piece of JavaScript code in curly braces (â{â and â}â). This code is executed before the generated parser starts parsing. All variables and functions defined in the initializer are accessible in rule actions and semantic predicates. Curly braces in the initializer code must be balanced. + +The parsing expressions of the rules are used to match the input text to the grammar. There are various types of expressions â matching characters or character classes, indicating optional parts and repetition, etc. Expressions can also contain references to other rules. See detailed description below. + +If an expression successfully matches a part of the text when running the generated parser, it produces a *match result*, which is a JavaScript value. For example: + + * An expression matching a literal string produces a JavaScript string containing matched part of the input. + * An expression matching repeated occurrence of some subexpression produces a JavaScript array with all the matches. + +The match results propagate through the rules when the rule names are used in expressions, up to the start rule. The generated parser returns start rule's match result when parsing is successful. + +One special case of parser expression is a *parser action* â a piece of JavaScript code inside curly braces (â{â and â}â) that takes match results of some of the the preceding expressions and returns a JavaScript value. This value is considered match result of the preceding expression (in other words, the parser action is a match result transformer). + +In our arithmetics example, there are many parser actions. Consider the action in expression `digits:[0-9]+ { return parseInt(digits.join(""), 10); }`. It takes the match result of the expression [0-9]+, which is an array of strings containing digits, as its parameter. It joins the digits together to form a number and converts it to a JavaScript `number` object. + +### Parsing Expression Types + +There are several types of parsing expressions, some of them containing subexpressions and thus forming a recursive structure: + +#### "*literal*"<br>'*literal*' + +Match exact literal string and return it. The string syntax is the same as in JavaScript. + +#### . + +Match exactly one character and return it as a string. + +#### [*characters*] + +Match one character from a set and return it as a string. The characters in the list can be escaped in exactly the same way as in JavaScript string. The list of characters can also contain ranges (e.g. `[a-z]` means âall lowercase lettersâ). Preceding the characters with `^` inverts the matched set (e.g. `[^a-z]` means âall character but lowercase lettersâ). + +#### *rule* + +Match a parsing expression of a rule recursively and return its match result. + +#### ( *expression* ) + +Match a subexpression and return its match result. + +#### *expression* \* + +Match zero or more repetitions of the expression and return their match results in an array. The matching is greedy, i.e. the parser tries to match the expression as many times as possible. + +#### *expression* + + +Match one or more repetitions of the expression and return their match results in an array. The matching is greedy, i.e. the parser tries to match the expression as many times as possible. + +#### *expression* ? + +Try to match the expression. If the match succeeds, return its match result, otherwise return an empty string. + +#### & *expression* + +Try to match the expression. If the match succeeds, just return an empty string and do not advance the parser position, otherwise consider the match failed. + +#### ! *expression* + +Try to match the expression and. If the match does not succeed, just return an empty string and do not advance the parser position, otherwise consider the match failed. + +#### & { *predicate* } + +The predicate is a piece of JavaScript code that is executed as if it was inside a function. It should return some JavaScript value using the `return` statement. If the returned value evaluates to `true` in boolean context, just return an empty string and do not advance the parser position; otherwise consider the match failed. + +The code inside the predicate has access to all variables and functions defined in the initializer at the beginning of the grammar. Curly braces in the predicate code must be balanced. + +#### ! { *predicate* } + +The predicate is a piece of JavaScript code that is executed as if it was inside a function. It should return some JavaScript value using the `return` statement. If the returned value evaluates to `false` in boolean context, just return an empty string and do not advance the parser position; otherwise consider the match failed. + +The code inside the predicate has access to all variables and functions defined in the initializer at the beginning of the grammar. Curly braces in the predicate code must be balanced. + +#### *label* : *expression* + +Match the expression and remember its match result under given lablel. The label must be a JavaScript identifier. + +Labeled expressions are useful together with actions, where saved match results can be accessed by action's JavaScript code. + +#### *expression<sub>1</sub>* *expression<sub>2</sub>* ... *expression<sub>n</sub>* + +Match a sequence of expressions and return their match results in an array. + +#### *expression* { *action* } + +Match the expression. If the match is successful, run the action, otherwise consider the match failed. + +The action is a piece of JavaScript code that is executed as if it was inside a function. It gets the match results of labeled expressions in preceding expression as its arguments. The action should return some JavaScript value using the `return` statement. This value is considered match result of the preceding expression. The action can return `null` to indicate a match failure. + +The code inside the action has access to all variables and functions defined in the initializer at the beginning of the grammar. Curly braces in the action code must be balanced. + +#### *expression<sub>1</sub>* / *expression<sub>2</sub>* / ... / *expression<sub>n</sub>* + +Try to match the first expression, if it does not succeed, try the second one, etc. Return the match result of the first successfully matched expression. If no expression matches, consider the match failed. + +Compatibility +------------- + +Both the parser generator and generated parsers should run well in the following environments: + + * Node.js 0.4.4+ + * IE 6+ + * Firefox + * Chrome + * Safari + * Opera + +Development +----------- + + * [Project website](https://pegjs.majda.cz/) + * [Source code](https://github.com/dmajda/pegjs) + * [Issue tracker](https://github.com/dmajda/pegjs/issues) + * [Google Group](http://groups.google.com/group/pegjs) + * [Twitter](http://twitter.com/peg_js) + +PEG.js is developed by [David Majda](http://majda.cz/) ([@dmajda](http://twitter.com/dmajda)). 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 patch or GitHub pull request. + +Note that PEG.js is still very much work in progress. There are no compatibility guarantees until version 1.0. http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/pegjs/VERSION ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/pegjs/VERSION b/bin/node_modules/xcode/node_modules/pegjs/VERSION new file mode 100644 index 0000000..b616048 --- /dev/null +++ b/bin/node_modules/xcode/node_modules/pegjs/VERSION @@ -0,0 +1 @@ +0.6.2 http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/pegjs/bin/pegjs ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/pegjs/bin/pegjs b/bin/node_modules/xcode/node_modules/pegjs/bin/pegjs new file mode 100644 index 0000000..c24246e --- /dev/null +++ b/bin/node_modules/xcode/node_modules/pegjs/bin/pegjs @@ -0,0 +1,142 @@ +#!/usr/bin/env node + +var sys = require("sys"); +var fs = require("fs"); +var PEG = require("../lib/peg"); + +/* Helpers */ + +function printVersion() { + sys.puts("PEG.js " + PEG.VERSION); +} + +function printHelp() { + sys.puts("Usage: pegjs [options] [--] [<input_file>] [<output_file>]"); + sys.puts(""); + sys.puts("Generates a parser from the PEG grammar specified in the <input_file> and"); + sys.puts("writes it to the <output_file>."); + sys.puts(""); + sys.puts("If the <output_file> is omitted, its name is generated by changing the"); + sys.puts("<input_file> extension to \".js\". If both <input_file> and <output_file> are"); + sys.puts("omitted, standard input and output are used."); + sys.puts(""); + sys.puts("Options:"); + sys.puts(" -e, --export-var <variable> name of the variable where the parser object"); + sys.puts(" will be stored (default: \"module.exports\")"); + sys.puts(" -v, --version print version information and exit"); + sys.puts(" -h, --help print help and exit"); +} + +function exitSuccess() { + process.exit(0); +} + +function exitFailure() { + process.exit(1); +} + +function abort(message) { + sys.error(message); + exitFailure(); +} + +/* Arguments */ + +var args = process.argv.slice(2); // Trim "node" and the script path. + +function isOption(arg) { + return /-.+/.test(arg); +} + +function nextArg() { + args.shift(); +} + +/* Files */ + +function readStream(inputStream, callback) { + var input = ""; + inputStream.on("data", function(data) { input += data; }); + inputStream.on("end", function() { callback(input); }); +} + +/* Main */ + +/* This makes the generated parser a CommonJS module by default. */ +var exportVar = "module.exports"; + +while (args.length > 0 && isOption(args[0])) { + switch (args[0]) { + case "-e": + case "--export-var": + nextArg(); + if (args.length === 0) { + abort("Missing parameter of the -e/--export-var option."); + } + exportVar = args[0]; + break; + + case "-v": + case "--version": + printVersion(); + exitSuccess(); + break; + + case "-h": + case "--help": + printHelp(); + exitSuccess(); + break; + + case "--": + nextArg(); + break; + + default: + abort("Unknown option: " + args[0] + "."); + } + nextArg(); +} + +switch (args.length) { + case 0: + var inputStream = process.openStdin(); + var outputStream = process.stdout; + break; + + case 1: + case 2: + var inputFile = args[0]; + var inputStream = fs.createReadStream(inputFile); + inputStream.on("error", function() { + abort("Can't read from file \"" + inputFile + "\"."); + }); + + var outputFile = args.length == 1 + ? args[0].replace(/\.[^.]*$/, ".js") + : args[1]; + var outputStream = fs.createWriteStream(outputFile); + outputStream.on("error", function() { + abort("Can't write to file \"" + outputFile + "\"."); + }); + + break; + + default: + abort("Too many arguments."); +} + +readStream(inputStream, function(input) { + try { + var parser = PEG.buildParser(input); + } catch (e) { + if (e.line !== undefined && e.column !== undefined) { + abort(e.line + ":" + e.column + ": " + e.message); + } else { + abort(e.message); + } + } + + outputStream.write(exportVar + " = " + parser.toSource() + ";\n"); + outputStream.end(); +}); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/pegjs/examples/arithmetics.pegjs ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/pegjs/examples/arithmetics.pegjs b/bin/node_modules/xcode/node_modules/pegjs/examples/arithmetics.pegjs new file mode 100644 index 0000000..52fae2a --- /dev/null +++ b/bin/node_modules/xcode/node_modules/pegjs/examples/arithmetics.pegjs @@ -0,0 +1,22 @@ +/* + * Classic example grammar, which recognizes simple arithmetic expressions like + * "2*(3+4)". The parser generated from this grammar then computes their value. + */ + +start + = additive + +additive + = left:multiplicative "+" right:additive { return left + right; } + / multiplicative + +multiplicative + = left:primary "*" right:multiplicative { return left * right; } + / primary + +primary + = integer + / "(" additive:additive ")" { return additive; } + +integer "integer" + = digits:[0-9]+ { return parseInt(digits.join(""), 10); } http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/26cca47e/bin/node_modules/xcode/node_modules/pegjs/examples/css.pegjs ---------------------------------------------------------------------- diff --git a/bin/node_modules/xcode/node_modules/pegjs/examples/css.pegjs b/bin/node_modules/xcode/node_modules/pegjs/examples/css.pegjs new file mode 100644 index 0000000..5593d3c --- /dev/null +++ b/bin/node_modules/xcode/node_modules/pegjs/examples/css.pegjs @@ -0,0 +1,554 @@ +/* + * CSS parser based on the grammar described at http://www.w3.org/TR/CSS2/grammar.html. + * + * The parser builds a tree representing the parsed CSS, composed of basic + * JavaScript values, arrays and objects (basically JSON). It can be easily + * used by various CSS processors, transformers, etc. + * + * Note that the parser does not handle errors in CSS according to the + * specification -- many errors which it should recover from (e.g. malformed + * declarations or unexpected end of stylesheet) are simply fatal. This is a + * result of straightforward rewrite of the CSS grammar to PEG.js and it should + * be fixed sometimes. + */ + +/* ===== Syntactical Elements ===== */ + +start + = stylesheet:stylesheet comment* { return stylesheet; } + +stylesheet + = charset:(CHARSET_SYM STRING ";")? (S / CDO / CDC)* + imports:(import (CDO S* / CDC S*)*)* + rules:((ruleset / media / page) (CDO S* / CDC S*)*)* { + var importsConverted = []; + for (var i = 0; i < imports.length; i++) { + importsConverted.push(imports[i][0]); + } + + var rulesConverted = []; + for (i = 0; i < rules.length; i++) { + rulesConverted.push(rules[i][0]); + } + + return { + type: "stylesheet", + charset: charset !== "" ? charset[1] : null, + imports: importsConverted, + rules: rulesConverted + }; + } + +import + = IMPORT_SYM S* href:(STRING / URI) S* media:media_list? ";" S* { + return { + type: "import_rule", + href: href, + media: media !== "" ? media : [] + }; + } + +media + = MEDIA_SYM S* media:media_list "{" S* rules:ruleset* "}" S* { + return { + type: "media_rule", + media: media, + rules: rules + }; + } + +media_list + = head:medium tail:("," S* medium)* { + var result = [head]; + for (var i = 0; i < tail.length; i++) { + result.push(tail[i][2]); + } + return result; + } + +medium + = ident:IDENT S* { return ident; } + +page + = PAGE_SYM S* qualifier:pseudo_page? + "{" S* + declarationsHead:declaration? + declarationsTail:(";" S* declaration?)* + "}" S* { + var declarations = declarationsHead !== "" ? [declarationsHead] : []; + for (var i = 0; i < declarationsTail.length; i++) { + if (declarationsTail[i][2] !== "") { + declarations.push(declarationsTail[i][2]); + } + } + + return { + type: "page_rule", + qualifier: qualifier !== "" ? qualifier : null, + declarations: declarations + }; + } + +pseudo_page + = ":" ident:IDENT S* { return ident; } + +operator + = "/" S* { return "/"; } + / "," S* { return ","; } + +combinator + = "+" S* { return "+"; } + / ">" S* { return ">"; } + +unary_operator + = "+" + / "-" + +property + = ident:IDENT S* { return ident; } + +ruleset + = selectorsHead:selector + selectorsTail:("," S* selector)* + "{" S* + declarationsHead:declaration? + declarationsTail:(";" S* declaration?)* + "}" S* { + var selectors = [selectorsHead]; + for (var i = 0; i < selectorsTail.length; i++) { + selectors.push(selectorsTail[i][2]); + } + + var declarations = declarationsHead !== "" ? [declarationsHead] : []; + for (i = 0; i < declarationsTail.length; i++) { + if (declarationsTail[i][2] !== "") { + declarations.push(declarationsTail[i][2]); + } + } + + return { + type: "ruleset", + selectors: selectors, + declarations: declarations + }; + } + +selector + = left:simple_selector S* combinator:combinator right:selector { + return { + type: "selector", + combinator: combinator, + left: left, + right: right + }; + } + / left:simple_selector S* right:selector { + return { + type: "selector", + combinator: " ", + left: left, + right: right + }; + } + / selector:simple_selector S* { return selector; } + +simple_selector + = element:element_name + qualifiers:( + id:HASH { return { type: "ID selector", id: id.substr(1) }; } + / class + / attrib + / pseudo + )* { + return { + type: "simple_selector", + element: element, + qualifiers: qualifiers + }; + } + / qualifiers:( + id:HASH { return { type: "ID selector", id: id.substr(1) }; } + / class + / attrib + / pseudo + )+ { + return { + type: "simple_selector", + element: "*", + qualifiers: qualifiers + }; + } + +class + = "." class_:IDENT { return { type: "class_selector", "class": class_ }; } + +element_name + = IDENT / '*' + +attrib + = "[" S* + attribute:IDENT S* + operatorAndValue:( + ('=' / INCLUDES / DASHMATCH) S* + (IDENT / STRING) S* + )? + "]" { + return { + type: "attribute_selector", + attribute: attribute, + operator: operatorAndValue !== "" ? operatorAndValue[0] : null, + value: operatorAndValue !== "" ? operatorAndValue[2] : null + }; + } + +pseudo + = ":" + value:( + name:FUNCTION S* params:(IDENT S*)? ")" { + return { + type: "function", + name: name, + params: params !== "" ? [params[0]] : [] + }; + } + / IDENT + ) { + /* + * The returned object has somewhat vague property names and values because + * the rule matches both pseudo-classes and pseudo-elements (they look the + * same at the syntactic level). + */ + return { + type: "pseudo_selector", + value: value + }; + } + +declaration + = property:property ":" S* expression:expr important:prio? { + return { + type: "declaration", + property: property, + expression: expression, + important: important !== "" ? true : false + }; + } + +prio + = IMPORTANT_SYM S* + +expr + = head:term tail:(operator? term)* { + var result = head; + for (var i = 0; i < tail.length; i++) { + result = { + type: "expression", + operator: tail[i][0], + left: result, + right: tail[i][1] + }; + } + return result; + } + +term + = operator:unary_operator? + value:( + EMS S* + / EXS S* + / LENGTH S* + / ANGLE S* + / TIME S* + / FREQ S* + / PERCENTAGE S* + / NUMBER S* + ) { return { type: "value", value: operator + value[0] }; } + / value:URI S* { return { type: "uri", value: value }; } + / function + / hexcolor + / value:STRING S* { return { type: "string", value: value }; } + / value:IDENT S* { return { type: "ident", value: value }; } + +function + = name:FUNCTION S* params:expr ")" S* { + return { + type: "function", + name: name, + params: params + }; + } + +hexcolor + = value:HASH S* { return { type: "hexcolor", value: value}; } + +/* ===== Lexical Elements ===== */ + +/* Macros */ + +h + = [0-9a-fA-F] + +nonascii + = [\x80-\xFF] + +unicode + = "\\" h1:h h2:h? h3:h? h4:h? h5:h? h6:h? ("\r\n" / [ \t\r\n\f])? { + return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4 + h5 + h6)); + } + +escape + = unicode + / "\\" char_:[^\r\n\f0-9a-fA-F] { return char_; } + +nmstart + = [_a-zA-Z] + / nonascii + / escape + +nmchar + = [_a-zA-Z0-9-] + / nonascii + / escape + +integer + = digits:[0-9]+ { return parseInt(digits.join("")); } + +float + = before:[0-9]* "." after:[0-9]+ { + return parseFloat(before.join("") + "." + after.join("")); + } + +string1 + = '"' chars:([^\n\r\f\\"] / "\\" nl:nl { return nl } / escape)* '"' { + return chars.join(""); + } + +string2 + = "'" chars:([^\n\r\f\\'] / "\\" nl:nl { return nl } / escape)* "'" { + return chars.join(""); + } + +comment + = "/*" [^*]* "*"+ ([^/*] [^*]* "*"+)* "/" + +ident + = dash:"-"? nmstart:nmstart nmchars:nmchar* { + return dash + nmstart + nmchars.join(""); + } + +name + = nmchars:nmchar+ { return nmchars.join(""); } + +num + = float + / integer + +string + = string1 + / string2 + +url + = chars:([!#$%&*-~] / nonascii / escape)* { return chars.join(""); } + +s + = [ \t\r\n\f]+ + +w + = s? + +nl + = "\n" + / "\r\n" + / "\r" + / "\f" + +A + = [aA] + / "\\" "0"? "0"? "0"? "0"? "41" ("\r\n" / [ \t\r\n\f])? { return "A"; } + / "\\" "0"? "0"? "0"? "0"? "61" ("\r\n" / [ \t\r\n\f])? { return "a"; } + +C + = [cC] + / "\\" "0"? "0"? "0"? "0"? "43" ("\r\n" / [ \t\r\n\f])? { return "C"; } + / "\\" "0"? "0"? "0"? "0"? "63" ("\r\n" / [ \t\r\n\f])? { return "c"; } + +D + = [dD] + / "\\" "0"? "0"? "0"? "0"? "44" ("\r\n" / [ \t\r\n\f])? { return "D"; } + / "\\" "0"? "0"? "0"? "0"? "64" ("\r\n" / [ \t\r\n\f])? { return "d"; } + +E + = [eE] + / "\\" "0"? "0"? "0"? "0"? "45" ("\r\n" / [ \t\r\n\f])? { return "E"; } + / "\\" "0"? "0"? "0"? "0"? "65" ("\r\n" / [ \t\r\n\f])? { return "e"; } + +G + = [gG] + / "\\" "0"? "0"? "0"? "0"? "47" ("\r\n" / [ \t\r\n\f])? { return "G"; } + / "\\" "0"? "0"? "0"? "0"? "67" ("\r\n" / [ \t\r\n\f])? { return "g"; } + / "\\" char_:[gG] { return char_; } + +H + = h:[hH] + / "\\" "0"? "0"? "0"? "0"? "48" ("\r\n" / [ \t\r\n\f])? { return "H"; } + / "\\" "0"? "0"? "0"? "0"? "68" ("\r\n" / [ \t\r\n\f])? { return "h"; } + / "\\" char_:[hH] { return char_; } + +I + = i:[iI] + / "\\" "0"? "0"? "0"? "0"? "49" ("\r\n" / [ \t\r\n\f])? { return "I"; } + / "\\" "0"? "0"? "0"? "0"? "69" ("\r\n" / [ \t\r\n\f])? { return "i"; } + / "\\" char_:[iI] { return char_; } + +K + = [kK] + / "\\" "0"? "0"? "0"? "0"? "4" [bB] ("\r\n" / [ \t\r\n\f])? { return "K"; } + / "\\" "0"? "0"? "0"? "0"? "6" [bB] ("\r\n" / [ \t\r\n\f])? { return "k"; } + / "\\" char_:[kK] { return char_; } + +L + = [lL] + / "\\" "0"? "0"? "0"? "0"? "4" [cC] ("\r\n" / [ \t\r\n\f])? { return "L"; } + / "\\" "0"? "0"? "0"? "0"? "6" [cC] ("\r\n" / [ \t\r\n\f])? { return "l"; } + / "\\" char_:[lL] { return char_; } + +M + = [mM] + / "\\" "0"? "0"? "0"? "0"? "4" [dD] ("\r\n" / [ \t\r\n\f])? { return "M"; } + / "\\" "0"? "0"? "0"? "0"? "6" [dD] ("\r\n" / [ \t\r\n\f])? { return "m"; } + / "\\" char_:[mM] { return char_; } + +N + = [nN] + / "\\" "0"? "0"? "0"? "0"? "4" [eE] ("\r\n" / [ \t\r\n\f])? { return "N"; } + / "\\" "0"? "0"? "0"? "0"? "6" [eE] ("\r\n" / [ \t\r\n\f])? { return "n"; } + / "\\" char_:[nN] { return char_; } + +O + = [oO] + / "\\" "0"? "0"? "0"? "0"? "4" [fF] ("\r\n" / [ \t\r\n\f])? { return "O"; } + / "\\" "0"? "0"? "0"? "0"? "6" [fF] ("\r\n" / [ \t\r\n\f])? { return "o"; } + / "\\" char_:[oO] { return char_; } + +P + = [pP] + / "\\" "0"? "0"? "0"? "0"? "50" ("\r\n" / [ \t\r\n\f])? { return "P"; } + / "\\" "0"? "0"? "0"? "0"? "70" ("\r\n" / [ \t\r\n\f])? { return "p"; } + / "\\" char_:[pP] { return char_; } + +R + = [rR] + / "\\" "0"? "0"? "0"? "0"? "52" ("\r\n" / [ \t\r\n\f])? { return "R"; } + / "\\" "0"? "0"? "0"? "0"? "72" ("\r\n" / [ \t\r\n\f])? { return "r"; } + / "\\" char_:[rR] { return char_; } + +S_ + = [sS] + / "\\" "0"? "0"? "0"? "0"? "53" ("\r\n" / [ \t\r\n\f])? { return "S"; } + / "\\" "0"? "0"? "0"? "0"? "73" ("\r\n" / [ \t\r\n\f])? { return "s"; } + / "\\" char_:[sS] { return char_; } + +T + = [tT] + / "\\" "0"? "0"? "0"? "0"? "54" ("\r\n" / [ \t\r\n\f])? { return "T"; } + / "\\" "0"? "0"? "0"? "0"? "74" ("\r\n" / [ \t\r\n\f])? { return "t"; } + / "\\" char_:[tT] { return char_; } + +U + = [uU] + / "\\" "0"? "0"? "0"? "0"? "55" ("\r\n" / [ \t\r\n\f])? { return "U"; } + / "\\" "0"? "0"? "0"? "0"? "75" ("\r\n" / [ \t\r\n\f])? { return "u"; } + / "\\" char_:[uU] { return char_; } + +X + = [xX] + / "\\" "0"? "0"? "0"? "0"? "58" ("\r\n" / [ \t\r\n\f])? { return "X"; } + / "\\" "0"? "0"? "0"? "0"? "78" ("\r\n" / [ \t\r\n\f])? { return "x"; } + / "\\" char_:[xX] { return char_; } + +Z + = [zZ] + / "\\" "0"? "0"? "0"? "0"? "5" [aA] ("\r\n" / [ \t\r\n\f])? { return "Z"; } + / "\\" "0"? "0"? "0"? "0"? "7" [aA] ("\r\n" / [ \t\r\n\f])? { return "z"; } + / "\\" char_:[zZ] { return char_; } + +/* Tokens */ + +S "whitespace" + = comment* s + +CDO "<!--" + = comment* "<!--" + +CDC "-->" + = comment* "-->" + +INCLUDES "~=" + = comment* "~=" + +DASHMATCH "|=" + = comment* "|=" + +STRING "string" + = comment* string:string { return string; } + +IDENT "identifier" + = comment* ident:ident { return ident; } + +HASH "hash" + = comment* "#" name:name { return "#" + name; } + +IMPORT_SYM "@import" + = comment* "@" I M P O R T + +PAGE_SYM "@page" + = comment* "@" P A G E + +MEDIA_SYM "@media" + = comment* "@" M E D I A + +CHARSET_SYM "@charset" + = comment* "@charset " + +/* Note: We replace "w" with "s" here to avoid infinite recursion. */ +IMPORTANT_SYM "!important" + = comment* "!" (s / comment)* I M P O R T A N T { return "!important"; } + +EMS "length" + = comment* num:num e:E m:M { return num + e + m; } + +EXS "length" + = comment* num:num e:E x:X { return num + e + x; } + +LENGTH "length" + = comment* num:num unit:(P X / C M / M M / I N / P T / P C) { + return num + unit.join(""); + } + +ANGLE "angle" + = comment* num:num unit:(D E G / R A D / G R A D) { + return num + unit.join(""); + } + +TIME "time" + = comment* num:num unit:(m:M s:S_ { return m + s; } / S_) { + return num + unit; + } + +FREQ "frequency" + = comment* num:num unit:(H Z / K H Z) { return num + unit.join(""); } + +DIMENSION "dimension" + = comment* num:num unit:ident { return num + unit; } + +PERCENTAGE "percentage" + = comment* num:num "%" { return num + "%"; } + +NUMBER "number" + = comment* num:num { return num; } + +URI "uri" + = comment* U R L "(" w value:(string / url) w ")" { return value; } + +FUNCTION "function" + = comment* name:ident "(" { return name; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
