From 1c53865e53e645ec3615fc0158ca1c3af4e4f992 Mon Sep 17 00:00:00 2001 From: Steve Shreeve Date: Wed, 16 Jul 2025 09:22:27 -0600 Subject: [PATCH 1/4] Not needed (for this branch) --- .gitignore | 5 - .npmignore | 4 - .travis.yml | 3 - CONTRIBUTING.md | 29 - Makefile | 20 - README.md | 158 - entry.js | 3 - lib/cli.js | 187 - lib/util/set.js | 93 - lib/util/typal.js | 90 - ports/comments.jison | 199 - ports/comments.js | 479 - ports/csharp/Jison/Jison.sln | 22 - ports/csharp/Jison/Jison.v11.suo | Bin 73216 -> 0 bytes ports/csharp/Jison/Jison/App.config | 6 - ports/csharp/Jison/Jison/Jison.csproj | 128 - ports/csharp/Jison/Jison/Jison.csproj.user | 13 - .../Jison/Jison/Properties/AssemblyInfo.cs | 36 - .../Jison/Properties/Resources.Designer.cs | 63 - .../Jison/Jison/Properties/Resources.resx | 101 - ports/csharp/Jison/Jison/Template.cs | 750 -- ports/csharp/Jison/Jison/Test.cs | 41 - ports/csharp/Jison/Jison/Test/Cell.cs | 64 - ports/csharp/Jison/Jison/Test/Expression.cs | 132 - ports/csharp/Jison/Jison/Test/Formula.cs | 2911 ----- ports/csharp/Jison/Jison/Test/Functions.cs | 47 - ports/csharp/Jison/Jison/Test/Location.cs | 114 - .../csharp/Jison/Jison/Test/RowDictionary.cs | 13 - ports/csharp/Jison/Jison/Test/Spreadsheet.cs | 73 - .../Jison/Jison/Test/SpreadsheetDictionary.cs | 19 - .../Jison/Test/SpreadsheetsDictionary.cs | 10 - ports/csharp/Jison/Jison/Test/formula.jison | 640 -- ports/csharp/Jison/Jison/Test/formula.js | 1303 --- ports/csharp/Jison/Jison/bin/Debug/Jison.exe | Bin 49664 -> 0 bytes .../Jison/Jison/bin/Debug/Jison.exe.config | 6 - ports/csharp/Jison/Jison/bin/Debug/Jison.pdb | Bin 87552 -> 0 bytes .../Jison/Jison/bin/Debug/Jison.vshost.exe | Bin 22984 -> 0 bytes .../Jison/bin/Debug/Jison.vshost.exe.config | 6 - ports/csharp/Jison/Jison/csharp.js | 274 - ports/php/php.js | 268 - ports/php/readme | 43 - ports/php/template.php | 615 -- tests/all-tests.js | 4 - tests/parser/actions.js | 528 - tests/parser/api.js | 447 - tests/parser/errorlab.js | 205 - tests/parser/generator.js | 381 - tests/parser/lalr.js | 183 - tests/parser/lr0.js | 72 - tests/parser/lr1.js | 176 - tests/parser/parser-tests.js | 13 - tests/parser/precedence.js | 237 - tests/parser/slr.js | 52 - tests/parser/tables.js | 126 - tests/performance.js | 108 - tests/setup.js | 2 - web/.gitignore | 2 - web/README | 1 - web/Rakefile | 1 - web/Rules | 78 - web/config.yaml | 41 - web/content/about.html | 12 - web/content/assets/js/calculator.js | 346 - web/content/assets/js/es5.js | 233 - web/content/assets/js/jquery.js | 9472 ----------------- web/content/assets/js/json2.js | 334 - web/content/assets/js/lib/jison.js | 1502 --- web/content/assets/js/lib/jison/bnf.js | 52 - web/content/assets/js/lib/jison/jisonlex.js | 22 - web/content/assets/js/lib/jison/json2jison.js | 145 - web/content/assets/js/lib/jison/lexer.js | 248 - .../assets/js/lib/jison/util/bnf-parser.js | 442 - .../assets/js/lib/jison/util/lex-parser.js | 456 - web/content/assets/js/lib/jison/util/set.js | 94 - web/content/assets/js/lib/jison/util/typal.js | 90 - web/content/assets/js/try.js | 84 - web/content/assets/js/usf.js | 268 - web/content/assets/js/webtoolkit.base64.js | 142 - web/content/assets/pngs/jison.png | Bin 74273 -> 0 bytes web/content/assets/pngs/jison_x1.png | Bin 55471 -> 0 bytes web/content/assets/pngs/usf.jpg | Bin 4368 -> 0 bytes web/content/assets/pngs/usflogo.jpg | Bin 4368 -> 0 bytes web/content/assets/styles/style.css | 87 - web/content/assets/styles/try.css | 84 - web/content/assets/styles/usf.css | 91 - web/content/assets/styles/usflogo.jpg | Bin 4368 -> 0 bytes web/content/community.html | 8 - web/content/demos.html | 13 - web/content/demos/calc.html | 86 - web/content/docs.html | 438 - web/content/index.html | 61 - web/content/install.html | 5 - web/content/try.html | 112 - web/content/try/usf.html | 92 - web/jison/examples/ansic.jison | 415 - web/jison/examples/basic.jison | 11 - web/jison/examples/basic2.jison | 10 - web/jison/examples/basic2_lex.json | 15 - web/jison/examples/classy.json | 105 - web/jison/examples/classy_ast.json | 126 - web/jison/examples/dism.jison | 39 - web/jison/examples/dism_lr0.jison | 35 - web/jison/examples/json.js | 87 - web/jison/examples/jsonAST.js | 90 - web/jison/examples/precedence.jison | 24 - web/jison/examples/reduce_conflict.jison | 23 - web/jison/index.html | 100 - web/jison/main.js | 249 - web/jison/states.html | 113 - web/jison/usf.html | 99 - web/layouts/default.html | 37 - web/lib/default.rb | 2 - 112 files changed, 28224 deletions(-) delete mode 100644 .npmignore delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 README.md delete mode 100644 entry.js delete mode 100755 lib/cli.js delete mode 100644 lib/util/set.js delete mode 100644 lib/util/typal.js delete mode 100644 ports/comments.jison delete mode 100644 ports/comments.js delete mode 100644 ports/csharp/Jison/Jison.sln delete mode 100644 ports/csharp/Jison/Jison.v11.suo delete mode 100644 ports/csharp/Jison/Jison/App.config delete mode 100644 ports/csharp/Jison/Jison/Jison.csproj delete mode 100644 ports/csharp/Jison/Jison/Jison.csproj.user delete mode 100644 ports/csharp/Jison/Jison/Properties/AssemblyInfo.cs delete mode 100644 ports/csharp/Jison/Jison/Properties/Resources.Designer.cs delete mode 100644 ports/csharp/Jison/Jison/Properties/Resources.resx delete mode 100644 ports/csharp/Jison/Jison/Template.cs delete mode 100644 ports/csharp/Jison/Jison/Test.cs delete mode 100644 ports/csharp/Jison/Jison/Test/Cell.cs delete mode 100644 ports/csharp/Jison/Jison/Test/Expression.cs delete mode 100644 ports/csharp/Jison/Jison/Test/Formula.cs delete mode 100644 ports/csharp/Jison/Jison/Test/Functions.cs delete mode 100644 ports/csharp/Jison/Jison/Test/Location.cs delete mode 100644 ports/csharp/Jison/Jison/Test/RowDictionary.cs delete mode 100644 ports/csharp/Jison/Jison/Test/Spreadsheet.cs delete mode 100644 ports/csharp/Jison/Jison/Test/SpreadsheetDictionary.cs delete mode 100644 ports/csharp/Jison/Jison/Test/SpreadsheetsDictionary.cs delete mode 100644 ports/csharp/Jison/Jison/Test/formula.jison delete mode 100644 ports/csharp/Jison/Jison/Test/formula.js delete mode 100755 ports/csharp/Jison/Jison/bin/Debug/Jison.exe delete mode 100644 ports/csharp/Jison/Jison/bin/Debug/Jison.exe.config delete mode 100644 ports/csharp/Jison/Jison/bin/Debug/Jison.pdb delete mode 100644 ports/csharp/Jison/Jison/bin/Debug/Jison.vshost.exe delete mode 100644 ports/csharp/Jison/Jison/bin/Debug/Jison.vshost.exe.config delete mode 100644 ports/csharp/Jison/Jison/csharp.js delete mode 100644 ports/php/php.js delete mode 100644 ports/php/readme delete mode 100644 ports/php/template.php delete mode 100755 tests/all-tests.js delete mode 100644 tests/parser/actions.js delete mode 100644 tests/parser/api.js delete mode 100644 tests/parser/errorlab.js delete mode 100644 tests/parser/generator.js delete mode 100644 tests/parser/lalr.js delete mode 100644 tests/parser/lr0.js delete mode 100644 tests/parser/lr1.js delete mode 100755 tests/parser/parser-tests.js delete mode 100644 tests/parser/precedence.js delete mode 100644 tests/parser/slr.js delete mode 100644 tests/parser/tables.js delete mode 100755 tests/performance.js delete mode 100644 tests/setup.js delete mode 100644 web/.gitignore delete mode 100644 web/README delete mode 100644 web/Rakefile delete mode 100644 web/Rules delete mode 100644 web/config.yaml delete mode 100644 web/content/about.html delete mode 100644 web/content/assets/js/calculator.js delete mode 100644 web/content/assets/js/es5.js delete mode 100644 web/content/assets/js/jquery.js delete mode 100644 web/content/assets/js/json2.js delete mode 100644 web/content/assets/js/lib/jison.js delete mode 100644 web/content/assets/js/lib/jison/bnf.js delete mode 100644 web/content/assets/js/lib/jison/jisonlex.js delete mode 100644 web/content/assets/js/lib/jison/json2jison.js delete mode 100644 web/content/assets/js/lib/jison/lexer.js delete mode 100644 web/content/assets/js/lib/jison/util/bnf-parser.js delete mode 100644 web/content/assets/js/lib/jison/util/lex-parser.js delete mode 100644 web/content/assets/js/lib/jison/util/set.js delete mode 100644 web/content/assets/js/lib/jison/util/typal.js delete mode 100644 web/content/assets/js/try.js delete mode 100644 web/content/assets/js/usf.js delete mode 100644 web/content/assets/js/webtoolkit.base64.js delete mode 100644 web/content/assets/pngs/jison.png delete mode 100644 web/content/assets/pngs/jison_x1.png delete mode 100644 web/content/assets/pngs/usf.jpg delete mode 100644 web/content/assets/pngs/usflogo.jpg delete mode 100644 web/content/assets/styles/style.css delete mode 100644 web/content/assets/styles/try.css delete mode 100644 web/content/assets/styles/usf.css delete mode 100644 web/content/assets/styles/usflogo.jpg delete mode 100644 web/content/community.html delete mode 100644 web/content/demos.html delete mode 100644 web/content/demos/calc.html delete mode 100644 web/content/docs.html delete mode 100644 web/content/index.html delete mode 100644 web/content/install.html delete mode 100644 web/content/try.html delete mode 100644 web/content/try/usf.html delete mode 100644 web/jison/examples/ansic.jison delete mode 100644 web/jison/examples/basic.jison delete mode 100644 web/jison/examples/basic2.jison delete mode 100644 web/jison/examples/basic2_lex.json delete mode 100644 web/jison/examples/classy.json delete mode 100644 web/jison/examples/classy_ast.json delete mode 100644 web/jison/examples/dism.jison delete mode 100644 web/jison/examples/dism_lr0.jison delete mode 100644 web/jison/examples/json.js delete mode 100644 web/jison/examples/jsonAST.js delete mode 100644 web/jison/examples/precedence.jison delete mode 100644 web/jison/examples/reduce_conflict.jison delete mode 100644 web/jison/index.html delete mode 100644 web/jison/main.js delete mode 100644 web/jison/states.html delete mode 100644 web/jison/usf.html delete mode 100644 web/layouts/default.html delete mode 100644 web/lib/default.rb diff --git a/.gitignore b/.gitignore index 3f1af7895..9daa8247d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,2 @@ .DS_Store node_modules - -# Editor backup files -*.bak -*~ -web/content/assets/js/jison.js \ No newline at end of file diff --git a/.npmignore b/.npmignore deleted file mode 100644 index bad00b162..000000000 --- a/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -src/ -web/ -examples/ -ports/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 20fd86b6a..000000000 --- a/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - 0.10 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 38c447e6d..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,29 +0,0 @@ -Contributing to Jison -======= - -Fork, make your changes, run tests and/or add tests then send a pull request. - -## Running tests - -Prerequesites: `node` and `npm`. - -First run: - - npm install - -Then run tests with: - - make test - -## Building the site - -To build the site, as well as the Browserified web version of Jison, run: - - make site - -Then you can also preview the site by doing: - - make preview - -Note that you will need `nanoc` and `adsf` in order to build/preview the site. `gem install` them if you haven't. - diff --git a/Makefile b/Makefile deleted file mode 100644 index 0150e93d6..000000000 --- a/Makefile +++ /dev/null @@ -1,20 +0,0 @@ - -all: test - -site: - ./node_modules/.bin/browserify entry.js --exports require | ./node_modules/.bin/uglifyjs > web/content/assets/js/jison.js - cd web/ && nanoc compile - cp -r examples web/output/jison/ - -preview: - cd web/ && nanoc view & - open http://localhost:3000/jison/ - -deploy: - rm -r ../pages/jison/* - cp -r web/output/jison/* ../pages/jison/ - cd ../pages/jison && git add . && git commit -m 'Deploy site updates' && git push origin gh-pages - -test: - node tests/all-tests.js - diff --git a/README.md b/README.md deleted file mode 100644 index 098d31b13..000000000 --- a/README.md +++ /dev/null @@ -1,158 +0,0 @@ -Jison -===== -* [issues](http://github.com/zaach/jison/issues) -* [discuss](mailto:jison@librelist.com) - -[![build status](https://travis-ci.org/zaach/jison.svg)](http://travis-ci.org/zaach/jison) - -An API for creating parsers in JavaScript ------------------------------------------ - -Jison generates bottom-up parsers in JavaScript. Its API is similar to Bison's, hence the name. It supports many of Bison's major features, plus some of its own. If you are new to parser generators such as Bison, and Context-free Grammars in general, a [good introduction][1] is found in the Bison manual. If you already know Bison, Jison should be easy to pickup. - -Briefly, Jison takes a JSON encoded grammar or Bison style grammar and outputs a JavaScript file capable of parsing the language described by that grammar. You can then use the generated script to parse inputs and accept, reject, or perform actions based on the input. - -Installation ------------- -Jison can be installed for [Node](http://nodejs.org) using [`npm`](http://github.com/isaacs/npm/) - -Using npm: - - npm install jison -g - -Usage from the command line ------------------------ - -Clone the github repository for examples: - - git clone git://github.com/zaach/jison.git - cd jison/examples - -Now you're ready to generate some parsers: - - jison calculator.jison - -This will generate `calculator.js` in your current working directory. This file can be used to parse an input file, like so: - - echo "2^32 / 1024" > testcalc - node calculator.js testcalc - -This will print out `4194304`. - -Full cli option list: - - Usage: jison [file] [lexfile] [options] - - file file containing a grammar - lexfile file containing a lexical grammar - - Options: - -j, --json force jison to expect a grammar in JSON format - -o FILE, --outfile FILE Filename and base module name of the generated parser - -t, --debug Debug mode - -m TYPE, --module-type TYPE The type of module to generate (commonjs, amd, js) - -p TYPE, --parser-type TYPE The type of algorithm to use for the parser (lr0, slr, lalr, lr) - -V, --version print version and exit - - -Usage from a CommonJS module --------------------------- - -You can generate parsers programatically from JavaScript as well. Assuming Jison is in your commonjs environment's load path: - -```javascript -// mygenerator.js -var Parser = require("jison").Parser; - -// a grammar in JSON -var grammar = { - "lex": { - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["[a-f0-9]+", "return 'HEX';"] - ] - }, - - "bnf": { - "hex_strings" :[ "hex_strings HEX", - "HEX" ] - } -}; - -// `grammar` can also be a string that uses jison's grammar format -var parser = new Parser(grammar); - -// generate source, ready to be written to disk -var parserSource = parser.generate(); - -// you can also use the parser directly from memory - -// returns true -parser.parse("adfe34bc e82a"); - -// throws lexical error -parser.parse("adfe34bc zxg"); -``` - -More Documentation ------------------- -For more information on creating grammars and using the generated parsers, read the [documentation](http://jison.org/docs). - -How to contribute ------------------ - -See [CONTRIBUTING.md](https://github.com/zaach/jison/blob/master/CONTRIBUTING.md) for contribution guidelines, how to run the tests, etc. - -Projects using Jison ------------------- - -View them on the [wiki](https://github.com/zaach/jison/wiki/ProjectsUsingJison), or add your own. - - -Contributors ------------- -[Githubbers](http://github.com/zaach/jison/contributors) - -Special thanks to Jarred Ligatti, Manuel E. Bermúdez - -License -------- - -> Copyright (c) 2009-2014 Zachary Carter -> -> 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. - - - [1]: http://dinosaur.compilertools.net/bison/bison_4.html - diff --git a/entry.js b/entry.js deleted file mode 100644 index 666cdd838..000000000 --- a/entry.js +++ /dev/null @@ -1,3 +0,0 @@ - -Jison = require('./lib/jison.js'); -bnf = require('ebnf-parser'); diff --git a/lib/cli.js b/lib/cli.js deleted file mode 100755 index 338a23827..000000000 --- a/lib/cli.js +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/env node - -function getCommandlineOptions () { - "use strict"; - var version = require('../package.json').version; - var opts = require("nomnom") - .script('jison') - .option('file', { - flag : true, - position : 0, - help : 'file containing a grammar' - }) - .option('lexfile', { - flag : true, - position : 1, - help : 'file containing a lexical grammar' - }) - .option('json', { - abbr : 'j', - flag : true, - help : 'force jison to expect a grammar in JSON format' - }) - .option('outfile', { - abbr : 'o', - metavar : 'FILE', - help : 'Filename and base module name of the generated parser' - }) - .option('debug', { - abbr : 't', - flag : true, - default: - false, - help : 'Debug mode' - }) - .option('module-type', { - abbr : 'm', - default: - 'commonjs', - metavar : 'TYPE', - help : 'The type of module to generate (commonjs, amd, js)' - }) - .option('parser-type', { - abbr : 'p', - default: - 'lalr', - metavar : 'TYPE', - help : 'The type of algorithm to use for the parser (lr0, slr,' + - 'lalr, lr)' - }) - .option('version', { - abbr : 'V', - flag : true, - help : 'print version and exit', - callback : function () { - return version; - } - }).parse(); - - return opts; -} - -var cli = module.exports; - -cli.main = function cliMain(opts) { - "use strict"; - opts = opts || {}; - - function processGrammar(raw, lex, opts) { - var grammar, - parser; - grammar = cli.processGrammars(raw, lex, opts.json); - parser = cli.generateParserString(opts, grammar); - return parser; - } - - function processInputFile () { - var fs = require('fs'); - var path = require('path'); - - // getting raw files - var lex; - if (opts.lexfile) { - lex = fs.readFileSync(path.normalize(opts.lexfile), 'utf8'); - } - var raw = fs.readFileSync(path.normalize(opts.file), 'utf8'); - - // making best guess at json mode - opts.json = path.extname(opts.file) === '.json' || opts.json; - - // setting output file name and module name based on input file name - // if they aren't specified. - var name = path.basename((opts.outfile || opts.file)); - - name = name.replace(/\..*$/g, ''); - - opts.outfile = opts.outfile || (name + '.js'); - if (!opts.moduleName && name) { - opts.moduleName = name.replace(/-\w/g, - function (match) { - return match.charAt(1).toUpperCase(); - }); - } - - var parser = processGrammar(raw, lex, opts); - fs.writeFileSync(opts.outfile, parser); - } - - function readin(cb) { - var stdin = process.openStdin(), - data = ''; - - stdin.setEncoding('utf8'); - stdin.addListener('data', function (chunk) { - data += chunk; - }); - stdin.addListener('end', function () { - cb(data); - }); - } - - function processStdin () { - readin(function (raw) { - console.log(processGrammar(raw, null, opts)); - }); - } - - // if an input file wasn't given, assume input on stdin - if (opts.file) { - processInputFile(); - } else { - processStdin(); - } -}; - -cli.generateParserString = function generateParserString(opts, grammar) { - "use strict"; - opts = opts || {}; - var jison = require('./jison.js'); - - var settings = grammar.options || {}; - - if (opts['parser-type']) { - settings.type = opts['parser-type']; - } - if (opts.moduleName) { - settings.moduleName = opts.moduleName; - } - settings.debug = opts.debug; - if (!settings.moduleType) { - settings.moduleType = opts['module-type']; - } - - var generator = new jison.Generator(grammar, settings); - return generator.generate(settings); -}; - -cli.processGrammars = function processGrammars(file, lexFile, jsonMode) { - "use strict"; - lexFile = lexFile || false; - jsonMode = jsonMode || false; - var ebnfParser = require('ebnf-parser'); - var cjson = require('cjson'); - var grammar; - try { - if (jsonMode) { - grammar = cjson.parse(file); - } else { - grammar = ebnfParser.parse(file); - } - } catch (e) { - throw new Error('Could not parse jison grammar'); - } - try { - if (lexFile) { - grammar.lex = require('lex-parser').parse(lexFile); - } - } catch (e) { - throw new Error('Could not parse lex grammar'); - } - return grammar; -}; - - -if (require.main === module) { - var opts = getCommandlineOptions(); - cli.main(opts); -} diff --git a/lib/util/set.js b/lib/util/set.js deleted file mode 100644 index 8d871c81a..000000000 --- a/lib/util/set.js +++ /dev/null @@ -1,93 +0,0 @@ -// Set class to wrap arrays - -var typal = require("./typal").typal; - -var setMixin = { - constructor: function Set_constructor (set, raw) { - this._items = []; - if (set && set.constructor === Array) - this._items = raw ? set: set.slice(0); - else if(arguments.length) - this._items = [].slice.call(arguments,0); - }, - concat: function concat (setB) { - this._items.push.apply(this._items, setB._items || setB); - return this; - }, - eq: function eq (set) { - return this._items.length === set._items.length && this.subset(set); - }, - indexOf: function indexOf (item) { - if(item && item.eq) { - for(var k=0; k=0;--k) { - ar[a[k]] = true; - } - for (var i=b.length-1;i >= 0;--i) { - if (!ar[b[i]]) { - a.push(b[i]); - } - } - return a; - } -}); - -if (typeof exports !== 'undefined') - exports.Set = Set; - diff --git a/lib/util/typal.js b/lib/util/typal.js deleted file mode 100644 index 847bb6d55..000000000 --- a/lib/util/typal.js +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Introduces a typal object to make classical/prototypal patterns easier - * Plus some AOP sugar - * - * By Zachary Carter - * MIT Licensed - * */ - -var typal = (function () { - -var create = Object.create || function (o) { function F(){} F.prototype = o; return new F(); }; -var position = /^(before|after)/; - -// basic method layering -// always returns original method's return value -function layerMethod(k, fun) { - var pos = k.match(position)[0], - key = k.replace(position, ''), - prop = this[key]; - - if (pos === 'after') { - this[key] = function () { - var ret = prop.apply(this, arguments); - var args = [].slice.call(arguments); - args.splice(0, 0, ret); - fun.apply(this, args); - return ret; - }; - } else if (pos === 'before') { - this[key] = function () { - fun.apply(this, arguments); - var ret = prop.apply(this, arguments); - return ret; - }; - } -} - -// mixes each argument's own properties into calling object, -// overwriting them or layering them. i.e. an object method 'meth' is -// layered by mixin methods 'beforemeth' or 'aftermeth' -function typal_mix() { - var self = this; - for(var i=0,o,k; i("//"\n) - %{ - yytext = ''; - this.popState(); - return 'areaEnd'; - %} -(?=("//"|"/*")) - %{ - this.popState(); - return 'areaEnd'; - %} -(.|{lineEnd}) - %{ - return 'areaString'; - %} -(?=<>) - %{ - this.popState(); - return 'areaEnd'; - %} -("//"){commentName}(?={lineEnd}) - %{ - this.begin('area'); - yytext = getTypes(yytext.substring(2, yytext.length)); - return 'areaType'; - %} - - -("*/") - %{ - this.popState(); - return 'commentEnd'; - %} -(.|{lineEnd}) - %{ - return 'bodyString'; - %} -("/*"){commentName} - %{ - this.begin('commentBody'); - yytext = getTypes(yytext.substring(2, yytext.length)); - return 'commentType'; - %} - - -(.) - %{ - return 'inlineBodyString'; - %} -(?={lineEnd}) - %{ - this.popState(); - return 'inlineCommentEnd'; - %} -(?=<>) - %{ - this.popState(); - return 'inlineCommentEnd'; - %} -"//"{commentName} - %{ - this.begin('inlineCommentBody'); - yytext = getTypes(yytext.substring(2, yytext.length)); - return 'inlineCommentType'; - %} - - -([A-Za-z0-9 .,?;]+) return 'string'; -([ ]) return 'string'; -{lineEnd} return 'string'; -(.) return 'string'; -<> return 'eof'; - -/lex - -//Parsing Grammer -%% - -file - : contents - {return $1;} - | contents eof - {return $1;} - | eof - { - return ""; - } - ; - -contents - : content - { - $$ = $1; - } - | contents content - { - $$ = $1 + $2; - } - ; - -content - : string - { - $$ = $1; - } - | comment - { - $$ = $1; - } - | inlineComment - { - $$ = $1; - } - | area - { - $$ = $1; - } - ; - -comment - : commentType commentEnd - { - $$ = $1 + $2; - } - | commentType commentBody commentEnd - { - $$ = convertToSyntax($1, $2); - } - ; - -commentBody - : bodyString - { - $$ = $1; - } - | commentBody bodyString - { - $$ = $1 + $2; - } - ; - -inlineComment - : inlineCommentType inlineCommentBody inlineCommentEnd - { - $$ = convertToSyntax($1, $2); - } - ; - -inlineCommentBody - : inlineBodyString - { - $$ = $1; - } - | inlineCommentBody inlineBodyString - { - $$ = $1 + $2; - } - ; - -area - : areaType areaEnd - { - $$ = convertToSyntax($1, $2); - } - | areaType areaBody areaEnd - { - $$ = convertToSyntax($1, $2 + $3); - } - ; -areaBody - : areaString - { - $$ = $1; - } - | areaBody areaString - { - $$ = $1 + $2; - } - ; -%% - -var getTypes = function (types) { - types = types.split(','); - var Types = {}; - for (var i in types) { - Types[types[i]] = true; - } - return Types; -}; \ No newline at end of file diff --git a/ports/comments.js b/ports/comments.js deleted file mode 100644 index 0633a2f21..000000000 --- a/ports/comments.js +++ /dev/null @@ -1,479 +0,0 @@ -/* parser generated by jison 0.4.2 */ -var comments = (function(){ -var parser = {trace: function trace() { }, -yy: {}, -symbols_: {"error":2,"file":3,"contents":4,"eof":5,"content":6,"string":7,"comment":8,"inlineComment":9,"area":10,"commentType":11,"commentEnd":12,"commentBody":13,"bodyString":14,"inlineCommentType":15,"inlineCommentBody":16,"inlineCommentEnd":17,"inlineBodyString":18,"areaType":19,"areaEnd":20,"areaBody":21,"areaString":22,"$accept":0,"$end":1}, -terminals_: {2:"error",5:"eof",7:"string",11:"commentType",12:"commentEnd",14:"bodyString",15:"inlineCommentType",17:"inlineCommentEnd",18:"inlineBodyString",19:"areaType",20:"areaEnd",22:"areaString"}, -productions_: [0,[3,1],[3,2],[3,1],[4,1],[4,2],[6,1],[6,1],[6,1],[6,1],[8,2],[8,3],[13,1],[13,2],[9,3],[16,1],[16,2],[10,2],[10,3],[21,1],[21,2]], -performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { - -var $0 = $$.length - 1; -switch (yystate) { -case 1:return $$[$0]; -break; -case 2:return $$[$0-1]; -break; -case 3: - return ""; - -break; -case 4: - this.$ = $$[$0]; - -break; -case 5: - this.$ = $$[$0-1] + $$[$0]; - -break; -case 6: - this.$ = $$[$0]; - -break; -case 7: - this.$ = $$[$0]; - -break; -case 8: - this.$ = $$[$0]; - -break; -case 9: - this.$ = $$[$0]; - -break; -case 10: - this.$ = $$[$0-1] + $$[$0]; - -break; -case 11: - this.$ = convertToSyntax($$[$0-2], $$[$0-1]); - -break; -case 12: - this.$ = $$[$0]; - -break; -case 13: - this.$ = $$[$0-1] + $$[$0]; - -break; -case 14: - this.$ = convertToSyntax($$[$0-2], $$[$0-1]); - -break; -case 15: - this.$ = $$[$0]; - -break; -case 16: - this.$ = $$[$0-1] + $$[$0]; - -break; -case 17: - this.$ = convertToSyntax($$[$0-1], $$[$0]); - -break; -case 18: - this.$ = convertToSyntax($$[$0-2], $$[$0-1] + $$[$0]); - -break; -case 19: - this.$ = $$[$0]; - -break; -case 20: - this.$ = $$[$0-1] + $$[$0]; - -break; -} -}, -table: [{3:1,4:2,5:[1,3],6:4,7:[1,5],8:6,9:7,10:8,11:[1,9],15:[1,10],19:[1,11]},{1:[3]},{1:[2,1],5:[1,12],6:13,7:[1,5],8:6,9:7,10:8,11:[1,9],15:[1,10],19:[1,11]},{1:[2,3]},{1:[2,4],5:[2,4],7:[2,4],11:[2,4],15:[2,4],19:[2,4]},{1:[2,6],5:[2,6],7:[2,6],11:[2,6],15:[2,6],19:[2,6]},{1:[2,7],5:[2,7],7:[2,7],11:[2,7],15:[2,7],19:[2,7]},{1:[2,8],5:[2,8],7:[2,8],11:[2,8],15:[2,8],19:[2,8]},{1:[2,9],5:[2,9],7:[2,9],11:[2,9],15:[2,9],19:[2,9]},{12:[1,14],13:15,14:[1,16]},{16:17,18:[1,18]},{20:[1,19],21:20,22:[1,21]},{1:[2,2]},{1:[2,5],5:[2,5],7:[2,5],11:[2,5],15:[2,5],19:[2,5]},{1:[2,10],5:[2,10],7:[2,10],11:[2,10],15:[2,10],19:[2,10]},{12:[1,22],14:[1,23]},{12:[2,12],14:[2,12]},{17:[1,24],18:[1,25]},{17:[2,15],18:[2,15]},{1:[2,17],5:[2,17],7:[2,17],11:[2,17],15:[2,17],19:[2,17]},{20:[1,26],22:[1,27]},{20:[2,19],22:[2,19]},{1:[2,11],5:[2,11],7:[2,11],11:[2,11],15:[2,11],19:[2,11]},{12:[2,13],14:[2,13]},{1:[2,14],5:[2,14],7:[2,14],11:[2,14],15:[2,14],19:[2,14]},{17:[2,16],18:[2,16]},{1:[2,18],5:[2,18],7:[2,18],11:[2,18],15:[2,18],19:[2,18]},{20:[2,20],22:[2,20]}], -defaultActions: {3:[2,3],12:[2,2]}, -parseError: function parseError(str, hash) { - throw new Error(str); -}, -parse: function parse(input) { - var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; - this.lexer.setInput(input); - this.lexer.yy = this.yy; - this.yy.lexer = this.lexer; - this.yy.parser = this; - if (typeof this.lexer.yylloc == "undefined") - this.lexer.yylloc = {}; - var yyloc = this.lexer.yylloc; - lstack.push(yyloc); - var ranges = this.lexer.options && this.lexer.options.ranges; - if (typeof this.yy.parseError === "function") - this.parseError = this.yy.parseError; - function popStack(n) { - stack.length = stack.length - 2 * n; - vstack.length = vstack.length - n; - lstack.length = lstack.length - n; - } - function lex() { - var token; - token = self.lexer.lex() || 1; - if (typeof token !== "number") { - token = self.symbols_[token] || token; - } - return token; - } - var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; - while (true) { - state = stack[stack.length - 1]; - if (this.defaultActions[state]) { - action = this.defaultActions[state]; - } else { - if (symbol === null || typeof symbol == "undefined") { - symbol = lex(); - } - action = table[state] && table[state][symbol]; - } - if (typeof action === "undefined" || !action.length || !action[0]) { - var errStr = ""; - if (!recovering) { - expected = []; - for (p in table[state]) - if (this.terminals_[p] && p > 2) { - expected.push("'" + this.terminals_[p] + "'"); - } - if (this.lexer.showPosition) { - errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; - } else { - errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); - } - this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); - } - } - if (action[0] instanceof Array && action.length > 1) { - throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); - } - switch (action[0]) { - case 1: - stack.push(symbol); - vstack.push(this.lexer.yytext); - lstack.push(this.lexer.yylloc); - stack.push(action[1]); - symbol = null; - if (!preErrorSymbol) { - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - yyloc = this.lexer.yylloc; - if (recovering > 0) - recovering--; - } else { - symbol = preErrorSymbol; - preErrorSymbol = null; - } - break; - case 2: - len = this.productions_[action[1]][1]; - yyval.$ = vstack[vstack.length - len]; - yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; - if (ranges) { - yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; - } - r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); - if (typeof r !== "undefined") { - return r; - } - if (len) { - stack = stack.slice(0, -1 * len * 2); - vstack = vstack.slice(0, -1 * len); - lstack = lstack.slice(0, -1 * len); - } - stack.push(this.productions_[action[1]][0]); - vstack.push(yyval.$); - lstack.push(yyval._$); - newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; - stack.push(newState); - break; - case 3: - return true; - } - } - return true; -} -}; - - -var getTypes = function (types) { - types = types.split(','); - var Types = {}; - for (var i in types) { - Types[types[i]] = true; - } - return Types; -};/* generated by jison-lex 0.1.0 */ -var lexer = (function(){ -var lexer = { -EOF:1, -parseError:function parseError(str, hash) { - if (this.yy.parser) { - this.yy.parser.parseError(str, hash); - } else { - throw new Error(str); - } - }, -setInput:function (input) { - this._input = input; - this._more = this._less = this.done = false; - this.yylineno = this.yyleng = 0; - this.yytext = this.matched = this.match = ''; - this.conditionStack = ['INITIAL']; - this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; - if (this.options.ranges) this.yylloc.range = [0,0]; - this.offset = 0; - return this; - }, -input:function () { - var ch = this._input[0]; - this.yytext += ch; - this.yyleng++; - this.offset++; - this.match += ch; - this.matched += ch; - var lines = ch.match(/(?:\r\n?|\n).*/g); - if (lines) { - this.yylineno++; - this.yylloc.last_line++; - } else { - this.yylloc.last_column++; - } - if (this.options.ranges) this.yylloc.range[1]++; - - this._input = this._input.slice(1); - return ch; - }, -unput:function (ch) { - var len = ch.length; - var lines = ch.split(/(?:\r\n?|\n)/g); - - this._input = ch + this._input; - this.yytext = this.yytext.substr(0, this.yytext.length-len-1); - //this.yyleng -= len; - this.offset -= len; - var oldLines = this.match.split(/(?:\r\n?|\n)/g); - this.match = this.match.substr(0, this.match.length-1); - this.matched = this.matched.substr(0, this.matched.length-1); - - if (lines.length-1) this.yylineno -= lines.length-1; - var r = this.yylloc.range; - - this.yylloc = {first_line: this.yylloc.first_line, - last_line: this.yylineno+1, - first_column: this.yylloc.first_column, - last_column: lines ? - (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: - this.yylloc.first_column - len - }; - - if (this.options.ranges) { - this.yylloc.range = [r[0], r[0] + this.yyleng - len]; - } - return this; - }, -more:function () { - this._more = true; - return this; - }, -less:function (n) { - this.unput(this.match.slice(n)); - }, -pastInput:function () { - var past = this.matched.substr(0, this.matched.length - this.match.length); - return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); - }, -upcomingInput:function () { - var next = this.match; - if (next.length < 20) { - next += this._input.substr(0, 20-next.length); - } - return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); - }, -showPosition:function () { - var pre = this.pastInput(); - var c = new Array(pre.length + 1).join("-"); - return pre + this.upcomingInput() + "\n" + c+"^"; - }, -next:function () { - if (this.done) { - return this.EOF; - } - if (!this._input) this.done = true; - - var token, - match, - tempMatch, - index, - col, - lines; - if (!this._more) { - this.yytext = ''; - this.match = ''; - } - var rules = this._currentRules(); - for (var i=0;i < rules.length; i++) { - tempMatch = this._input.match(this.rules[rules[i]]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (!this.options.flex) break; - } - } - if (match) { - lines = match[0].match(/(?:\r\n?|\n).*/g); - if (lines) this.yylineno += lines.length; - this.yylloc = {first_line: this.yylloc.last_line, - last_line: this.yylineno+1, - first_column: this.yylloc.last_column, - last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; - this.yytext += match[0]; - this.match += match[0]; - this.matches = match; - this.yyleng = this.yytext.length; - if (this.options.ranges) { - this.yylloc.range = [this.offset, this.offset += this.yyleng]; - } - this._more = false; - this._input = this._input.slice(match[0].length); - this.matched += match[0]; - token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); - if (this.done && this._input) this.done = false; - if (token) return token; - else return; - } - if (this._input === "") { - return this.EOF; - } else { - return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), - {text: "", token: null, line: this.yylineno}); - } - }, -lex:function lex() { - var r = this.next(); - if (typeof r !== 'undefined') { - return r; - } else { - return this.lex(); - } - }, -begin:function begin(condition) { - this.conditionStack.push(condition); - }, -popState:function popState() { - return this.conditionStack.pop(); - }, -_currentRules:function _currentRules() { - return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; - }, -topState:function () { - return this.conditionStack[this.conditionStack.length-2]; - }, -pushState:function begin(condition) { - this.begin(condition); - }, -options: {}, -performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { - -var YYSTATE=YY_START; -switch($avoiding_name_collisions) { -case 0: - yy_.yytext = ''; - this.popState(); - return 20; - -break; -case 1: - this.popState(); - return 20; - -break; -case 2: - return 22; - -break; -case 3: - this.popState(); - return 20; - -break; -case 4: - this.begin('area'); - yy_.yytext = getTypes(yy_.yytext.substring(2, yy_.yytext.length)); - return 19; - -break; -case 5: - this.popState(); - return 12; - -break; -case 6: - return 14; - -break; -case 7: - this.begin('commentBody'); - yy_.yytext = getTypes(yy_.yytext.substring(2, yy_.yytext.length)); - return 11; - -break; -case 8: - return 18; - -break; -case 9: - this.popState(); - return 17; - -break; -case 10: - this.popState(); - return 17; - -break; -case 11: - this.begin('inlineCommentBody'); - yy_.yytext = getTypes(yy_.yytext.substring(2, yy_.yytext.length)); - return 15; - -break; -case 12:return 7; -break; -case 13:return 7; -break; -case 14:return 7; -break; -case 15:return 7; -break; -case 16:return 5; -break; -} -}, -rules: [/^(?:(\/\/\n))/,/^(?:(?=(\/\/|\/\*)))/,/^(?:(.|((\n\r|\r\n|[\n\r]))))/,/^(?:(?=$))/,/^(?:(\/\/)(([a-zA-Z]+(\||[a-zA-Z]+)*(?=[\s]*)))(?=((\n\r|\r\n|[\n\r]))))/,/^(?:(\*\/))/,/^(?:(.|((\n\r|\r\n|[\n\r]))))/,/^(?:(\/\*)(([a-zA-Z]+(\||[a-zA-Z]+)*(?=[\s]*))))/,/^(?:(.))/,/^(?:(?=((\n\r|\r\n|[\n\r]))))/,/^(?:(?=$))/,/^(?:\/\/(([a-zA-Z]+(\||[a-zA-Z]+)*(?=[\s]*))))/,/^(?:([A-Za-z0-9 .,?;]+))/,/^(?:([ ]))/,/^(?:((\n\r|\r\n|[\n\r])))/,/^(?:(.))/,/^(?:$)/], -conditions: {"area":{"rules":[0,1,2,3,4,7,11,12,13,14,15,16],"inclusive":true},"commentBody":{"rules":[4,5,6,7,11,12,13,14,15,16],"inclusive":true},"inlineCommentBody":{"rules":[4,7,8,9,10,11,12,13,14,15,16],"inclusive":true},"INITIAL":{"rules":[4,7,11,12,13,14,15,16],"inclusive":true}} -}; -return lexer; -})(); -parser.lexer = lexer; -function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; -return new Parser; -})(); -if (typeof require !== 'undefined' && typeof exports !== 'undefined') { -exports.parser = comments; -exports.Parser = comments.Parser; -exports.parse = function () { return comments.parse.apply(comments, arguments); }; -exports.main = function commonjsMain(args) { - if (!args[1]) { - console.log('Usage: '+args[0]+' FILE'); - process.exit(1); - } - var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - return exports.parser.parse(source); -}; -if (typeof module !== 'undefined' && require.main === module) { - exports.main(process.argv.slice(1)); -} -} \ No newline at end of file diff --git a/ports/csharp/Jison/Jison.sln b/ports/csharp/Jison/Jison.sln deleted file mode 100644 index 1030a406d..000000000 --- a/ports/csharp/Jison/Jison.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jison", "Jison\Jison.csproj", "{CE2B4CE0-498B-4A1C-89EF-0F299DF67352}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D33A8B72-D61E-4FE4-BC2A-B128A0BF068E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CE2B4CE0-498B-4A1C-89EF-0F299DF67352}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE2B4CE0-498B-4A1C-89EF-0F299DF67352}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE2B4CE0-498B-4A1C-89EF-0F299DF67352}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE2B4CE0-498B-4A1C-89EF-0F299DF67352}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/ports/csharp/Jison/Jison.v11.suo b/ports/csharp/Jison/Jison.v11.suo deleted file mode 100644 index c99cf176339424d24d9450d4616736926e041312..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 73216 zcmeHQ37i~7x$g}LNjQXHfEWTS2pAwc+55-^yR*AF$VGOui87eX&h~C5J3F(?kz_F_ zA|lAGh=7V5iin_3L=+DUm!c@j!!zo8pa|$gQRFH5#C`vNSJ!s;O!supk)7QzHNS7F zy1KgV`s%Ci`>N_kKb-ZY<;rAhj15e5P{bt z#h9{PS&7v9;p$L!xy536e-wJ8xvDKM9UfLzCiiLPM6~KH*|7`XOq(4IsunFl#l|Gbwr?Lili2??+9Qc&=+Pf&8`jk%O zDX0v=ZOu_5(r3Dd<&gezq<@H>{yf;PGXj(0c&1^Q*rwuXbo6w%-)VYg8RR>&{Z`$- z5;oJ}yWP5df^KhweI(#`z|nx|fP(?%c&6#k%+K54W*JWeFu#jnR|9GQwSYQ6J)i;5 z2xtN{16lz5elhGNfTe(CfHMJ1t6jJ0rs=@*`ZPcB#{U0ogk@Lm0(1k81M~m_0J|^F zh5sDD7Qj}33P=w(WaB5pT#k29KnySpmrN+l>BL4~VI z2sCgm2K09YhKxd*o&&_ox5pw7@jcBtC503t8l_80cmR}CQV9Z7Z7oovQFkJ&-Tx_h z(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oX=5bi7p#dTk{i?z zu7Qe-fFsk#%~T2I;&lB6rPaYivLmAMqNt_LftL)$Q~ub{P%zrpt?o*$4kwc7NpZ?N zu%e{6 - - - - - \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/Jison.csproj b/ports/csharp/Jison/Jison/Jison.csproj deleted file mode 100644 index 59df70a60..000000000 --- a/ports/csharp/Jison/Jison/Jison.csproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - AnyCPU - {CE2B4CE0-498B-4A1C-89EF-0F299DF67352} - Exe - Properties - Jison - Jison - 512 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - ..\ - true - 10.0.0 - 2.0 - - - AnyCPU - True - full - False - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - - - - - - AnyCPU - pdbonly - True - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - - - - - - - Designer - - - - - - - - False - Microsoft .NET Framework 4.5 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - - - - - - - - \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/Jison.csproj.user b/ports/csharp/Jison/Jison/Jison.csproj.user deleted file mode 100644 index 18182982a..000000000 --- a/ports/csharp/Jison/Jison/Jison.csproj.user +++ /dev/null @@ -1,13 +0,0 @@ - - - - publish\ - - - - - - en-US - false - - \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/Properties/AssemblyInfo.cs b/ports/csharp/Jison/Jison/Properties/AssemblyInfo.cs deleted file mode 100644 index 48b0b658f..000000000 --- a/ports/csharp/Jison/Jison/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Jison")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Jison")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("13daedbc-572b-45a9-b566-bd2457788ffe")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ports/csharp/Jison/Jison/Properties/Resources.Designer.cs b/ports/csharp/Jison/Jison/Properties/Resources.Designer.cs deleted file mode 100644 index 7a13aee89..000000000 --- a/ports/csharp/Jison/Jison/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18034 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Jison.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Jison.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/ports/csharp/Jison/Jison/Properties/Resources.resx b/ports/csharp/Jison/Jison/Properties/Resources.resx deleted file mode 100644 index 4fdb1b6af..000000000 --- a/ports/csharp/Jison/Jison/Properties/Resources.resx +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/Template.cs b/ports/csharp/Jison/Jison/Template.cs deleted file mode 100644 index 40e224b7e..000000000 --- a/ports/csharp/Jison/Jison/Template.cs +++ /dev/null @@ -1,750 +0,0 @@ -using System; -using System.Text.RegularExpressions; -using System.Collections.Generic; -using System.Linq; -//@@USING_INJECT@@ - -/**/namespace Jison/**/ -{ - public /**/class Parser/**/ - { - public ParserSymbols Symbols; - public Dictionary Terminals; - public Dictionary Productions; - public Dictionary Table; - public Dictionary DefaultActions; - public string Version = "0.4.2"; - public bool Debug = false; - - public const int None = 0; - public const int Shift = 1; - public const int Reduce = 2; - public const int Accept = 3; - - public void Trace() - { - - } - - /**/public Parser/**/() - { - //Setup Parser - //@@PARSER_INJECT@@ - - //Setup Lexer - //@@LEXER_INJECT@@ - } - - public /**/ParserValue/**/ ParserPerformAction(ref /**/ParserValue/**/ thisS, ref /**/ParserValue/**/ yy, ref int yystate, ref JList ss) - { - var so = ss.Count - 1;//@@ParserPerformActionInjection@@ - return null; - } - - public ParserSymbol ParserLex() - { - var token = LexerLex();//end = 1 - - if (token != null) - { - return token; - } - - return Symbols["end"]; - } - - public void ParseError(string error, ParserError hash = null) - { - throw new InvalidOperationException(error); - } - - public void LexerError(string error, LexerError hash = null) - { - throw new InvalidOperationException(error); - } - - public /**/ParserValue/**/ Parse(string input) - { - if (Table == null) { - throw new Exception("Empty table"); - } - var stack = new JList - { - new ParserCachedAction(new ParserAction(0, Table[0])) - }; - var vstack = new JList - { - new /**/ParserValue/**/() - }; - var yy = new /**/ParserValue/**/(); - var _yy = new /**/ParserValue/**/(); - var v = new /**/ParserValue/**/(); - int recovering = 0; - ParserSymbol symbol = null; - ParserAction action = null; - string errStr = ""; - ParserSymbol preErrorSymbol = null; - ParserState state = null; - - SetInput(input); - - while (true) - { - // retreive state number from top of stack - state = stack.Last().Action.State; - - // use default actions if available - if (state != null && DefaultActions.ContainsKey(state.Index)) - { - action = DefaultActions[state.Index]; - } - else - { - if (symbol == null) - { - symbol = ParserLex(); - } - // read action for current state and first input - if (state != null && state.Actions.ContainsKey(symbol.Index)) - { - action = state.Actions[symbol.Index]; - } - else - { - action = null; - } - } - - if (action == null) - { - if (recovering > 0) - { - // Report error - var expected = new Stack{}; - foreach(var p in Table[state.Index].Actions) - { - expected.Push(Terminals[p.Value.Action].Name); - } - - errStr = "Parse error on line " + (Yy.LineNo + 1).ToString() + ":" + '\n' + - ShowPosition() + '\n' + - "Expecting " + String.Join(", ", expected) + - ", got '" + - (symbol != null ? Terminals[symbol.Index].ToString() : "NOTHING") + "'"; - - ParseError(errStr, new ParserError(Match, state, symbol, Yy.LineNo, yy.Loc, expected)); - } - } - - /*if (state.IsArray()) { - this.parseError("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); - }*/ - - if (state == null || action == null) - { - break; - } - - switch (action.Action) - { - case Shift: - stack.Push(new ParserCachedAction(action, symbol)); - vstack.Push(Yy.Clone()); - - symbol = null; - if (preErrorSymbol == null) - { // normal execution/no error - yy = Yy.Clone(); - if (recovering > 0) recovering--; - } else { // error just occurred, resume old lookahead f/ before error - symbol = preErrorSymbol; - preErrorSymbol = null; - } - break; - - case Reduce: - int len = Productions[action.State.Index].Len; - // perform semantic action - _yy = vstack[vstack.Count - len]; - - if (Ranges != null) - { - Yy.Loc.Range = new ParserRange( - vstack[vstack.Count - len].Loc.Range.X, - vstack.Last().Loc.Range.Y - ); - } - - var value = ParserPerformAction(ref _yy, ref yy, ref action.State.Index, ref vstack); - - if (value != null) - { - return value; - } - - // pop off stack - while (len > 0) - { - stack.Pop(); - vstack.Pop(); - len--; - } - - if (_yy == null) - { - vstack.Push(new /**/ParserValue/**/()); - } - else - { - vstack.Push(_yy.Clone()); - } - var nextSymbol = Productions[action.State.Index].Symbol; - // goto new state = table[STATE][NONTERMINAL] - var nextState = stack.Last().Action.State; - var nextAction = nextState.Actions[nextSymbol.Index]; - - stack.Push(new ParserCachedAction(nextAction, nextSymbol)); - - break; - case Accept: - return v; - } - } - - return v; - } - - /* Jison generated lexer */ - public ParserSymbol Eof = new ParserSymbol("Eof", 1); - public /**/ParserValue/**/ Yy = new /**/ParserValue/**/(); - public string Match = ""; - public string Matched = ""; - public Stack ConditionStack; - public Dictionary Rules; - public Dictionary Conditions; - public bool Done = false; - public bool Less; - public bool _More; - public string _Input; - public int Offset; - public DictionaryRanges; - public bool Flex = false; - - public void SetInput(string input) - { - _Input = input; - _More = Less = Done = false; - Yy.LineNo = Yy.Leng = 0; - Matched = Match = ""; - ConditionStack = new Stack(); - ConditionStack.Push("INITIAL"); - - if (Ranges != null) - { - Yy.Loc = new ParserLocation(new ParserRange(0,0)); - } else { - Yy.Loc = new ParserLocation(); - } - - Offset = 0; - } - - public string Input() - { - string ch = _Input[0].ToString(); - Yy.Text += ch; - Yy.Leng++; - Offset++; - Match += ch; - Matched += ch; - Match lines = Regex.Match(ch, "/(?:\r\n?|\n).*/"); - if (lines.Success) { - Yy.LineNo++; - Yy.Loc.LastLine++; - } else { - Yy.Loc.LastColumn++; - } - - if (Ranges != null) - { - Yy.Loc.Range.Y++; - } - - _Input = _Input.Substring(1); - return ch; - } - - public void Unput(string ch) - { - int len = ch.Length; - var lines = Regex.Split(ch, "/(?:\r\n?|\n)/"); - - _Input = ch + _Input; - Yy.Text = Yy.Text.Substring(0, len - 1); - Offset -= len; - var oldLines = Regex.Split(Match, "/(?:\r\n?|\n)/"); - Match = Match.Substring(0, Match.Length - 1); - Matched = Matched.Substring(0, Matched.Length - 1); - - if ((lines.Length - 1) > 0) Yy.LineNo -= lines.Length - 1; - var r = Yy.Loc.Range; - - Yy.Loc = new ParserLocation( - Yy.Loc.FirstLine, - Yy.LineNo + 1, - Yy.Loc.FirstColumn, - ( - lines.Length > 0 ? - ( - lines.Length == oldLines.Length ? - Yy.Loc.FirstColumn : - 0 - ) + oldLines[oldLines.Length - lines.Length].Length - lines[0].Length : - Yy.Loc.FirstColumn - len - ) - ); - - if (Ranges.Count > 0) { - Yy.Loc.Range = new ParserRange(r.X, r.X + Yy.Leng - len); - } - } - - public void More() - { - _More = true; - } - - public string PastInput() - { - var past = Matched.Substring(0, Matched.Length - Match.Length); - return (past.Length > 20 ? "..." + Regex.Replace(past.Substring(-20), "/\n/", "") : ""); - } - - public string UpcomingInput() - { - var next = Match; - if (next.Length < 20) - { - next += _Input.Substring(0, (next.Length > 20 ? 20 - next.Length : next.Length)); - } - return Regex.Replace(next.Substring(0, (next.Length > 20 ? 20 - next.Length : next.Length)) + (next.Length > 20 ? "..." : ""), "/\n/", ""); - } - - public string ShowPosition() - { - var pre = PastInput(); - - var c = ""; - for (var i = 0; i < pre.Length; i++) - { - c += "-"; - } - - return pre + UpcomingInput() + '\n' + c + "^"; - } - - public ParserSymbol Next() - { - if (Done == true) - { - return Eof; - } - - if (String.IsNullOrEmpty(_Input)) - { - Done = true; - } - - if (_More == false) - { - Yy.Text = ""; - Match = ""; - } - - var rules = CurrentRules(); - string match = ""; - bool matched = false; - int index = 0; - Regex rule; - for (int i = 0; i < rules.Count; i++) - { - rule = Rules[rules[i]]; - var tempMatch = rule.Match(_Input); - if (tempMatch.Success == true && (match != null || tempMatch.Length > match.Length)) { - match = tempMatch.Value; - matched = true; - index = i; - if (!Flex) { - break; - } - } - } - if ( matched ) - { - Match lineCount = Regex.Match(match, "/\n.*/"); - - Yy.LineNo += lineCount.Length; - Yy.Loc.FirstLine = Yy.Loc.LastLine; - Yy.Loc.LastLine = Yy.LineNo + 1; - Yy.Loc.FirstColumn = Yy.Loc.LastColumn; - Yy.Loc.LastColumn = lineCount.Length > 0 ? lineCount.Length - 1 : Yy.Loc.LastColumn + match.Length; - - Yy.Text += match; - Match += match; - Matched += match; - - Yy.Leng = Yy.Text.Length; - if (Ranges != null) - { - Yy.Loc.Range = new ParserRange(Offset, Offset += Yy.Leng); - } - _More = false; - _Input = _Input.Substring(match.Length); - var ruleIndex = rules[index]; - var nextCondition = ConditionStack.Peek(); - dynamic action = LexerPerformAction(ruleIndex, nextCondition); - ParserSymbol token = Symbols[action]; - - if (Done == true && String.IsNullOrEmpty(_Input) == false) - { - Done = false; - } - - if (token.Index > -1) { - return token; - } else { - return null; - } - } - - if (String.IsNullOrEmpty(_Input)) { - return Symbols["EOF"]; - } else - { - LexerError("Lexical error on line " + (Yy.LineNo + 1) + ". Unrecognized text.\n" + ShowPosition(), new LexerError("", -1, Yy.LineNo)); - return null; - } - } - - public ParserSymbol LexerLex() - { - var r = Next(); - - while (r == null) - { - r = Next(); - } - - return r; - } - - public void Begin(string condition) - { - ConditionStack.Push(condition); - } - - public string PopState() - { - return ConditionStack.Pop(); - } - - public List CurrentRules() - { - var peek = ConditionStack.Peek(); - return Conditions[peek].Rules; - } - - public dynamic LexerPerformAction(int avoidingNameCollisions, string Yy_Start) - { - //@@LexerPerformActionInjection@@ - return -1; - } - } - - public class ParserLocation - { - public int FirstLine = 1; - public int LastLine = 0; - public int FirstColumn = 1; - public int LastColumn = 0; - public ParserRange Range; - - public ParserLocation() - { - } - - public ParserLocation(ParserRange range) - { - Range = range; - } - - public ParserLocation(int firstLine, int lastLine, int firstColumn, int lastColumn) - { - FirstLine = firstLine; - LastLine = lastLine; - FirstColumn = firstColumn; - LastColumn = lastColumn; - } - - public ParserLocation(int firstLine, int lastLine, int firstColumn, int lastColumn, ParserRange range) - { - FirstLine = firstLine; - LastLine = lastLine; - FirstColumn = firstColumn; - LastColumn = lastColumn; - Range = range; - } - } - - public class LexerConditions - { - public List Rules; - public bool Inclusive; - - public LexerConditions(List rules, bool inclusive) - { - Rules = rules; - Inclusive = inclusive; - } - } - - public class ParserProduction - { - public int Len = 0; - public ParserSymbol Symbol; - - public ParserProduction(ParserSymbol symbol) - { - Symbol = symbol; - } - - public ParserProduction(ParserSymbol symbol, int len) - { - Symbol = symbol; - Len = len; - } - } - - public class ParserCachedAction - { - public ParserAction Action; - public ParserSymbol Symbol; - - public ParserCachedAction(ParserAction action) - { - Action = action; - } - - public ParserCachedAction(ParserAction action, ParserSymbol symbol) - { - Action = action; - Symbol = symbol; - } - } - - public class ParserAction - { - public int Action; - public ParserState State; - public ParserSymbol Symbol; - - public ParserAction(int action) - { - Action = action; - } - - public ParserAction(int action, ref ParserState state) - { - Action = action; - State = state; - } - - public ParserAction(int action, ParserState state) - { - Action = action; - State = state; - } - - public ParserAction(int action, ref ParserSymbol symbol) - { - Action = action; - Symbol = symbol; - } - } - - public class ParserSymbol - { - public string Name; - public int Index = -1; - public IDictionary Symbols = new Dictionary(); - public IDictionary SymbolsByName = new Dictionary(); - - public ParserSymbol() - { - } - - public ParserSymbol(string name, int index) - { - Name = name; - Index = index; - } - - public void AddAction(ParserSymbol p) - { - Symbols.Add(p.Index, p); - SymbolsByName.Add(p.Name, p); - } - } - - public class ParserError - { - public String Text; - public ParserState State; - public ParserSymbol Symbol; - public int LineNo; - public ParserLocation Loc; - public Stack Expected; - - public ParserError(String text, ParserState state, ParserSymbol symbol, int lineNo, ParserLocation loc, Stack expected) - { - Text = text; - State = state; - Symbol = symbol; - LineNo = lineNo; - Loc = loc; - Expected = expected; - } - } - - public class LexerError - { - public String Text; - public int Token; - public int LineNo; - - public LexerError(String text, int token, int lineNo) - { - Text = text; - Token = token; - LineNo = lineNo; - } - } - - public class ParserState - { - public int Index; - public Dictionary Actions = new Dictionary(); - - public ParserState(int index) - { - Index = index; - } - - public void SetActions(ref Dictionary actions) - { - Actions = actions; - } - } - - public class ParserRange - { - public int X; - public int Y; - - public ParserRange(int x, int y) - { - X = x; - Y = y; - } - } - - public class ParserSymbols - { - private Dictionary SymbolsString = new Dictionary(); - private Dictionary SymbolsInt = new Dictionary(); - - public void Add(ParserSymbol symbol) - { - SymbolsInt.Add(symbol.Index, symbol); - SymbolsString.Add(symbol.Name, symbol); - } - - public ParserSymbol this[char name] - { - get - { - return SymbolsString[name.ToString()]; - } - } - - public ParserSymbol this[string name] - { - get - { - return SymbolsString[name]; - } - } - - public ParserSymbol this[int index] - { - get - { - if (index < 0) - { - return new ParserSymbol(); - } - return SymbolsInt[index]; - } - } - } - - public class ParserValue - { - public string Text; - public ParserLocation Loc; - public int Leng = 0; - public int LineNo = 0; - - public ParserValue() - { - } - - public ParserValue(ParserValue parserValue) - { - Text = parserValue.Text; - Leng = parserValue.Leng; - Loc = parserValue.Loc; - LineNo = parserValue.LineNo; - } - - public ParserValue Clone() - { - return new ParserValue(this); - } - } - - public class JList : List where T : class - { - public void Push(T item) - { - Add(item); - } - - public void Pop() - { - RemoveAt(Count - 1); - } - - new public T this[int index] - { - get - { - if (index >= Count || index < 0 || Count == 0) - { - return null; - } - return base[index]; - } - } - } -} \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/Test.cs b/ports/csharp/Jison/Jison/Test.cs deleted file mode 100644 index 1dd965950..000000000 --- a/ports/csharp/Jison/Jison/Test.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using jQuerySheet; - -namespace jQuerySheet -{ - public class Test - { - public Test () - { - } - - public static void Main() - { - Spreadsheet.Spreadsheets = new SpreadsheetsDictionary(); - var spreadsheetsDictionary = new SpreadsheetDictionary(); - Spreadsheet.Spreadsheets.Add(0, spreadsheetsDictionary); - var row = new RowDictionary(); - spreadsheetsDictionary.Add(0, row); - - var cellA1 = new Cell(0, 0, 0); - cellA1.Value = "250"; - var cellB1 = new Cell(0, 0, 1); - cellB1.Value = "250"; - var cellC1 = new Cell(0, 0, 2); - cellC1.Formula = "800 - SUM(A1:B1) + 100"; - cellC1.HasFormula = true; - - row.Add(0, cellA1); - row.Add(1, cellB1); - row.Add(2, cellC1); - - //var spreadsheet = new Spreadsheet(); - //spreadsheet.Calc(); - - var parsedCell = Spreadsheet.Spreadsheets[0][0][2]; - var value = parsedCell.UpdateValue(); - value = value; - } - } -} -; \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/Test/Cell.cs b/ports/csharp/Jison/Jison/Test/Cell.cs deleted file mode 100644 index c24a9d242..000000000 --- a/ports/csharp/Jison/Jison/Test/Cell.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace jQuerySheet -{ - public class Cell - { - public Cell () - { - } - - public int Row; - public int Col; - public int Spreadsheet; - public string Value; - public Boolean HasFormula; - public string Formula; - public Expression Exp; - - public DateTime CalcLast = new DateTime(); - public int CalcCount = 0; - - public Stack State = new Stack(); - - public Cell(int spreadsheet, int row, int col) - { - Spreadsheet = spreadsheet; - Row = row; - Col = col; - } - public Cell(int spreadsheet, int row, int col, string value) - { - Spreadsheet = spreadsheet; - Row = row; - Col = col; - Value = value; - } - - public Expression UpdateValue() - { - if (HasFormula && State.Count < 1) { - State.Push ("Parsing"); - CalcCount++; - var formula = new Formula (); - var value = formula.Parse (Formula); - State.Pop (); - return value; - } else { - var exp = new Expression(); - double num; - if (double.TryParse(Value, out num)) - { - exp.Set(num); - } - else - { - exp.Set(Value); - } - return exp; - } - } - } -} - diff --git a/ports/csharp/Jison/Jison/Test/Expression.cs b/ports/csharp/Jison/Jison/Test/Expression.cs deleted file mode 100644 index 769d100f2..000000000 --- a/ports/csharp/Jison/Jison/Test/Expression.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace jQuerySheet -{ - public class Expression : ParserValue - { - public bool ValueSet = false; - public string Type; - - public Expression(){} - public Expression(Expression value) - { - Text = value.Text; - Leng = value.Leng; - Loc = value.Loc; - LineNo = value.LineNo; - ValueSet = value.ValueSet; - BoolValue = value.BoolValue; - Children = value.Children; - DoubleValue = value.DoubleValue; - } - - public Expression Clone() - { - return new Expression(this); - } - - public Expression(string value) - { - Text = value; - } - - public bool BoolValue; - public bool ToBool() - { - ValueSet = true; - BoolValue = Convert.ToBoolean (Text); - Type = "bool"; - return BoolValue; - } - public void Set(bool value) { - BoolValue = value; - ValueSet = true; - Type = "bool"; - } - - - public double DoubleValue; - public double ToDouble() - { - ValueSet = true; - if (!String.IsNullOrEmpty (Text) || DoubleValue != 0) { - double num; - if (double.TryParse(Text, out num)) { - DoubleValue = num; - } else { - DoubleValue = (DoubleValue != 0 ? DoubleValue : 0); - } - ValueSet = true; - } else { - DoubleValue = 0; - } - Type = "double"; - return DoubleValue; - } - public bool IsNumeric() - { - if (Type == "double" || DoubleValue > 0) - { - Type = "double"; - return true; - } - - double num; - if (double.TryParse(Text, out num)) - { - ValueSet = true; - Type = "double"; - return true; - } - - return false; - } - public void Add(Expression value) - { - value.ToDouble(); - DoubleValue += value.DoubleValue; - Type = "double"; - } - public void Set(double value) { - DoubleValue = value; - ValueSet = true; - Type = "double"; - } - - - public string ToString() - { - ValueSet = true; - Type = "string"; - return Text; - } - public void Set(string value) { - Text = value; - ValueSet = true; - Type = "string"; - } - public void Concat(Expression value) - { - Text += value.Text; - Type = "string"; - } - - - - - public List Children; - public void Push(Expression value) - { - if (Children == null) { - Children = new List() - { - this - }; - } - - Children.Add (value); - } - } -} - diff --git a/ports/csharp/Jison/Jison/Test/Formula.cs b/ports/csharp/Jison/Jison/Test/Formula.cs deleted file mode 100644 index bc1ec4011..000000000 --- a/ports/csharp/Jison/Jison/Test/Formula.cs +++ /dev/null @@ -1,2911 +0,0 @@ -using System; -using System.Text.RegularExpressions; -using System.Collections.Generic; -using System.Linq; - - -namespace jQuerySheet -{ - public class Formula - { - public ParserSymbols Symbols; - public Dictionary Terminals; - public Dictionary Productions; - public Dictionary Table; - public Dictionary DefaultActions; - public string Version = "0.4.2"; - public bool Debug = false; - - public const int None = 0; - public const int Shift = 1; - public const int Reduce = 2; - public const int Accept = 3; - - public void Trace() - { - - } - - public Formula() - { - //Setup Parser - - var symbol0 = new ParserSymbol("accept", 0); - var symbol1 = new ParserSymbol("end", 1); - var symbol2 = new ParserSymbol("error", 2); - var symbol3 = new ParserSymbol("expressions", 3); - var symbol4 = new ParserSymbol("expression", 4); - var symbol5 = new ParserSymbol("EOF", 5); - var symbol6 = new ParserSymbol("variableSequence", 6); - var symbol7 = new ParserSymbol("TIME_AMPM", 7); - var symbol8 = new ParserSymbol("TIME_24", 8); - var symbol9 = new ParserSymbol("number", 9); - var symbol10 = new ParserSymbol("STRING", 10); - var symbol11 = new ParserSymbol("=", 11); - var symbol12 = new ParserSymbol("+", 12); - var symbol13 = new ParserSymbol("(", 13); - var symbol14 = new ParserSymbol(")", 14); - var symbol15 = new ParserSymbol("<", 15); - var symbol16 = new ParserSymbol(">", 16); - var symbol17 = new ParserSymbol("NOT", 17); - var symbol18 = new ParserSymbol("-", 18); - var symbol19 = new ParserSymbol("*", 19); - var symbol20 = new ParserSymbol("/", 20); - var symbol21 = new ParserSymbol("^", 21); - var symbol22 = new ParserSymbol("E", 22); - var symbol23 = new ParserSymbol("FUNCTION", 23); - var symbol24 = new ParserSymbol("expseq", 24); - var symbol25 = new ParserSymbol("cell", 25); - var symbol26 = new ParserSymbol("FIXEDCELL", 26); - var symbol27 = new ParserSymbol(":", 27); - var symbol28 = new ParserSymbol("CELL", 28); - var symbol29 = new ParserSymbol("SHEET", 29); - var symbol30 = new ParserSymbol("!", 30); - var symbol31 = new ParserSymbol(";", 31); - var symbol32 = new ParserSymbol(",", 32); - var symbol33 = new ParserSymbol("VARIABLE", 33); - var symbol34 = new ParserSymbol("DECIMAL", 34); - var symbol35 = new ParserSymbol("NUMBER", 35); - var symbol36 = new ParserSymbol("%", 36); - var symbol37 = new ParserSymbol("#", 37); - - - Symbols = new ParserSymbols(); - Symbols.Add(symbol0); - Symbols.Add(symbol1); - Symbols.Add(symbol2); - Symbols.Add(symbol3); - Symbols.Add(symbol4); - Symbols.Add(symbol5); - Symbols.Add(symbol6); - Symbols.Add(symbol7); - Symbols.Add(symbol8); - Symbols.Add(symbol9); - Symbols.Add(symbol10); - Symbols.Add(symbol11); - Symbols.Add(symbol12); - Symbols.Add(symbol13); - Symbols.Add(symbol14); - Symbols.Add(symbol15); - Symbols.Add(symbol16); - Symbols.Add(symbol17); - Symbols.Add(symbol18); - Symbols.Add(symbol19); - Symbols.Add(symbol20); - Symbols.Add(symbol21); - Symbols.Add(symbol22); - Symbols.Add(symbol23); - Symbols.Add(symbol24); - Symbols.Add(symbol25); - Symbols.Add(symbol26); - Symbols.Add(symbol27); - Symbols.Add(symbol28); - Symbols.Add(symbol29); - Symbols.Add(symbol30); - Symbols.Add(symbol31); - Symbols.Add(symbol32); - Symbols.Add(symbol33); - Symbols.Add(symbol34); - Symbols.Add(symbol35); - Symbols.Add(symbol36); - Symbols.Add(symbol37); - - Terminals = new Dictionary - { - {5, symbol5}, - {7, symbol7}, - {8, symbol8}, - {10, symbol10}, - {11, symbol11}, - {12, symbol12}, - {13, symbol13}, - {14, symbol14}, - {15, symbol15}, - {16, symbol16}, - {17, symbol17}, - {18, symbol18}, - {19, symbol19}, - {20, symbol20}, - {21, symbol21}, - {22, symbol22}, - {23, symbol23}, - {26, symbol26}, - {27, symbol27}, - {28, symbol28}, - {29, symbol29}, - {30, symbol30}, - {31, symbol31}, - {32, symbol32}, - {33, symbol33}, - {34, symbol34}, - {35, symbol35}, - {36, symbol36}, - {37, symbol37} - }; - - var table0 = new ParserState(0); - var table1 = new ParserState(1); - var table2 = new ParserState(2); - var table3 = new ParserState(3); - var table4 = new ParserState(4); - var table5 = new ParserState(5); - var table6 = new ParserState(6); - var table7 = new ParserState(7); - var table8 = new ParserState(8); - var table9 = new ParserState(9); - var table10 = new ParserState(10); - var table11 = new ParserState(11); - var table12 = new ParserState(12); - var table13 = new ParserState(13); - var table14 = new ParserState(14); - var table15 = new ParserState(15); - var table16 = new ParserState(16); - var table17 = new ParserState(17); - var table18 = new ParserState(18); - var table19 = new ParserState(19); - var table20 = new ParserState(20); - var table21 = new ParserState(21); - var table22 = new ParserState(22); - var table23 = new ParserState(23); - var table24 = new ParserState(24); - var table25 = new ParserState(25); - var table26 = new ParserState(26); - var table27 = new ParserState(27); - var table28 = new ParserState(28); - var table29 = new ParserState(29); - var table30 = new ParserState(30); - var table31 = new ParserState(31); - var table32 = new ParserState(32); - var table33 = new ParserState(33); - var table34 = new ParserState(34); - var table35 = new ParserState(35); - var table36 = new ParserState(36); - var table37 = new ParserState(37); - var table38 = new ParserState(38); - var table39 = new ParserState(39); - var table40 = new ParserState(40); - var table41 = new ParserState(41); - var table42 = new ParserState(42); - var table43 = new ParserState(43); - var table44 = new ParserState(44); - var table45 = new ParserState(45); - var table46 = new ParserState(46); - var table47 = new ParserState(47); - var table48 = new ParserState(48); - var table49 = new ParserState(49); - var table50 = new ParserState(50); - var table51 = new ParserState(51); - var table52 = new ParserState(52); - var table53 = new ParserState(53); - var table54 = new ParserState(54); - var table55 = new ParserState(55); - var table56 = new ParserState(56); - var table57 = new ParserState(57); - var table58 = new ParserState(58); - var table59 = new ParserState(59); - var table60 = new ParserState(60); - var table61 = new ParserState(61); - var table62 = new ParserState(62); - var table63 = new ParserState(63); - var table64 = new ParserState(64); - var table65 = new ParserState(65); - var table66 = new ParserState(66); - var table67 = new ParserState(67); - var table68 = new ParserState(68); - var table69 = new ParserState(69); - var table70 = new ParserState(70); - var table71 = new ParserState(71); - var table72 = new ParserState(72); - var table73 = new ParserState(73); - var table74 = new ParserState(74); - var table75 = new ParserState(75); - var table76 = new ParserState(76); - var table77 = new ParserState(77); - var table78 = new ParserState(78); - - var tableDefinition0 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {3, new ParserAction(None, ref table1)}, - {4, new ParserAction(None, ref table2)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition1 = new Dictionary - { - {1, new ParserAction(Accept)} - }; - - var tableDefinition2 = new Dictionary - { - {5, new ParserAction(Shift, ref table21)}, - {11, new ParserAction(Shift, ref table22)}, - {12, new ParserAction(Shift, ref table23)}, - {15, new ParserAction(Shift, ref table24)}, - {16, new ParserAction(Shift, ref table25)}, - {17, new ParserAction(Shift, ref table26)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)} - }; - - var tableDefinition3 = new Dictionary - { - {5, new ParserAction(Reduce, ref table2)}, - {11, new ParserAction(Reduce, ref table2)}, - {12, new ParserAction(Reduce, ref table2)}, - {14, new ParserAction(Reduce, ref table2)}, - {15, new ParserAction(Reduce, ref table2)}, - {16, new ParserAction(Reduce, ref table2)}, - {17, new ParserAction(Reduce, ref table2)}, - {18, new ParserAction(Reduce, ref table2)}, - {19, new ParserAction(Reduce, ref table2)}, - {20, new ParserAction(Reduce, ref table2)}, - {21, new ParserAction(Reduce, ref table2)}, - {31, new ParserAction(Reduce, ref table2)}, - {32, new ParserAction(Reduce, ref table2)}, - {34, new ParserAction(Shift, ref table31)} - }; - - var tableDefinition4 = new Dictionary - { - {5, new ParserAction(Reduce, ref table3)}, - {11, new ParserAction(Reduce, ref table3)}, - {12, new ParserAction(Reduce, ref table3)}, - {14, new ParserAction(Reduce, ref table3)}, - {15, new ParserAction(Reduce, ref table3)}, - {16, new ParserAction(Reduce, ref table3)}, - {17, new ParserAction(Reduce, ref table3)}, - {18, new ParserAction(Reduce, ref table3)}, - {19, new ParserAction(Reduce, ref table3)}, - {20, new ParserAction(Reduce, ref table3)}, - {21, new ParserAction(Reduce, ref table3)}, - {31, new ParserAction(Reduce, ref table3)}, - {32, new ParserAction(Reduce, ref table3)} - }; - - var tableDefinition5 = new Dictionary - { - {5, new ParserAction(Reduce, ref table4)}, - {11, new ParserAction(Reduce, ref table4)}, - {12, new ParserAction(Reduce, ref table4)}, - {14, new ParserAction(Reduce, ref table4)}, - {15, new ParserAction(Reduce, ref table4)}, - {16, new ParserAction(Reduce, ref table4)}, - {17, new ParserAction(Reduce, ref table4)}, - {18, new ParserAction(Reduce, ref table4)}, - {19, new ParserAction(Reduce, ref table4)}, - {20, new ParserAction(Reduce, ref table4)}, - {21, new ParserAction(Reduce, ref table4)}, - {31, new ParserAction(Reduce, ref table4)}, - {32, new ParserAction(Reduce, ref table4)} - }; - - var tableDefinition6 = new Dictionary - { - {5, new ParserAction(Reduce, ref table5)}, - {11, new ParserAction(Reduce, ref table5)}, - {12, new ParserAction(Reduce, ref table5)}, - {14, new ParserAction(Reduce, ref table5)}, - {15, new ParserAction(Reduce, ref table5)}, - {16, new ParserAction(Reduce, ref table5)}, - {17, new ParserAction(Reduce, ref table5)}, - {18, new ParserAction(Reduce, ref table5)}, - {19, new ParserAction(Reduce, ref table5)}, - {20, new ParserAction(Reduce, ref table5)}, - {21, new ParserAction(Reduce, ref table5)}, - {31, new ParserAction(Reduce, ref table5)}, - {32, new ParserAction(Reduce, ref table5)}, - {36, new ParserAction(Shift, ref table32)} - }; - - var tableDefinition7 = new Dictionary - { - {5, new ParserAction(Reduce, ref table6)}, - {11, new ParserAction(Reduce, ref table6)}, - {12, new ParserAction(Reduce, ref table6)}, - {14, new ParserAction(Reduce, ref table6)}, - {15, new ParserAction(Reduce, ref table6)}, - {16, new ParserAction(Reduce, ref table6)}, - {17, new ParserAction(Reduce, ref table6)}, - {18, new ParserAction(Reduce, ref table6)}, - {19, new ParserAction(Reduce, ref table6)}, - {20, new ParserAction(Reduce, ref table6)}, - {21, new ParserAction(Reduce, ref table6)}, - {31, new ParserAction(Reduce, ref table6)}, - {32, new ParserAction(Reduce, ref table6)} - }; - - var tableDefinition8 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table33)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition9 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table34)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition10 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table35)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition11 = new Dictionary - { - {5, new ParserAction(Reduce, ref table22)}, - {11, new ParserAction(Reduce, ref table22)}, - {12, new ParserAction(Reduce, ref table22)}, - {14, new ParserAction(Reduce, ref table22)}, - {15, new ParserAction(Reduce, ref table22)}, - {16, new ParserAction(Reduce, ref table22)}, - {17, new ParserAction(Reduce, ref table22)}, - {18, new ParserAction(Reduce, ref table22)}, - {19, new ParserAction(Reduce, ref table22)}, - {20, new ParserAction(Reduce, ref table22)}, - {21, new ParserAction(Reduce, ref table22)}, - {31, new ParserAction(Reduce, ref table22)}, - {32, new ParserAction(Reduce, ref table22)} - }; - - var tableDefinition12 = new Dictionary - { - {13, new ParserAction(Shift, ref table36)} - }; - - var tableDefinition13 = new Dictionary - { - {5, new ParserAction(Reduce, ref table25)}, - {11, new ParserAction(Reduce, ref table25)}, - {12, new ParserAction(Reduce, ref table25)}, - {14, new ParserAction(Reduce, ref table25)}, - {15, new ParserAction(Reduce, ref table25)}, - {16, new ParserAction(Reduce, ref table25)}, - {17, new ParserAction(Reduce, ref table25)}, - {18, new ParserAction(Reduce, ref table25)}, - {19, new ParserAction(Reduce, ref table25)}, - {20, new ParserAction(Reduce, ref table25)}, - {21, new ParserAction(Reduce, ref table25)}, - {31, new ParserAction(Reduce, ref table25)}, - {32, new ParserAction(Reduce, ref table25)} - }; - - var tableDefinition14 = new Dictionary - { - {2, new ParserAction(None, ref table37)}, - {5, new ParserAction(Reduce, ref table26)}, - {11, new ParserAction(Reduce, ref table26)}, - {12, new ParserAction(Reduce, ref table26)}, - {14, new ParserAction(Reduce, ref table26)}, - {15, new ParserAction(Reduce, ref table26)}, - {16, new ParserAction(Reduce, ref table26)}, - {17, new ParserAction(Reduce, ref table26)}, - {18, new ParserAction(Reduce, ref table26)}, - {19, new ParserAction(Reduce, ref table26)}, - {20, new ParserAction(Reduce, ref table26)}, - {21, new ParserAction(Reduce, ref table26)}, - {31, new ParserAction(Reduce, ref table26)}, - {32, new ParserAction(Reduce, ref table26)}, - {33, new ParserAction(Shift, ref table38)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition15 = new Dictionary - { - {5, new ParserAction(Reduce, ref table37)}, - {11, new ParserAction(Reduce, ref table37)}, - {12, new ParserAction(Reduce, ref table37)}, - {14, new ParserAction(Reduce, ref table37)}, - {15, new ParserAction(Reduce, ref table37)}, - {16, new ParserAction(Reduce, ref table37)}, - {17, new ParserAction(Reduce, ref table37)}, - {18, new ParserAction(Reduce, ref table37)}, - {19, new ParserAction(Reduce, ref table37)}, - {20, new ParserAction(Reduce, ref table37)}, - {21, new ParserAction(Reduce, ref table37)}, - {31, new ParserAction(Reduce, ref table37)}, - {32, new ParserAction(Reduce, ref table37)}, - {34, new ParserAction(Reduce, ref table37)}, - {37, new ParserAction(Shift, ref table39)} - }; - - var tableDefinition16 = new Dictionary - { - {5, new ParserAction(Reduce, ref table39)}, - {11, new ParserAction(Reduce, ref table39)}, - {12, new ParserAction(Reduce, ref table39)}, - {14, new ParserAction(Reduce, ref table39)}, - {15, new ParserAction(Reduce, ref table39)}, - {16, new ParserAction(Reduce, ref table39)}, - {17, new ParserAction(Reduce, ref table39)}, - {18, new ParserAction(Reduce, ref table39)}, - {19, new ParserAction(Reduce, ref table39)}, - {20, new ParserAction(Reduce, ref table39)}, - {21, new ParserAction(Reduce, ref table39)}, - {31, new ParserAction(Reduce, ref table39)}, - {32, new ParserAction(Reduce, ref table39)}, - {34, new ParserAction(Shift, ref table40)}, - {36, new ParserAction(Reduce, ref table39)} - }; - - var tableDefinition17 = new Dictionary - { - {5, new ParserAction(Reduce, ref table28)}, - {11, new ParserAction(Reduce, ref table28)}, - {12, new ParserAction(Reduce, ref table28)}, - {14, new ParserAction(Reduce, ref table28)}, - {15, new ParserAction(Reduce, ref table28)}, - {16, new ParserAction(Reduce, ref table28)}, - {17, new ParserAction(Reduce, ref table28)}, - {18, new ParserAction(Reduce, ref table28)}, - {19, new ParserAction(Reduce, ref table28)}, - {20, new ParserAction(Reduce, ref table28)}, - {21, new ParserAction(Reduce, ref table28)}, - {27, new ParserAction(Shift, ref table41)}, - {31, new ParserAction(Reduce, ref table28)}, - {32, new ParserAction(Reduce, ref table28)} - }; - - var tableDefinition18 = new Dictionary - { - {5, new ParserAction(Reduce, ref table30)}, - {11, new ParserAction(Reduce, ref table30)}, - {12, new ParserAction(Reduce, ref table30)}, - {14, new ParserAction(Reduce, ref table30)}, - {15, new ParserAction(Reduce, ref table30)}, - {16, new ParserAction(Reduce, ref table30)}, - {17, new ParserAction(Reduce, ref table30)}, - {18, new ParserAction(Reduce, ref table30)}, - {19, new ParserAction(Reduce, ref table30)}, - {20, new ParserAction(Reduce, ref table30)}, - {21, new ParserAction(Reduce, ref table30)}, - {27, new ParserAction(Shift, ref table42)}, - {31, new ParserAction(Reduce, ref table30)}, - {32, new ParserAction(Reduce, ref table30)} - }; - - var tableDefinition19 = new Dictionary - { - {30, new ParserAction(Shift, ref table43)} - }; - - var tableDefinition20 = new Dictionary - { - {33, new ParserAction(Shift, ref table44)} - }; - - var tableDefinition21 = new Dictionary - { - {1, new ParserAction(Reduce, ref table1)} - }; - - var tableDefinition22 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table45)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition23 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table46)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition24 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table49)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {11, new ParserAction(Shift, ref table47)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {16, new ParserAction(Shift, ref table48)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition25 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table51)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {11, new ParserAction(Shift, ref table50)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition26 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table52)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition27 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table53)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition28 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table54)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition29 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table55)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition30 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table56)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition31 = new Dictionary - { - {33, new ParserAction(Shift, ref table57)} - }; - - var tableDefinition32 = new Dictionary - { - {5, new ParserAction(Reduce, ref table41)}, - {11, new ParserAction(Reduce, ref table41)}, - {12, new ParserAction(Reduce, ref table41)}, - {14, new ParserAction(Reduce, ref table41)}, - {15, new ParserAction(Reduce, ref table41)}, - {16, new ParserAction(Reduce, ref table41)}, - {17, new ParserAction(Reduce, ref table41)}, - {18, new ParserAction(Reduce, ref table41)}, - {19, new ParserAction(Reduce, ref table41)}, - {20, new ParserAction(Reduce, ref table41)}, - {21, new ParserAction(Reduce, ref table41)}, - {31, new ParserAction(Reduce, ref table41)}, - {32, new ParserAction(Reduce, ref table41)}, - {36, new ParserAction(Reduce, ref table41)} - }; - - var tableDefinition33 = new Dictionary - { - {11, new ParserAction(Shift, ref table22)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Shift, ref table58)}, - {15, new ParserAction(Shift, ref table24)}, - {16, new ParserAction(Shift, ref table25)}, - {17, new ParserAction(Shift, ref table26)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)} - }; - - var tableDefinition34 = new Dictionary - { - {5, new ParserAction(Reduce, ref table20)}, - {11, new ParserAction(Reduce, ref table20)}, - {12, new ParserAction(Reduce, ref table20)}, - {14, new ParserAction(Reduce, ref table20)}, - {15, new ParserAction(Reduce, ref table20)}, - {16, new ParserAction(Reduce, ref table20)}, - {17, new ParserAction(Reduce, ref table20)}, - {18, new ParserAction(Reduce, ref table20)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table20)}, - {32, new ParserAction(Reduce, ref table20)} - }; - - var tableDefinition35 = new Dictionary - { - {5, new ParserAction(Reduce, ref table21)}, - {11, new ParserAction(Reduce, ref table21)}, - {12, new ParserAction(Reduce, ref table21)}, - {14, new ParserAction(Reduce, ref table21)}, - {15, new ParserAction(Reduce, ref table21)}, - {16, new ParserAction(Reduce, ref table21)}, - {17, new ParserAction(Reduce, ref table21)}, - {18, new ParserAction(Reduce, ref table21)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table21)}, - {32, new ParserAction(Reduce, ref table21)} - }; - - var tableDefinition36 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table61)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {14, new ParserAction(Shift, ref table59)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {24, new ParserAction(None, ref table60)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition37 = new Dictionary - { - {5, new ParserAction(Reduce, ref table27)}, - {11, new ParserAction(Reduce, ref table27)}, - {12, new ParserAction(Reduce, ref table27)}, - {14, new ParserAction(Reduce, ref table27)}, - {15, new ParserAction(Reduce, ref table27)}, - {16, new ParserAction(Reduce, ref table27)}, - {17, new ParserAction(Reduce, ref table27)}, - {18, new ParserAction(Reduce, ref table27)}, - {19, new ParserAction(Reduce, ref table27)}, - {20, new ParserAction(Reduce, ref table27)}, - {21, new ParserAction(Reduce, ref table27)}, - {31, new ParserAction(Reduce, ref table27)}, - {32, new ParserAction(Reduce, ref table27)} - }; - - var tableDefinition38 = new Dictionary - { - {37, new ParserAction(Shift, ref table39)} - }; - - var tableDefinition39 = new Dictionary - { - {33, new ParserAction(Shift, ref table62)} - }; - - var tableDefinition40 = new Dictionary - { - {35, new ParserAction(Shift, ref table63)} - }; - - var tableDefinition41 = new Dictionary - { - {26, new ParserAction(Shift, ref table64)} - }; - - var tableDefinition42 = new Dictionary - { - {28, new ParserAction(Shift, ref table65)} - }; - - var tableDefinition43 = new Dictionary - { - {28, new ParserAction(Shift, ref table66)} - }; - - var tableDefinition44 = new Dictionary - { - {30, new ParserAction(Shift, ref table67)} - }; - - var tableDefinition45 = new Dictionary - { - {5, new ParserAction(Reduce, ref table7)}, - {11, new ParserAction(Reduce, ref table7)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table7)}, - {15, new ParserAction(Shift, ref table24)}, - {16, new ParserAction(Shift, ref table25)}, - {17, new ParserAction(Shift, ref table26)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table7)}, - {32, new ParserAction(Reduce, ref table7)} - }; - - var tableDefinition46 = new Dictionary - { - {5, new ParserAction(Reduce, ref table8)}, - {11, new ParserAction(Reduce, ref table8)}, - {12, new ParserAction(Reduce, ref table8)}, - {14, new ParserAction(Reduce, ref table8)}, - {15, new ParserAction(Reduce, ref table8)}, - {16, new ParserAction(Reduce, ref table8)}, - {17, new ParserAction(Reduce, ref table8)}, - {18, new ParserAction(Reduce, ref table8)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table8)}, - {32, new ParserAction(Reduce, ref table8)} - }; - - var tableDefinition47 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table68)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition48 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table69)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition49 = new Dictionary - { - {5, new ParserAction(Reduce, ref table15)}, - {11, new ParserAction(Reduce, ref table15)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table15)}, - {15, new ParserAction(Reduce, ref table15)}, - {16, new ParserAction(Reduce, ref table15)}, - {17, new ParserAction(Reduce, ref table15)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table15)}, - {32, new ParserAction(Reduce, ref table15)} - }; - - var tableDefinition50 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table70)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition51 = new Dictionary - { - {5, new ParserAction(Reduce, ref table14)}, - {11, new ParserAction(Reduce, ref table14)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table14)}, - {15, new ParserAction(Reduce, ref table14)}, - {16, new ParserAction(Reduce, ref table14)}, - {17, new ParserAction(Reduce, ref table14)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table14)}, - {32, new ParserAction(Reduce, ref table14)} - }; - - var tableDefinition52 = new Dictionary - { - {5, new ParserAction(Reduce, ref table13)}, - {11, new ParserAction(Reduce, ref table13)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table13)}, - {15, new ParserAction(Shift, ref table24)}, - {16, new ParserAction(Shift, ref table25)}, - {17, new ParserAction(Reduce, ref table13)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table13)}, - {32, new ParserAction(Reduce, ref table13)} - }; - - var tableDefinition53 = new Dictionary - { - {5, new ParserAction(Reduce, ref table16)}, - {11, new ParserAction(Reduce, ref table16)}, - {12, new ParserAction(Reduce, ref table16)}, - {14, new ParserAction(Reduce, ref table16)}, - {15, new ParserAction(Reduce, ref table16)}, - {16, new ParserAction(Reduce, ref table16)}, - {17, new ParserAction(Reduce, ref table16)}, - {18, new ParserAction(Reduce, ref table16)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table16)}, - {32, new ParserAction(Reduce, ref table16)} - }; - - var tableDefinition54 = new Dictionary - { - {5, new ParserAction(Reduce, ref table17)}, - {11, new ParserAction(Reduce, ref table17)}, - {12, new ParserAction(Reduce, ref table17)}, - {14, new ParserAction(Reduce, ref table17)}, - {15, new ParserAction(Reduce, ref table17)}, - {16, new ParserAction(Reduce, ref table17)}, - {17, new ParserAction(Reduce, ref table17)}, - {18, new ParserAction(Reduce, ref table17)}, - {19, new ParserAction(Reduce, ref table17)}, - {20, new ParserAction(Reduce, ref table17)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table17)}, - {32, new ParserAction(Reduce, ref table17)} - }; - - var tableDefinition55 = new Dictionary - { - {5, new ParserAction(Reduce, ref table18)}, - {11, new ParserAction(Reduce, ref table18)}, - {12, new ParserAction(Reduce, ref table18)}, - {14, new ParserAction(Reduce, ref table18)}, - {15, new ParserAction(Reduce, ref table18)}, - {16, new ParserAction(Reduce, ref table18)}, - {17, new ParserAction(Reduce, ref table18)}, - {18, new ParserAction(Reduce, ref table18)}, - {19, new ParserAction(Reduce, ref table18)}, - {20, new ParserAction(Reduce, ref table18)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table18)}, - {32, new ParserAction(Reduce, ref table18)} - }; - - var tableDefinition56 = new Dictionary - { - {5, new ParserAction(Reduce, ref table19)}, - {11, new ParserAction(Reduce, ref table19)}, - {12, new ParserAction(Reduce, ref table19)}, - {14, new ParserAction(Reduce, ref table19)}, - {15, new ParserAction(Reduce, ref table19)}, - {16, new ParserAction(Reduce, ref table19)}, - {17, new ParserAction(Reduce, ref table19)}, - {18, new ParserAction(Reduce, ref table19)}, - {19, new ParserAction(Reduce, ref table19)}, - {20, new ParserAction(Reduce, ref table19)}, - {21, new ParserAction(Reduce, ref table19)}, - {31, new ParserAction(Reduce, ref table19)}, - {32, new ParserAction(Reduce, ref table19)} - }; - - var tableDefinition57 = new Dictionary - { - {5, new ParserAction(Reduce, ref table38)}, - {11, new ParserAction(Reduce, ref table38)}, - {12, new ParserAction(Reduce, ref table38)}, - {14, new ParserAction(Reduce, ref table38)}, - {15, new ParserAction(Reduce, ref table38)}, - {16, new ParserAction(Reduce, ref table38)}, - {17, new ParserAction(Reduce, ref table38)}, - {18, new ParserAction(Reduce, ref table38)}, - {19, new ParserAction(Reduce, ref table38)}, - {20, new ParserAction(Reduce, ref table38)}, - {21, new ParserAction(Reduce, ref table38)}, - {31, new ParserAction(Reduce, ref table38)}, - {32, new ParserAction(Reduce, ref table38)}, - {34, new ParserAction(Reduce, ref table38)} - }; - - var tableDefinition58 = new Dictionary - { - {5, new ParserAction(Reduce, ref table9)}, - {11, new ParserAction(Reduce, ref table9)}, - {12, new ParserAction(Reduce, ref table9)}, - {14, new ParserAction(Reduce, ref table9)}, - {15, new ParserAction(Reduce, ref table9)}, - {16, new ParserAction(Reduce, ref table9)}, - {17, new ParserAction(Reduce, ref table9)}, - {18, new ParserAction(Reduce, ref table9)}, - {19, new ParserAction(Reduce, ref table9)}, - {20, new ParserAction(Reduce, ref table9)}, - {21, new ParserAction(Reduce, ref table9)}, - {31, new ParserAction(Reduce, ref table9)}, - {32, new ParserAction(Reduce, ref table9)} - }; - - var tableDefinition59 = new Dictionary - { - {5, new ParserAction(Reduce, ref table23)}, - {11, new ParserAction(Reduce, ref table23)}, - {12, new ParserAction(Reduce, ref table23)}, - {14, new ParserAction(Reduce, ref table23)}, - {15, new ParserAction(Reduce, ref table23)}, - {16, new ParserAction(Reduce, ref table23)}, - {17, new ParserAction(Reduce, ref table23)}, - {18, new ParserAction(Reduce, ref table23)}, - {19, new ParserAction(Reduce, ref table23)}, - {20, new ParserAction(Reduce, ref table23)}, - {21, new ParserAction(Reduce, ref table23)}, - {31, new ParserAction(Reduce, ref table23)}, - {32, new ParserAction(Reduce, ref table23)} - }; - - var tableDefinition60 = new Dictionary - { - {14, new ParserAction(Shift, ref table71)}, - {31, new ParserAction(Shift, ref table72)}, - {32, new ParserAction(Shift, ref table73)} - }; - - var tableDefinition61 = new Dictionary - { - {11, new ParserAction(Shift, ref table22)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table34)}, - {15, new ParserAction(Shift, ref table24)}, - {16, new ParserAction(Shift, ref table25)}, - {17, new ParserAction(Shift, ref table26)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table34)}, - {32, new ParserAction(Reduce, ref table34)} - }; - - var tableDefinition62 = new Dictionary - { - {30, new ParserAction(Shift, ref table74)} - }; - - var tableDefinition63 = new Dictionary - { - {5, new ParserAction(Reduce, ref table40)}, - {11, new ParserAction(Reduce, ref table40)}, - {12, new ParserAction(Reduce, ref table40)}, - {14, new ParserAction(Reduce, ref table40)}, - {15, new ParserAction(Reduce, ref table40)}, - {16, new ParserAction(Reduce, ref table40)}, - {17, new ParserAction(Reduce, ref table40)}, - {18, new ParserAction(Reduce, ref table40)}, - {19, new ParserAction(Reduce, ref table40)}, - {20, new ParserAction(Reduce, ref table40)}, - {21, new ParserAction(Reduce, ref table40)}, - {31, new ParserAction(Reduce, ref table40)}, - {32, new ParserAction(Reduce, ref table40)}, - {36, new ParserAction(Reduce, ref table40)} - }; - - var tableDefinition64 = new Dictionary - { - {5, new ParserAction(Reduce, ref table29)}, - {11, new ParserAction(Reduce, ref table29)}, - {12, new ParserAction(Reduce, ref table29)}, - {14, new ParserAction(Reduce, ref table29)}, - {15, new ParserAction(Reduce, ref table29)}, - {16, new ParserAction(Reduce, ref table29)}, - {17, new ParserAction(Reduce, ref table29)}, - {18, new ParserAction(Reduce, ref table29)}, - {19, new ParserAction(Reduce, ref table29)}, - {20, new ParserAction(Reduce, ref table29)}, - {21, new ParserAction(Reduce, ref table29)}, - {31, new ParserAction(Reduce, ref table29)}, - {32, new ParserAction(Reduce, ref table29)} - }; - - var tableDefinition65 = new Dictionary - { - {5, new ParserAction(Reduce, ref table31)}, - {11, new ParserAction(Reduce, ref table31)}, - {12, new ParserAction(Reduce, ref table31)}, - {14, new ParserAction(Reduce, ref table31)}, - {15, new ParserAction(Reduce, ref table31)}, - {16, new ParserAction(Reduce, ref table31)}, - {17, new ParserAction(Reduce, ref table31)}, - {18, new ParserAction(Reduce, ref table31)}, - {19, new ParserAction(Reduce, ref table31)}, - {20, new ParserAction(Reduce, ref table31)}, - {21, new ParserAction(Reduce, ref table31)}, - {31, new ParserAction(Reduce, ref table31)}, - {32, new ParserAction(Reduce, ref table31)} - }; - - var tableDefinition66 = new Dictionary - { - {5, new ParserAction(Reduce, ref table32)}, - {11, new ParserAction(Reduce, ref table32)}, - {12, new ParserAction(Reduce, ref table32)}, - {14, new ParserAction(Reduce, ref table32)}, - {15, new ParserAction(Reduce, ref table32)}, - {16, new ParserAction(Reduce, ref table32)}, - {17, new ParserAction(Reduce, ref table32)}, - {18, new ParserAction(Reduce, ref table32)}, - {19, new ParserAction(Reduce, ref table32)}, - {20, new ParserAction(Reduce, ref table32)}, - {21, new ParserAction(Reduce, ref table32)}, - {27, new ParserAction(Shift, ref table75)}, - {31, new ParserAction(Reduce, ref table32)}, - {32, new ParserAction(Reduce, ref table32)} - }; - - var tableDefinition67 = new Dictionary - { - {5, new ParserAction(Reduce, ref table42)}, - {11, new ParserAction(Reduce, ref table42)}, - {12, new ParserAction(Reduce, ref table42)}, - {14, new ParserAction(Reduce, ref table42)}, - {15, new ParserAction(Reduce, ref table42)}, - {16, new ParserAction(Reduce, ref table42)}, - {17, new ParserAction(Reduce, ref table42)}, - {18, new ParserAction(Reduce, ref table42)}, - {19, new ParserAction(Reduce, ref table42)}, - {20, new ParserAction(Reduce, ref table42)}, - {21, new ParserAction(Reduce, ref table42)}, - {31, new ParserAction(Reduce, ref table42)}, - {32, new ParserAction(Reduce, ref table42)}, - {33, new ParserAction(Reduce, ref table42)}, - {37, new ParserAction(Reduce, ref table42)} - }; - - var tableDefinition68 = new Dictionary - { - {5, new ParserAction(Reduce, ref table10)}, - {11, new ParserAction(Reduce, ref table10)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table10)}, - {15, new ParserAction(Reduce, ref table10)}, - {16, new ParserAction(Reduce, ref table10)}, - {17, new ParserAction(Reduce, ref table10)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table10)}, - {32, new ParserAction(Reduce, ref table10)} - }; - - var tableDefinition69 = new Dictionary - { - {5, new ParserAction(Reduce, ref table12)}, - {11, new ParserAction(Reduce, ref table12)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table12)}, - {15, new ParserAction(Reduce, ref table12)}, - {16, new ParserAction(Reduce, ref table12)}, - {17, new ParserAction(Reduce, ref table12)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table12)}, - {32, new ParserAction(Reduce, ref table12)} - }; - - var tableDefinition70 = new Dictionary - { - {5, new ParserAction(Reduce, ref table11)}, - {11, new ParserAction(Reduce, ref table11)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table11)}, - {15, new ParserAction(Reduce, ref table11)}, - {16, new ParserAction(Reduce, ref table11)}, - {17, new ParserAction(Reduce, ref table11)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table11)}, - {32, new ParserAction(Reduce, ref table11)} - }; - - var tableDefinition71 = new Dictionary - { - {5, new ParserAction(Reduce, ref table24)}, - {11, new ParserAction(Reduce, ref table24)}, - {12, new ParserAction(Reduce, ref table24)}, - {14, new ParserAction(Reduce, ref table24)}, - {15, new ParserAction(Reduce, ref table24)}, - {16, new ParserAction(Reduce, ref table24)}, - {17, new ParserAction(Reduce, ref table24)}, - {18, new ParserAction(Reduce, ref table24)}, - {19, new ParserAction(Reduce, ref table24)}, - {20, new ParserAction(Reduce, ref table24)}, - {21, new ParserAction(Reduce, ref table24)}, - {31, new ParserAction(Reduce, ref table24)}, - {32, new ParserAction(Reduce, ref table24)} - }; - - var tableDefinition72 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table76)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition73 = new Dictionary - { - {2, new ParserAction(None, ref table14)}, - {4, new ParserAction(None, ref table77)}, - {6, new ParserAction(None, ref table3)}, - {7, new ParserAction(Shift, ref table4)}, - {8, new ParserAction(Shift, ref table5)}, - {9, new ParserAction(None, ref table6)}, - {10, new ParserAction(Shift, ref table7)}, - {12, new ParserAction(Shift, ref table10)}, - {13, new ParserAction(Shift, ref table8)}, - {18, new ParserAction(Shift, ref table9)}, - {22, new ParserAction(Shift, ref table11)}, - {23, new ParserAction(Shift, ref table12)}, - {25, new ParserAction(None, ref table13)}, - {26, new ParserAction(Shift, ref table17)}, - {28, new ParserAction(Shift, ref table18)}, - {29, new ParserAction(Shift, ref table19)}, - {33, new ParserAction(Shift, ref table15)}, - {35, new ParserAction(Shift, ref table16)}, - {37, new ParserAction(Shift, ref table20)} - }; - - var tableDefinition74 = new Dictionary - { - {5, new ParserAction(Reduce, ref table43)}, - {11, new ParserAction(Reduce, ref table43)}, - {12, new ParserAction(Reduce, ref table43)}, - {14, new ParserAction(Reduce, ref table43)}, - {15, new ParserAction(Reduce, ref table43)}, - {16, new ParserAction(Reduce, ref table43)}, - {17, new ParserAction(Reduce, ref table43)}, - {18, new ParserAction(Reduce, ref table43)}, - {19, new ParserAction(Reduce, ref table43)}, - {20, new ParserAction(Reduce, ref table43)}, - {21, new ParserAction(Reduce, ref table43)}, - {31, new ParserAction(Reduce, ref table43)}, - {32, new ParserAction(Reduce, ref table43)}, - {33, new ParserAction(Reduce, ref table43)}, - {37, new ParserAction(Reduce, ref table43)} - }; - - var tableDefinition75 = new Dictionary - { - {28, new ParserAction(Shift, ref table78)} - }; - - var tableDefinition76 = new Dictionary - { - {11, new ParserAction(Shift, ref table22)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table35)}, - {15, new ParserAction(Shift, ref table24)}, - {16, new ParserAction(Shift, ref table25)}, - {17, new ParserAction(Shift, ref table26)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table35)}, - {32, new ParserAction(Reduce, ref table35)} - }; - - var tableDefinition77 = new Dictionary - { - {11, new ParserAction(Shift, ref table22)}, - {12, new ParserAction(Shift, ref table23)}, - {14, new ParserAction(Reduce, ref table36)}, - {15, new ParserAction(Shift, ref table24)}, - {16, new ParserAction(Shift, ref table25)}, - {17, new ParserAction(Shift, ref table26)}, - {18, new ParserAction(Shift, ref table27)}, - {19, new ParserAction(Shift, ref table28)}, - {20, new ParserAction(Shift, ref table29)}, - {21, new ParserAction(Shift, ref table30)}, - {31, new ParserAction(Reduce, ref table36)}, - {32, new ParserAction(Reduce, ref table36)} - }; - - var tableDefinition78 = new Dictionary - { - {5, new ParserAction(Reduce, ref table33)}, - {11, new ParserAction(Reduce, ref table33)}, - {12, new ParserAction(Reduce, ref table33)}, - {14, new ParserAction(Reduce, ref table33)}, - {15, new ParserAction(Reduce, ref table33)}, - {16, new ParserAction(Reduce, ref table33)}, - {17, new ParserAction(Reduce, ref table33)}, - {18, new ParserAction(Reduce, ref table33)}, - {19, new ParserAction(Reduce, ref table33)}, - {20, new ParserAction(Reduce, ref table33)}, - {21, new ParserAction(Reduce, ref table33)}, - {31, new ParserAction(Reduce, ref table33)}, - {32, new ParserAction(Reduce, ref table33)} - }; - - table0.SetActions(ref tableDefinition0); - table1.SetActions(ref tableDefinition1); - table2.SetActions(ref tableDefinition2); - table3.SetActions(ref tableDefinition3); - table4.SetActions(ref tableDefinition4); - table5.SetActions(ref tableDefinition5); - table6.SetActions(ref tableDefinition6); - table7.SetActions(ref tableDefinition7); - table8.SetActions(ref tableDefinition8); - table9.SetActions(ref tableDefinition9); - table10.SetActions(ref tableDefinition10); - table11.SetActions(ref tableDefinition11); - table12.SetActions(ref tableDefinition12); - table13.SetActions(ref tableDefinition13); - table14.SetActions(ref tableDefinition14); - table15.SetActions(ref tableDefinition15); - table16.SetActions(ref tableDefinition16); - table17.SetActions(ref tableDefinition17); - table18.SetActions(ref tableDefinition18); - table19.SetActions(ref tableDefinition19); - table20.SetActions(ref tableDefinition20); - table21.SetActions(ref tableDefinition21); - table22.SetActions(ref tableDefinition22); - table23.SetActions(ref tableDefinition23); - table24.SetActions(ref tableDefinition24); - table25.SetActions(ref tableDefinition25); - table26.SetActions(ref tableDefinition26); - table27.SetActions(ref tableDefinition27); - table28.SetActions(ref tableDefinition28); - table29.SetActions(ref tableDefinition29); - table30.SetActions(ref tableDefinition30); - table31.SetActions(ref tableDefinition31); - table32.SetActions(ref tableDefinition32); - table33.SetActions(ref tableDefinition33); - table34.SetActions(ref tableDefinition34); - table35.SetActions(ref tableDefinition35); - table36.SetActions(ref tableDefinition36); - table37.SetActions(ref tableDefinition37); - table38.SetActions(ref tableDefinition38); - table39.SetActions(ref tableDefinition39); - table40.SetActions(ref tableDefinition40); - table41.SetActions(ref tableDefinition41); - table42.SetActions(ref tableDefinition42); - table43.SetActions(ref tableDefinition43); - table44.SetActions(ref tableDefinition44); - table45.SetActions(ref tableDefinition45); - table46.SetActions(ref tableDefinition46); - table47.SetActions(ref tableDefinition47); - table48.SetActions(ref tableDefinition48); - table49.SetActions(ref tableDefinition49); - table50.SetActions(ref tableDefinition50); - table51.SetActions(ref tableDefinition51); - table52.SetActions(ref tableDefinition52); - table53.SetActions(ref tableDefinition53); - table54.SetActions(ref tableDefinition54); - table55.SetActions(ref tableDefinition55); - table56.SetActions(ref tableDefinition56); - table57.SetActions(ref tableDefinition57); - table58.SetActions(ref tableDefinition58); - table59.SetActions(ref tableDefinition59); - table60.SetActions(ref tableDefinition60); - table61.SetActions(ref tableDefinition61); - table62.SetActions(ref tableDefinition62); - table63.SetActions(ref tableDefinition63); - table64.SetActions(ref tableDefinition64); - table65.SetActions(ref tableDefinition65); - table66.SetActions(ref tableDefinition66); - table67.SetActions(ref tableDefinition67); - table68.SetActions(ref tableDefinition68); - table69.SetActions(ref tableDefinition69); - table70.SetActions(ref tableDefinition70); - table71.SetActions(ref tableDefinition71); - table72.SetActions(ref tableDefinition72); - table73.SetActions(ref tableDefinition73); - table74.SetActions(ref tableDefinition74); - table75.SetActions(ref tableDefinition75); - table76.SetActions(ref tableDefinition76); - table77.SetActions(ref tableDefinition77); - table78.SetActions(ref tableDefinition78); - - Table = new Dictionary - { - {0, table0}, - {1, table1}, - {2, table2}, - {3, table3}, - {4, table4}, - {5, table5}, - {6, table6}, - {7, table7}, - {8, table8}, - {9, table9}, - {10, table10}, - {11, table11}, - {12, table12}, - {13, table13}, - {14, table14}, - {15, table15}, - {16, table16}, - {17, table17}, - {18, table18}, - {19, table19}, - {20, table20}, - {21, table21}, - {22, table22}, - {23, table23}, - {24, table24}, - {25, table25}, - {26, table26}, - {27, table27}, - {28, table28}, - {29, table29}, - {30, table30}, - {31, table31}, - {32, table32}, - {33, table33}, - {34, table34}, - {35, table35}, - {36, table36}, - {37, table37}, - {38, table38}, - {39, table39}, - {40, table40}, - {41, table41}, - {42, table42}, - {43, table43}, - {44, table44}, - {45, table45}, - {46, table46}, - {47, table47}, - {48, table48}, - {49, table49}, - {50, table50}, - {51, table51}, - {52, table52}, - {53, table53}, - {54, table54}, - {55, table55}, - {56, table56}, - {57, table57}, - {58, table58}, - {59, table59}, - {60, table60}, - {61, table61}, - {62, table62}, - {63, table63}, - {64, table64}, - {65, table65}, - {66, table66}, - {67, table67}, - {68, table68}, - {69, table69}, - {70, table70}, - {71, table71}, - {72, table72}, - {73, table73}, - {74, table74}, - {75, table75}, - {76, table76}, - {77, table77}, - {78, table78} - }; - - DefaultActions = new Dictionary - { - {21, new ParserAction(Reduce, ref table1)} - }; - - Productions = new Dictionary - { - {0, new ParserProduction(symbol0)}, - {1, new ParserProduction(symbol3,2)}, - {2, new ParserProduction(symbol4,1)}, - {3, new ParserProduction(symbol4,1)}, - {4, new ParserProduction(symbol4,1)}, - {5, new ParserProduction(symbol4,1)}, - {6, new ParserProduction(symbol4,1)}, - {7, new ParserProduction(symbol4,3)}, - {8, new ParserProduction(symbol4,3)}, - {9, new ParserProduction(symbol4,3)}, - {10, new ParserProduction(symbol4,4)}, - {11, new ParserProduction(symbol4,4)}, - {12, new ParserProduction(symbol4,4)}, - {13, new ParserProduction(symbol4,3)}, - {14, new ParserProduction(symbol4,3)}, - {15, new ParserProduction(symbol4,3)}, - {16, new ParserProduction(symbol4,3)}, - {17, new ParserProduction(symbol4,3)}, - {18, new ParserProduction(symbol4,3)}, - {19, new ParserProduction(symbol4,3)}, - {20, new ParserProduction(symbol4,2)}, - {21, new ParserProduction(symbol4,2)}, - {22, new ParserProduction(symbol4,1)}, - {23, new ParserProduction(symbol4,3)}, - {24, new ParserProduction(symbol4,4)}, - {25, new ParserProduction(symbol4,1)}, - {26, new ParserProduction(symbol4,1)}, - {27, new ParserProduction(symbol4,2)}, - {28, new ParserProduction(symbol25,1)}, - {29, new ParserProduction(symbol25,3)}, - {30, new ParserProduction(symbol25,1)}, - {31, new ParserProduction(symbol25,3)}, - {32, new ParserProduction(symbol25,3)}, - {33, new ParserProduction(symbol25,5)}, - {34, new ParserProduction(symbol24,1)}, - {35, new ParserProduction(symbol24,3)}, - {36, new ParserProduction(symbol24,3)}, - {37, new ParserProduction(symbol6,1)}, - {38, new ParserProduction(symbol6,3)}, - {39, new ParserProduction(symbol9,1)}, - {40, new ParserProduction(symbol9,3)}, - {41, new ParserProduction(symbol9,2)}, - {42, new ParserProduction(symbol2,3)}, - {43, new ParserProduction(symbol2,4)} - }; - - - - - //Setup Lexer - - Rules = new Dictionary - { - {0, new Regex(@"^(?:\s+)")}, - {1, new Regex(@"^(?:""(\\[""]|[^""])*"")")}, - {2, new Regex(@"^(?:'(\\[']|[^'])*')")}, - {3, new Regex(@"^(?:[A-Za-z]{1,}[A-Za-z_0-9]+(?=[(]))")}, - {4, new Regex(@"^(?:([0]?[1-9]|1[0-2])[:][0-5][0-9]([:][0-5][0-9])?[ ]?(AM|am|aM|Am|PM|pm|pM|Pm))")}, - {5, new Regex(@"^(?:([0]?[0-9]|1[0-9]|2[0-3])[:][0-5][0-9]([:][0-5][0-9])?)")}, - {6, new Regex(@"^(?:SHEET[0-9]+)")}, - {7, new Regex(@"^(?:\$[A-Za-z]+\$[0-9]+)")}, - {8, new Regex(@"^(?:[A-Za-z]+[0-9]+)")}, - {9, new Regex(@"^(?:[A-Za-z]+(?=[(]))")}, - {10, new Regex(@"^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)")}, - {11, new Regex(@"^(?:[A-Za-z_]+)")}, - {12, new Regex(@"^(?:[0-9]+)")}, - {13, new Regex(@"^(?:\\s)")}, - {14, new Regex(@"^(?:[.])")}, - {15, new Regex(@"^(?::)")}, - {16, new Regex(@"^(?:;)")}, - {17, new Regex(@"^(?:,)")}, - {18, new Regex(@"^(?:\*)")}, - {19, new Regex(@"^(?:\/)")}, - {20, new Regex(@"^(?:-)")}, - {21, new Regex(@"^(?:\+)")}, - {22, new Regex(@"^(?:\^)")}, - {23, new Regex(@"^(?:\()")}, - {24, new Regex(@"^(?:\))")}, - {25, new Regex(@"^(?:>)")}, - {26, new Regex(@"^(?:<)")}, - {27, new Regex(@"^(?:NOT\b)")}, - {28, new Regex(@"^(?:E\b)")}, - {29, new Regex(@"^(?:"")")}, - {30, new Regex(@"^(?:')")}, - {31, new Regex(@"^(?:!)")}, - {32, new Regex(@"^(?:=)")}, - {33, new Regex(@"^(?:%)")}, - {34, new Regex(@"^(?:[#])")}, - {35, new Regex(@"^(?:$)")} - }; - - Conditions = new Dictionary - { - {"INITIAL", new LexerConditions(new List { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35 }, true)} - }; - - - } - - public Expression ParserPerformAction(ref Expression thisS, ref Expression yy, ref int yystate, ref JList ss) - { - var so = ss.Count - 1; -/* this == yyval */ - - -switch (yystate) { -case 1:return ss[so-1]; -break; -case 2: - - - - thisS = ss[so]; - - -break; -case 3: - -break; -case 4: - -break; -case 5: - - - - ss[so].ToDouble(); - thisS = ss[so]; - - -break; -case 6: - - - - ss[so].ToString(); - thisS = ss[so]; - - -break; -case 7: - - - - ss[so-2].Set(ss[so-2].Text == ss[so].Text); - thisS = ss[so-2]; - - -break; -case 8: - - - - if (ss[so-2].IsNumeric()) { - ss[so-2].ToDouble(); - ss[so-2].Add(ss[so]); - thisS = ss[so-2]; - } else { - ss[so-2].ToString(); - ss[so-2].Concat(ss[so]); - thisS = ss[so-2]; - } - - -break; -case 9: - -break; -case 10: - - - - ss[so-3].Set(ss[so-3].ToDouble() <= ss[so].ToDouble()); - thisS = ss[so-3]; - - -break; -case 11: - - - - ss[so-3].Set(ss[so-3].ToDouble() >= ss[so].ToDouble()); - thisS = ss[so-3]; - - -break; -case 12: - - - ss[so-3].Set(ss[so-3].Text != ss[so].Text); - thisS = ss[so-3]; - - -break; -case 13: - - - ss[so-2].Set(ss[so-2].Text != ss[so].Text); - thisS = ss[so-2]; - - -break; -case 14: - - - - ss[so-2].Set(ss[so-2].ToDouble() > ss[so].ToDouble()); - thisS = ss[so-2]; - - -break; -case 15: - - - - ss[so-2].Set(ss[so-2].ToDouble() < ss[so].ToDouble()); - thisS = ss[so-2]; - - -break; -case 16: - - ss[so-2].Set(ss[so-2].ToDouble() - ss[so].ToDouble()); - thisS = ss[so-2]; - - -break; -case 17: - - - - ss[so-2].Set(ss[so-2].ToDouble() * ss[so].ToDouble()); - thisS = ss[so-2]; - - -break; -case 18: - - - - ss[so-2].Set(ss[so-2].ToDouble() / ss[so].ToDouble()); - thisS = ss[so-2]; - - -break; -case 19: - - - - ss[so-2].Set(Math.Pow(ss[so-2].ToDouble(), ss[so].ToDouble())); - thisS = ss[so-2]; - - -break; -case 20: - - - - ss[so].Set(-ss[so].ToDouble()); - thisS = ss[so]; - - -break; -case 21: - - - - ss[so].Set(ss[so].ToDouble()); - thisS = ss[so]; - - -break; -case 22:; -break; -case 23: - - - - thisS = Functions.Call(ss[so-2].Text); - - -break; -case 24: - - - - thisS = Functions.Call(ss[so-3].Text, ss[so-1]); - - -break; -case 28: - - - - thisS = Spreadsheet.CellValue(Location.ParseFixed(ss[so].Text)); - - -break; -case 29: - - - - thisS = Spreadsheet.CellValue(Location.ParseFixed(ss[so-2].Text), Location.ParseFixed(ss[so].Text)); - - -break; -case 30: - - - - thisS = Spreadsheet.CellValue(Location.Parse(ss[so].Text)); - - -break; -case 31: - - - - thisS = Spreadsheet.CellValue(Location.Parse(ss[so-2].Text), Location.Parse(ss[so].Text)); - - -break; -case 32: - - - - thisS = Spreadsheet.CellValue(Location.ParseRemote(ss[so-2].Text, ss[so].Text)); - - -break; -case 33: - - - - thisS = Spreadsheet.CellValue(Location.ParseRemote(ss[so-4].Text, ss[so-2].Text), Location.ParseRemote(ss[so-4].Text, ss[so].Text)); - - -break; -case 34: - - - - thisS = ss[so]; - - -break; -case 35: - - - - ss[so-2].Push(ss[so]); - thisS = ss[so-2]; - - -break; -case 36: - - - - ss[so-2].Push(ss[so]); - thisS = ss[so-2]; - - -break; -case 37: - - - - thisS = ss[so]; - - -break; -case 38: - - - - ss[so-2].Push(ss[so]); - thisS = ss[so-2]; - - -break; -case 39: - - ss[so].ToDouble(); - thisS = ss[so]; - - -break; -case 40: - - - - ss[so-2].Text += "." + ss[so].Text; - ss[so-2].ToDouble(); - thisS = ss[so-2]; - - -break; -case 41: - - ss[so-1].Set(ss[so-1].ToDouble() * 0.01); - thisS = ss[so-1]; - - -break; -case 42: - - - - ss[so-2].Set(ss[so-2].Text + ss[so-1].Text + ss[so].Text); - thisS = ss[so-2]; - - -break; -case 43: - - - - ss[so-3].Set(ss[so-3].Text + ss[so-2].Text + ss[so-1].Text + ss[so].Text); - thisS = ss[so-3]; - - -break; -} - - return null; - } - - public ParserSymbol ParserLex() - { - var token = LexerLex();//end = 1 - - if (token != null) - { - return token; - } - - return Symbols["end"]; - } - - public void ParseError(string error, ParserError hash = null) - { - throw new InvalidOperationException(error); - } - - public void LexerError(string error, LexerError hash = null) - { - throw new InvalidOperationException(error); - } - - public Expression Parse(string input) - { - if (Table == null) { - throw new Exception("Empty table"); - } - var stack = new JList - { - new ParserCachedAction(new ParserAction(0, Table[0])) - }; - var vstack = new JList - { - new Expression() - }; - var yy = new Expression(); - var _yy = new Expression(); - var v = new Expression(); - int recovering = 0; - ParserSymbol symbol = null; - ParserAction action = null; - string errStr = ""; - ParserSymbol preErrorSymbol = null; - ParserState state = null; - - SetInput(input); - - while (true) - { - // retreive state number from top of stack - state = stack.Last().Action.State; - - // use default actions if available - if (state != null && DefaultActions.ContainsKey(state.Index)) - { - action = DefaultActions[state.Index]; - } - else - { - if (symbol == null) - { - symbol = ParserLex(); - } - // read action for current state and first input - if (state != null && state.Actions.ContainsKey(symbol.Index)) - { - action = state.Actions[symbol.Index]; - } - else - { - action = null; - } - } - - if (action == null) - { - if (recovering > 0) - { - // Report error - var expected = new Stack{}; - foreach(var p in Table[state.Index].Actions) - { - expected.Push(Terminals[p.Value.Action].Name); - } - - errStr = "Parse error on line " + (Yy.LineNo + 1).ToString() + ":" + '\n' + - ShowPosition() + '\n' + - "Expecting " + String.Join(", ", expected) + - ", got '" + - (symbol != null ? Terminals[symbol.Index].ToString() : "NOTHING") + "'"; - - ParseError(errStr, new ParserError(Match, state, symbol, Yy.LineNo, yy.Loc, expected)); - } - } - - /*if (state.IsArray()) { - this.parseError("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); - }*/ - - if (state == null || action == null) - { - break; - } - - switch (action.Action) - { - case Shift: - stack.Push(new ParserCachedAction(action, symbol)); - vstack.Push(Yy.Clone()); - - symbol = null; - if (preErrorSymbol == null) - { // normal execution/no error - yy = Yy.Clone(); - if (recovering > 0) recovering--; - } else { // error just occurred, resume old lookahead f/ before error - symbol = preErrorSymbol; - preErrorSymbol = null; - } - break; - - case Reduce: - int len = Productions[action.State.Index].Len; - // perform semantic action - _yy = vstack[vstack.Count - len]; - - if (Ranges != null) - { - Yy.Loc.Range = new ParserRange( - vstack[vstack.Count - len].Loc.Range.X, - vstack.Last().Loc.Range.Y - ); - } - - var value = ParserPerformAction(ref _yy, ref yy, ref action.State.Index, ref vstack); - - if (value != null) - { - return value; - } - - // pop off stack - while (len > 0) - { - stack.Pop(); - vstack.Pop(); - len--; - } - - if (_yy == null) - { - vstack.Push(new Expression()); - } - else - { - vstack.Push(_yy.Clone()); - } - var nextSymbol = Productions[action.State.Index].Symbol; - // goto new state = table[STATE][NONTERMINAL] - var nextState = stack.Last().Action.State; - var nextAction = nextState.Actions[nextSymbol.Index]; - - stack.Push(new ParserCachedAction(nextAction, nextSymbol)); - - break; - case Accept: - return v; - } - } - - return v; - } - - /* Jison generated lexer */ - public ParserSymbol Eof = new ParserSymbol("Eof", 1); - public Expression Yy = new Expression(); - public string Match = ""; - public string Matched = ""; - public Stack ConditionStack; - public Dictionary Rules; - public Dictionary Conditions; - public bool Done = false; - public bool Less; - public bool _More; - public string _Input; - public int Offset; - public DictionaryRanges; - public bool Flex = false; - - public void SetInput(string input) - { - _Input = input; - _More = Less = Done = false; - Yy.LineNo = Yy.Leng = 0; - Matched = Match = ""; - ConditionStack = new Stack(); - ConditionStack.Push("INITIAL"); - - if (Ranges != null) - { - Yy.Loc = new ParserLocation(new ParserRange(0,0)); - } else { - Yy.Loc = new ParserLocation(); - } - - Offset = 0; - } - - public string Input() - { - string ch = _Input[0].ToString(); - Yy.Text += ch; - Yy.Leng++; - Offset++; - Match += ch; - Matched += ch; - Match lines = Regex.Match(ch, "/(?:\r\n?|\n).*/"); - if (lines.Success) { - Yy.LineNo++; - Yy.Loc.LastLine++; - } else { - Yy.Loc.LastColumn++; - } - - if (Ranges != null) - { - Yy.Loc.Range.Y++; - } - - _Input = _Input.Substring(1); - return ch; - } - - public void Unput(string ch) - { - int len = ch.Length; - var lines = Regex.Split(ch, "/(?:\r\n?|\n)/"); - - _Input = ch + _Input; - Yy.Text = Yy.Text.Substring(0, len - 1); - Offset -= len; - var oldLines = Regex.Split(Match, "/(?:\r\n?|\n)/"); - Match = Match.Substring(0, Match.Length - 1); - Matched = Matched.Substring(0, Matched.Length - 1); - - if ((lines.Length - 1) > 0) Yy.LineNo -= lines.Length - 1; - var r = Yy.Loc.Range; - - Yy.Loc = new ParserLocation( - Yy.Loc.FirstLine, - Yy.LineNo + 1, - Yy.Loc.FirstColumn, - ( - lines.Length > 0 ? - ( - lines.Length == oldLines.Length ? - Yy.Loc.FirstColumn : - 0 - ) + oldLines[oldLines.Length - lines.Length].Length - lines[0].Length : - Yy.Loc.FirstColumn - len - ) - ); - - if (Ranges.Count > 0) { - Yy.Loc.Range = new ParserRange(r.X, r.X + Yy.Leng - len); - } - } - - public void More() - { - _More = true; - } - - public string PastInput() - { - var past = Matched.Substring(0, Matched.Length - Match.Length); - return (past.Length > 20 ? "..." + Regex.Replace(past.Substring(-20), "/\n/", "") : ""); - } - - public string UpcomingInput() - { - var next = Match; - if (next.Length < 20) - { - next += _Input.Substring(0, (next.Length > 20 ? 20 - next.Length : next.Length)); - } - return Regex.Replace(next.Substring(0, (next.Length > 20 ? 20 - next.Length : next.Length)) + (next.Length > 20 ? "..." : ""), "/\n/", ""); - } - - public string ShowPosition() - { - var pre = PastInput(); - - var c = ""; - for (var i = 0; i < pre.Length; i++) - { - c += "-"; - } - - return pre + UpcomingInput() + '\n' + c + "^"; - } - - public ParserSymbol Next() - { - if (Done == true) - { - return Eof; - } - - if (String.IsNullOrEmpty(_Input)) - { - Done = true; - } - - if (_More == false) - { - Yy.Text = ""; - Match = ""; - } - - var rules = CurrentRules(); - string match = ""; - bool matched = false; - int index = 0; - Regex rule; - for (int i = 0; i < rules.Count; i++) - { - rule = Rules[rules[i]]; - var tempMatch = rule.Match(_Input); - if (tempMatch.Success == true && (match != null || tempMatch.Length > match.Length)) { - match = tempMatch.Value; - matched = true; - index = i; - if (!Flex) { - break; - } - } - } - if ( matched ) - { - Match lineCount = Regex.Match(match, "/\n.*/"); - - Yy.LineNo += lineCount.Length; - Yy.Loc.FirstLine = Yy.Loc.LastLine; - Yy.Loc.LastLine = Yy.LineNo + 1; - Yy.Loc.FirstColumn = Yy.Loc.LastColumn; - Yy.Loc.LastColumn = lineCount.Length > 0 ? lineCount.Length - 1 : Yy.Loc.LastColumn + match.Length; - - Yy.Text += match; - Match += match; - Matched += match; - - Yy.Leng = Yy.Text.Length; - if (Ranges != null) - { - Yy.Loc.Range = new ParserRange(Offset, Offset += Yy.Leng); - } - _More = false; - _Input = _Input.Substring(match.Length); - var ruleIndex = rules[index]; - var nextCondition = ConditionStack.Peek(); - dynamic action = LexerPerformAction(ruleIndex, nextCondition); - ParserSymbol token = Symbols[action]; - - if (Done == true && String.IsNullOrEmpty(_Input) == false) - { - Done = false; - } - - if (token.Index > -1) { - return token; - } else { - return null; - } - } - - if (String.IsNullOrEmpty(_Input)) { - return Symbols["EOF"]; - } else - { - LexerError("Lexical error on line " + (Yy.LineNo + 1) + ". Unrecognized text.\n" + ShowPosition(), new LexerError("", -1, Yy.LineNo)); - return null; - } - } - - public ParserSymbol LexerLex() - { - var r = Next(); - - while (r == null) - { - r = Next(); - } - - return r; - } - - public void Begin(string condition) - { - ConditionStack.Push(condition); - } - - public string PopState() - { - return ConditionStack.Pop(); - } - - public List CurrentRules() - { - var peek = ConditionStack.Peek(); - return Conditions[peek].Rules; - } - - public dynamic LexerPerformAction(int avoidingNameCollisions, string Yy_Start) - { - - -; -switch(avoidingNameCollisions) { -case 0:/* skip whitespace */ -break; -case 1:return 10; -break; -case 2:return 10; -break; -case 3:return 23; -break; -case 4:return 7; -break; -case 5:return 8; -break; -case 6: - - - - return 29; - //return 33; - - -break; -case 7: - - - - return 26; - //return 33; - - -break; -case 8: - - - - return 28; - //return 33; - - -break; -case 9:return 23; -break; -case 10:return 33; -break; -case 11:return 33; -break; -case 12:return 35; -break; -case 13:/* skip whitespace */ -break; -case 14:return 34; -break; -case 15:return 27; -break; -case 16:return 31; -break; -case 17:return 32; -break; -case 18:return 19; -break; -case 19:return 20; -break; -case 20:return 18; -break; -case 21:return 12; -break; -case 22:return 21; -break; -case 23:return 13; -break; -case 24:return 14; -break; -case 25:return 16; -break; -case 26:return 15; -break; -case 27:return 17; -break; -case 28:return 22; -break; -case 29:return '"'; -break; -case 30:return "'"; -break; -case 31:return "!"; -break; -case 32:return 11; -break; -case 33:return 36; -break; -case 34:return 37; -break; -case 35:return 5; -break; -} - - return -1; - } - } - - public class ParserLocation - { - public int FirstLine = 1; - public int LastLine = 0; - public int FirstColumn = 1; - public int LastColumn = 0; - public ParserRange Range; - - public ParserLocation() - { - } - - public ParserLocation(ParserRange range) - { - Range = range; - } - - public ParserLocation(int firstLine, int lastLine, int firstColumn, int lastColumn) - { - FirstLine = firstLine; - LastLine = lastLine; - FirstColumn = firstColumn; - LastColumn = lastColumn; - } - - public ParserLocation(int firstLine, int lastLine, int firstColumn, int lastColumn, ParserRange range) - { - FirstLine = firstLine; - LastLine = lastLine; - FirstColumn = firstColumn; - LastColumn = lastColumn; - Range = range; - } - } - - public class LexerConditions - { - public List Rules; - public bool Inclusive; - - public LexerConditions(List rules, bool inclusive) - { - Rules = rules; - Inclusive = inclusive; - } - } - - public class ParserProduction - { - public int Len = 0; - public ParserSymbol Symbol; - - public ParserProduction(ParserSymbol symbol) - { - Symbol = symbol; - } - - public ParserProduction(ParserSymbol symbol, int len) - { - Symbol = symbol; - Len = len; - } - } - - public class ParserCachedAction - { - public ParserAction Action; - public ParserSymbol Symbol; - - public ParserCachedAction(ParserAction action) - { - Action = action; - } - - public ParserCachedAction(ParserAction action, ParserSymbol symbol) - { - Action = action; - Symbol = symbol; - } - } - - public class ParserAction - { - public int Action; - public ParserState State; - public ParserSymbol Symbol; - - public ParserAction(int action) - { - Action = action; - } - - public ParserAction(int action, ref ParserState state) - { - Action = action; - State = state; - } - - public ParserAction(int action, ParserState state) - { - Action = action; - State = state; - } - - public ParserAction(int action, ref ParserSymbol symbol) - { - Action = action; - Symbol = symbol; - } - } - - public class ParserSymbol - { - public string Name; - public int Index = -1; - public IDictionary Symbols = new Dictionary(); - public IDictionary SymbolsByName = new Dictionary(); - - public ParserSymbol() - { - } - - public ParserSymbol(string name, int index) - { - Name = name; - Index = index; - } - - public void AddAction(ParserSymbol p) - { - Symbols.Add(p.Index, p); - SymbolsByName.Add(p.Name, p); - } - } - - public class ParserError - { - public String Text; - public ParserState State; - public ParserSymbol Symbol; - public int LineNo; - public ParserLocation Loc; - public Stack Expected; - - public ParserError(String text, ParserState state, ParserSymbol symbol, int lineNo, ParserLocation loc, Stack expected) - { - Text = text; - State = state; - Symbol = symbol; - LineNo = lineNo; - Loc = loc; - Expected = expected; - } - } - - public class LexerError - { - public String Text; - public int Token; - public int LineNo; - - public LexerError(String text, int token, int lineNo) - { - Text = text; - Token = token; - LineNo = lineNo; - } - } - - public class ParserState - { - public int Index; - public Dictionary Actions = new Dictionary(); - - public ParserState(int index) - { - Index = index; - } - - public void SetActions(ref Dictionary actions) - { - Actions = actions; - } - } - - public class ParserRange - { - public int X; - public int Y; - - public ParserRange(int x, int y) - { - X = x; - Y = y; - } - } - - public class ParserSymbols - { - private Dictionary SymbolsString = new Dictionary(); - private Dictionary SymbolsInt = new Dictionary(); - - public void Add(ParserSymbol symbol) - { - SymbolsInt.Add(symbol.Index, symbol); - SymbolsString.Add(symbol.Name, symbol); - } - - public ParserSymbol this[char name] - { - get - { - return SymbolsString[name.ToString()]; - } - } - - public ParserSymbol this[string name] - { - get - { - return SymbolsString[name]; - } - } - - public ParserSymbol this[int index] - { - get - { - if (index < 0) - { - return new ParserSymbol(); - } - return SymbolsInt[index]; - } - } - } - - public class ParserValue - { - public string Text; - public ParserLocation Loc; - public int Leng = 0; - public int LineNo = 0; - - public ParserValue() - { - } - - public ParserValue(ParserValue parserValue) - { - Text = parserValue.Text; - Leng = parserValue.Leng; - Loc = parserValue.Loc; - LineNo = parserValue.LineNo; - } - - public ParserValue Clone() - { - return new ParserValue(this); - } - } - - public class JList : List where T : class - { - public void Push(T item) - { - Add(item); - } - - public void Pop() - { - RemoveAt(Count - 1); - } - - new public T this[int index] - { - get - { - if (index >= Count || index < 0 || Count == 0) - { - return null; - } - return base[index]; - } - } - } -} \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/Test/Functions.cs b/ports/csharp/Jison/Jison/Test/Functions.cs deleted file mode 100644 index 4edce4b0a..000000000 --- a/ports/csharp/Jison/Jison/Test/Functions.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using Jison; - -namespace jQuerySheet -{ - public static class Functions - { - public static Expression Call(string fnName) - { - return Call(fnName, new Expression()); - } - - public static Expression Call(string fnName, Expression value) - { - Expression result = null; - switch (fnName.ToUpper()) - { - case "SUM": - result = Sum(value); - break; - } - - return result; - } - - public static Expression Sum(Expression value) - { - if (value.Children != null) - { - double sum = 0; - foreach (Expression child in value.Children) - { - sum += child.ToDouble(); - } - - var firstChild = value.Children[0]; - firstChild.Set(sum); - return firstChild; - } - - value.ToDouble (); - return value; - } - } -} - diff --git a/ports/csharp/Jison/Jison/Test/Location.cs b/ports/csharp/Jison/Jison/Test/Location.cs deleted file mode 100644 index 6864d4aec..000000000 --- a/ports/csharp/Jison/Jison/Test/Location.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace jQuerySheet -{ - public class Location - { - public Location () - { - } - - public int Sheet = -1; - public int Row = -1; - public int Col = -1; - public bool IsFixed = false; - public bool IsRemote = false; - - static readonly public Dictionary Alphabet = new Dictionary() - { - {"A", 0}, - {"B", 1}, - {"C", 2}, - {"D", 3}, - {"E", 4}, - {"F", 5}, - {"G", 6}, - {"H", 7}, - {"I", 8}, - {"J", 9}, - {"K", 10}, - {"L", 11}, - {"M", 12}, - {"N", 13}, - {"O", 14}, - {"P", 15}, - {"Q", 16}, - {"R", 17}, - {"S", 18}, - {"T", 19}, - {"U", 20}, - {"V", 21}, - {"W", 22}, - {"X", 23}, - {"Y", 24}, - {"Z", 25} - }; - - static readonly public Regex Cell = new Regex("^([A-Z]+)([0-9]+)"); - - public static Location Parse(string id) - { - return new Location(id); - } - - public static Location ParseRemote(string sheet, string id) - { - return new Location(sheet, id); - } - - public static Location ParseFixed(string id) - { - return new Location(id, true); - } - - public static Location ParseRemoteFixed(string sheet, string id) - { - return new Location(sheet, id, true); - } - - public void ParseCellId(string id) - { - var match = Cell.Match(id); - if (match.Success) - { - Col = Alphabet[match.Groups[1].Value]; - Row = Convert.ToInt32(match.Groups[2].Value) - 1; - } - Sheet = Spreadsheet.ActiveSpreadsheet; - } - - public void ParseSheetId(string sheet) - { - sheet = sheet.Replace("sheet", ""); - Sheet = Convert.ToInt32(sheet); - } - - public Location(string id) - { - ParseCellId(id); - } - - public Location(string sheet, string id) - { - ParseCellId(id); - ParseSheetId(sheet); - IsRemote = true; - } - - public Location(string id, bool remote) - { - ParseCellId(id); - IsRemote = remote; - } - - public Location(string sheet, string id, bool remote) - { - ParseCellId(id); - ParseSheetId(sheet); - IsRemote = remote; - } - } -} - diff --git a/ports/csharp/Jison/Jison/Test/RowDictionary.cs b/ports/csharp/Jison/Jison/Test/RowDictionary.cs deleted file mode 100644 index a29ecd704..000000000 --- a/ports/csharp/Jison/Jison/Test/RowDictionary.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace jQuerySheet -{ - public class RowDictionary : Dictionary - { - public RowDictionary () - { - } - } -} - diff --git a/ports/csharp/Jison/Jison/Test/Spreadsheet.cs b/ports/csharp/Jison/Jison/Test/Spreadsheet.cs deleted file mode 100644 index 44be3f8fe..000000000 --- a/ports/csharp/Jison/Jison/Test/Spreadsheet.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Text; -using System.Threading.Tasks; -using System.Collections.Generic; - -namespace jQuerySheet -{ - public class Spreadsheet - { - static public int ActiveSpreadsheet = 0; - static public SpreadsheetsDictionary Spreadsheets; - - - public SpreadsheetsDictionary Calc() - { - foreach (var Spreadsheet in Spreadsheets.Values) { - foreach (var row in Spreadsheet.Values) { - foreach (var cell in row) { - cell.Value.UpdateValue(); - } - } - } - - return Spreadsheets; - } - - public static DateTime CalcLast; - - public static Expression UpdateCellValue(Cell cell) - { - if (cell.HasFormula && cell.State.Count < 1) - { - cell.State.Push("Parsing"); - cell.CalcCount++; - cell.CalcLast = CalcLast; - var formula = new Formula(); - var value = formula.Parse(cell.Formula); - cell.State.Pop(); - return value; - } - return cell.Exp; - } - - public static Expression CellValue(int spreadsheet, int row, int col) - { - var cell = Spreadsheets[spreadsheet][row][col]; - var value = UpdateCellValue(cell); - return value; - } - - public static Expression CellValue(Location loc) - { - var cell = Spreadsheets[loc.Sheet][loc.Row][loc.Col]; - var value = UpdateCellValue(cell); - return value; - } - - public static Expression CellValue(Location locStart, Location locEnd) - { - var range = new Expression(); - - for (var row = locStart.Row; row <= locEnd.Row; row++) - { - for (var col = locStart.Col; col <= locEnd.Col; col++) - { - range.Push(Spreadsheets[locStart.Sheet][row][col].UpdateValue()); - } - } - - return range; - } - } -} diff --git a/ports/csharp/Jison/Jison/Test/SpreadsheetDictionary.cs b/ports/csharp/Jison/Jison/Test/SpreadsheetDictionary.cs deleted file mode 100644 index a4441bf0c..000000000 --- a/ports/csharp/Jison/Jison/Test/SpreadsheetDictionary.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using jQuerySheet; - -namespace jQuerySheet -{ - public class SpreadsheetDictionary : Dictionary - { - public int RowIndex = -1; - public RowDictionary ActiveRow; - public void AddRow() - { - ActiveRow = new RowDictionary(); - RowIndex++; - Add (RowIndex, ActiveRow); - } - } -} - diff --git a/ports/csharp/Jison/Jison/Test/SpreadsheetsDictionary.cs b/ports/csharp/Jison/Jison/Test/SpreadsheetsDictionary.cs deleted file mode 100644 index 0c0dfa11e..000000000 --- a/ports/csharp/Jison/Jison/Test/SpreadsheetsDictionary.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace jQuerySheet -{ - public class SpreadsheetsDictionary : Dictionary - { - } -} - diff --git a/ports/csharp/Jison/Jison/Test/formula.jison b/ports/csharp/Jison/Jison/Test/formula.jison deleted file mode 100644 index 9814f4636..000000000 --- a/ports/csharp/Jison/Jison/Test/formula.jison +++ /dev/null @@ -1,640 +0,0 @@ -//option parserValue:Expression -//option namespace:jQuerySheet - -/* description: Parses end evaluates mathematical expressions. */ -/* lexical grammar */ -%lex -%% -\s+ {/* skip whitespace */} -'"'("\\"["]|[^"])*'"' {return 'STRING';} -"'"('\\'[']|[^'])*"'" {return 'STRING';} -[A-Za-z]{1,}[A-Za-z_0-9]+(?=[(]) {return 'FUNCTION';} -([0]?[1-9]|1[0-2])[:][0-5][0-9]([:][0-5][0-9])?[ ]?(AM|am|aM|Am|PM|pm|pM|Pm) - {return 'TIME_AMPM';} -([0]?[0-9]|1[0-9]|2[0-3])[:][0-5][0-9]([:][0-5][0-9])? - {return 'TIME_24';} -'SHEET'[0-9]+ -%{ - //js - if (yy.obj.type == 'cell') return 'SHEET'; - return 'VARIABLE'; - - /*php - if ($this->type == 'cell') return 'SHEET'; - return 'VARIABLE'; - */ - - /*cs - return 'SHEET'; - //return 'VARIABLE'; - */ -%} -'$'[A-Za-z]+'$'[0-9]+ -%{ - //js - if (yy.obj.type == 'cell') return 'FIXEDCELL'; - return 'VARIABLE'; - - /*php - if ($this->type == 'cell') return 'FIXEDCELL'; - return 'VARIABLE'; - */ - - /*cs - return 'FIXEDCELL'; - //return 'VARIABLE'; - */ -%} -[A-Za-z]+[0-9]+ -%{ - //js - if (yy.obj.type == 'cell') return 'CELL'; - return 'VARIABLE'; - - /*php - if ($this->type == 'cell') return 'CELL'; - return 'VARIABLE'; - */ - - /*cs - return 'CELL'; - //return 'VARIABLE'; - */ -%} -[A-Za-z]+(?=[(]) {return 'FUNCTION';} -[A-Za-z]{1,}[A-Za-z_0-9]+ {return 'VARIABLE';} -[A-Za-z_]+ {return 'VARIABLE';} -[0-9]+ {return 'NUMBER';} -"\s" {/* skip whitespace */} -[.] {return 'DECIMAL';} -":" {return ':';} -";" {return ';';} -"," {return ',';} -"*" {return '*';} -"/" {return '/';} -"-" {return '-';} -"+" {return '+';} -"^" {return '^';} -"(" {return '(';} -")" {return ')';} -">" {return '>';} -"<" {return '<';} -"NOT" {return 'NOT';} -"E" {return 'E';} -'"' {return '"';} -"'" {return "'";} -"!" {return "!";} -"=" {return '=';} -"%" {return '%';} -[#] {return '#';} -<> {return 'EOF';} - - -/lex - -/* operator associations and precedence (low-top, high- bottom) */ -%left '=' -%left '<=' '>=' '<>' 'NOT' '||' -%left '>' '<' -%left '+' '-' -%left '*' '/' -%left '^' -%left '%' -%left UMINUS - -%start expressions - -%% /* language grammar */ - -expressions -: expression EOF - {return $1;} - ; - -expression : - variableSequence - { - //js - $$ = yy.handler.variable.apply(yy.obj, $1); - - //php $$ = $this->variable($1); - - /*cs - $$ = $1; - */ - } - | TIME_AMPM - { - //js - $$ = yy.handler.time.apply(yy.obj, [$1, true]); - // - } - | TIME_24 - { - //js - $$ = yy.handler.time.apply(yy.obj, [$1]); - // - } - | number - { - //js - $$ = yy.handler.number.apply(yy.obj, [$1]); - - //php $$ = $1 * 1; - - /*cs - $1.ToDouble(); - $$ = $1; - */ - } - | STRING - { - //js - $$ = $1.substring(1, $1.length - 1); - - //php $$ = substr($1, 1, -1); - - /*cs - $1.ToString(); - $$ = $1; - */ - } - | expression '=' expression - { - //js - yy.obj.html.pop(); - $$ = yy.handler.callFunction.apply(yy.obj, ['EQUAL', [$1, $3]]); - - //php $$ = $1 == $3; - - /*cs - $1.Set($1.Text == $3.Text); - $$ = $1; - */ - } - | expression '+' expression - { - //js - $$ = yy.handler.performMath.apply(yy.obj, ['+', $1, $3]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - /*php - if (is_numeric($1) && is_numeric($3)) { - $$ = $1 + $3; - } else { - $$ = $1 . $3; - } - */ - - /*cs - if ($1.IsNumeric()) { - $1.ToDouble(); - $1.Add($3); - $$ = $1; - } else { - $1.ToString(); - $1.Concat($3); - $$ = $1; - } - */ - } - | '(' expression ')' - { - //js - $$ = yy.handler.number.apply(yy.obj, [$2]); - // - } - | expression '<' '=' expression - { - //js - $$ = yy.handler.callFunction.apply(yy.obj, ['LESS_EQUAL', [$1, $3]]); - - //php $$ = ($1 * 1) <= ($4 * 1); - - /*cs - $1.Set($1.ToDouble() <= $4.ToDouble()); - $$ = $1; - */ - } - | expression '>' '=' expression - { - //js - $$ = yy.handler.callFunction.apply(yy.obj, ['GREATER_EQUAL', [$1, $3]]); - - //php $$ = ($1 * 1) >= ($4 * 1); - - /*cs - $1.Set($1.ToDouble() >= $4.ToDouble()); - $$ = $1; - */ - } - | expression '<' '>' expression - { - //js|php - $$ = ($1 * 1) != ($4 * 1); - - //js - if (isNaN($$)) $$ = 0; - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - // - - /*cs - $1.Set($1.Text != $4.Text); - $$ = $1; - */ - } - | expression NOT expression - { - //js|php - $$ = $1 != $3; - - //js - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - // - - /*cs - $1.Set($1.Text != $3.Text); - $$ = $1; - */ - } - | expression '>' expression - { - //js - $$ = yy.handler.callFunction.apply(yy.obj, ['GREATER', [$1, $3]]); - - //php $$ = ($1 * 1) > ($3 * 1); - - /*cs - $1.Set($1.ToDouble() > $3.ToDouble()); - $$ = $1; - */ - } - | expression '<' expression - { - //js - $$ = yy.handler.callFunction.apply(yy.obj, ['LESS', [$1, $3]]); - - //php $$ = ($1 * 1) < ($3 * 1); - - /*cs - $1.Set($1.ToDouble() < $3.ToDouble()); - $$ = $1; - */ - } - | expression '-' expression - { - //js|php - $$ = ($1 * 1) - ($3 * 1); - - //js - $$ = yy.handler.performMath.apply(yy.obj, ['-', $1, $3]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - /*cs - $1.Set($1.ToDouble() - $3.ToDouble()); - $$ = $1; - */ - } - | expression '*' expression - { - //js - $$ = yy.handler.performMath.apply(yy.obj, ['*', $1, $3]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - //php $$ = ($1 * 1) * ($3 * 1); - - /*cs - $1.Set($1.ToDouble() * $3.ToDouble()); - $$ = $1; - */ - } - | expression '/' expression - { - //js - $$ = yy.handler.performMath.apply(yy.obj, ['/', $1, $3]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - //php $$ = ($1 * 1) / ($3 * 1); - - /*cs - $1.Set($1.ToDouble() / $3.ToDouble()); - $$ = $1; - */ - } - | expression '^' expression - { - //js - var n1 = yy.handler.number.apply(yy.obj, [$1]), - n2 = yy.handler.number.apply(yy.obj, [$3]); - - $$ = yy.handler.performMath.apply(yy.obj, ['^', $1, $3]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - //php $$ = pow(($1 * 1), ($3 * 1)); - - /*cs - $1.Set(Math.Pow($1.ToDouble(), $3.ToDouble())); - $$ = $1; - */ - } - | '-' expression - { - //js - var n1 = yy.handler.number.apply(yy.obj, [$2]); - $$ = n1 * -1; - if (isNaN($$)) $$ = 0; - - //php $$ = $1 * 1; - - /*cs - $2.Set(-$2.ToDouble()); - $$ = $2; - */ - } - | '+' expression - { - //js - var n1 = yy.handler.number.apply(yy.obj, [$2]); - $$ = n1 * 1; - if (isNaN($$)) $$ = 0; - - //php $$ = $1 * 1; - - /*cs - $2.Set($2.ToDouble()); - $$ = $2; - */ - } - | E - {/*$$ = Math.E;*/;} - | FUNCTION '(' ')' - { - //js - $$ = yy.handler.callFunction.apply(yy.obj, [$1, '']); - - //php $$ = $this->callFunction($1); - - /*cs - $$ = Functions.Call($1.Text); - */ - } - | FUNCTION '(' expseq ')' - { - //js - $$ = yy.handler.callFunction.apply(yy.obj, [$1, $3]); - - //php $$ = $this->callFunction($1, $3); - - /*cs - $$ = Functions.Call($1.Text, $3); - */ - } - | cell - | error - | error error -; - -cell : - FIXEDCELL - { - //js - $$ = yy.handler.fixedCellValue.apply(yy.obj, [$1]); - - //php $$ = $this->fixedCellValue($1); - - /*cs - $$ = Spreadsheet.CellValue(Location.ParseFixed($1.Text)); - */ - } - | FIXEDCELL ':' FIXEDCELL - { - //js - $$ = yy.handler.fixedCellRangeValue.apply(yy.obj, [$1, $3]); - - //php $$ = $this->fixedCellRangeValue($1, $3); - - /*cs - $$ = Spreadsheet.CellValue(Location.ParseFixed($1.Text), Location.ParseFixed($3.Text)); - */ - } - | CELL - { - //js - $$ = yy.handler.cellValue.apply(yy.obj, [$1]); - - //php $$ = $this->cellValue($1); - - /*cs - $$ = Spreadsheet.CellValue(Location.Parse($1.Text)); - */ - } - | CELL ':' CELL - { - //js - $$ = yy.handler.cellRangeValue.apply(yy.obj, [$1, $3]); - - //php $$ = $this->cellRangeValue($1, $3); - - /*cs - $$ = Spreadsheet.CellValue(Location.Parse($1.Text), Location.Parse($3.Text)); - */ - } - | SHEET '!' CELL - { - //js - $$ = yy.handler.remoteCellValue.apply(yy.obj, [$1, $3]); - - //php $$ = $this->remoteCellValue($1, $3); - - /*cs - $$ = Spreadsheet.CellValue(Location.ParseRemote($1.Text, $3.Text)); - */ - } - | SHEET '!' CELL ':' CELL - { - //js - $$ = yy.handler.remoteCellRangeValue.apply(yy.obj, [$1, $3, $5]); - - //php $$ = $this->remoteCellRangeValue($1, $3, $5); - - /*cs - $$ = Spreadsheet.CellValue(Location.ParseRemote($1.Text, $3.Text), Location.ParseRemote($1.Text, $5.Text)); - */ - } -; - -expseq : - expression - { - //js - $$ = [$1]; - - //php $$ = array($1); - - /*cs - $$ = $1; - */ - } - | expseq ';' expression - { - //js - $1.push($3); - $$ = $1; - - /*php - $1[] = $3; - $$ = $1; - */ - - /*cs - $1.Push($3); - $$ = $1; - */ - } - | expseq ',' expression - { - //js - $1.push($3); - $$ = $1; - - /*php - $1[] = $3; - $$ = $1; - */ - - /*cs - $1.Push($3); - $$ = $1; - */ - } - ; - - -variableSequence : - VARIABLE - { - //js - $$ = [$1]; - - //php $$ = array($1); - - /*cs - $$ = $1; - */ - } - | variableSequence DECIMAL VARIABLE - { - //js - $$ = ($.isArray($1) ? $1 : [$1]); - $$.push($3); - - /*php - $$ = (is_array($1) ? $1 : array()); - $$[] = $3; - */ - - /*cs - $1.Push($3); - $$ = $1; - */ - } -; - -number : - NUMBER - { - //js|php - $$ = $1 * 1; - - /*cs - $1.ToDouble(); - $$ = $1; - */ - } - | NUMBER DECIMAL NUMBER - { - //js - $$ =($1 + '.' + $3) * 1; - - //php $$ = $1 . '.' . $3; - - /*cs - $1.Text += "." + $3.Text; - $1.ToDouble(); - $$ = $1; - */ - } - | number '%' - { - //js - yy.obj.html.push($1 + $2); - - //js|php - $$ = $1 * 0.01; - - /*cs - $1.Set($1.ToDouble() * 0.01); - $$ = $1; - */ - } -; - -error : - '#' VARIABLE '!' { - //js - $$ = $1 + $2 + $3; - - //php $$ = $1 . $2 . $3; - - /*cs - $1.Set($1.Text + $2.Text + $3.Text); - $$ = $1; - */ - } - | VARIABLE '#' VARIABLE '!' { - //js - $$ = $2 + $3 + $4; - - //php $$ = $2 . $3 . $4; - - /*cs - $1.Set($1.Text + $2.Text + $3.Text + $4.Text); - $$ = $1; - */ - } -; - -%% -if (typeof(window) !== 'undefined') { - window.Formula = function(handler) { - var formulaLexer = function () {}; - formulaLexer.prototype = formula.lexer; - - var formulaParser = function () { - this.lexer = new formulaLexer(); - this.yy = {}; - }; - - formulaParser.prototype = formula; - var newParser = new formulaParser; - newParser.setObj = function(obj) { - newParser.yy.obj = obj; - }; - newParser.yy.handler = handler; - return newParser; - }; -} \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/Test/formula.js b/ports/csharp/Jison/Jison/Test/formula.js deleted file mode 100644 index e040e4acd..000000000 --- a/ports/csharp/Jison/Jison/Test/formula.js +++ /dev/null @@ -1,1303 +0,0 @@ -/* parser generated by jison 0.4.6 */ -/* - Returns a Parser object of the following structure: - - Parser: { - yy: {} - } - - Parser.prototype: { - yy: {}, - trace: function(), - symbols_: {associative list: name ==> number}, - terminals_: {associative list: number ==> name}, - productions_: [...], - performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), - table: [...], - defaultActions: {...}, - parseError: function(str, hash), - parse: function(input), - - lexer: { - EOF: 1, - parseError: function(str, hash), - setInput: function(input), - input: function(), - unput: function(str), - more: function(), - less: function(n), - pastInput: function(), - upcomingInput: function(), - showPosition: function(), - test_match: function(regex_match_array, rule_index), - next: function(), - lex: function(), - begin: function(condition), - popState: function(), - _currentRules: function(), - topState: function(), - pushState: function(condition), - - options: { - ranges: boolean (optional: true ==> token location info will include a .range[] member) - flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) - backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) - }, - - performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), - rules: [...], - conditions: {associative list: name ==> set}, - } - } - - - token location info (@$, _$, etc.): { - first_line: n, - last_line: n, - first_column: n, - last_column: n, - range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) - } - - - the parseError function receives a 'hash' object with these members for lexer and parser errors: { - text: (matched text) - token: (the produced terminal token, if any) - line: (yylineno) - } - while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { - loc: (yylloc) - expected: (string describing the set of expected tokens) - recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) - } -*/ -var formula = (function(){ -var parser = {trace: function trace() { }, -yy: {}, -symbols_: {"error":2,"expressions":3,"expression":4,"EOF":5,"variableSequence":6,"TIME_AMPM":7,"TIME_24":8,"number":9,"STRING":10,"=":11,"+":12,"(":13,")":14,"<":15,">":16,"NOT":17,"-":18,"*":19,"/":20,"^":21,"E":22,"FUNCTION":23,"expseq":24,"cell":25,"FIXEDCELL":26,":":27,"CELL":28,"SHEET":29,"!":30,";":31,",":32,"VARIABLE":33,"DECIMAL":34,"NUMBER":35,"%":36,"#":37,"$accept":0,"$end":1}, -terminals_: {5:"EOF",7:"TIME_AMPM",8:"TIME_24",10:"STRING",11:"=",12:"+",13:"(",14:")",15:"<",16:">",17:"NOT",18:"-",19:"*",20:"/",21:"^",22:"E",23:"FUNCTION",26:"FIXEDCELL",27:":",28:"CELL",29:"SHEET",30:"!",31:";",32:",",33:"VARIABLE",34:"DECIMAL",35:"NUMBER",36:"%",37:"#"}, -productions_: [0,[3,2],[4,1],[4,1],[4,1],[4,1],[4,1],[4,3],[4,3],[4,3],[4,4],[4,4],[4,4],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,2],[4,2],[4,1],[4,3],[4,4],[4,1],[4,1],[4,2],[25,1],[25,3],[25,1],[25,3],[25,3],[25,5],[24,1],[24,3],[24,3],[6,1],[6,3],[9,1],[9,3],[9,2],[2,3],[2,4]], -performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { -/* this == yyval */ - -var $0 = $$.length - 1; -switch (yystate) { -case 1:return $$[$0-1]; -break; -case 2: - //js - this.$ = yy.handler.variable.apply(yy.obj, $$[$0]); - - //php this.$ = this->variable($$[$0]); - - /*cs - this.$ = $$[$0]; - */ - -break; -case 3: - //js - this.$ = yy.handler.time.apply(yy.obj, [$$[$0], true]); - // - -break; -case 4: - //js - this.$ = yy.handler.time.apply(yy.obj, [$$[$0]]); - // - -break; -case 5: - //js - this.$ = yy.handler.number.apply(yy.obj, [$$[$0]]); - - //php this.$ = $$[$0] * 1; - - /*cs - $$[$0].ToDouble(); - this.$ = $$[$0]; - */ - -break; -case 6: - //js - this.$ = $$[$0].substring(1, $$[$0].length - 1); - - //php this.$ = substr($$[$0], 1, -1); - - /*cs - $$[$0].ToString(); - this.$ = $$[$0]; - */ - -break; -case 7: - //js - yy.obj.html.pop(); - this.$ = yy.handler.callFunction.apply(yy.obj, ['EQUAL', [$$[$0-2], $$[$0]]]); - - //php this.$ = $$[$0-2] == $$[$0]; - - /*cs - $$[$0-2].Set($$[$0-2].Text == $$[$0].Text); - this.$ = $$[$0-2]; - */ - -break; -case 8: - //js - this.$ = yy.handler.performMath.apply(yy.obj, ['+', $$[$0-2], $$[$0]]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - /*php - if (is_numeric($$[$0-2]) && is_numeric($$[$0])) { - this.$ = $$[$0-2] + $$[$0]; - } else { - this.$ = $$[$0-2] . $$[$0]; - } - */ - - /*cs - if ($$[$0-2].IsNumeric()) { - $$[$0-2].ToDouble(); - $$[$0-2].Add($$[$0]); - this.$ = $$[$0-2]; - } else { - $$[$0-2].ToString(); - $$[$0-2].Concat($$[$0]); - this.$ = $$[$0-2]; - } - */ - -break; -case 9: - //js - this.$ = yy.handler.number.apply(yy.obj, [$$[$0-1]]); - // - -break; -case 10: - //js - this.$ = yy.handler.callFunction.apply(yy.obj, ['LESS_EQUAL', [$$[$0-3], $$[$0-1]]]); - - //php this.$ = ($$[$0-3] * 1) <= ($$[$0] * 1); - - /*cs - $$[$0-3].Set($$[$0-3].ToDouble() <= $$[$0].ToDouble()); - this.$ = $$[$0-3]; - */ - -break; -case 11: - //js - this.$ = yy.handler.callFunction.apply(yy.obj, ['GREATER_EQUAL', [$$[$0-3], $$[$0-1]]]); - - //php this.$ = ($$[$0-3] * 1) >= ($$[$0] * 1); - - /*cs - $$[$0-3].Set($$[$0-3].ToDouble() >= $$[$0].ToDouble()); - this.$ = $$[$0-3]; - */ - -break; -case 12: - //js|php - this.$ = ($$[$0-3] * 1) != ($$[$0] * 1); - - //js - if (isNaN(this.$)) this.$ = 0; - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - // - - /*cs - $$[$0-3].Set($$[$0-3].Text != $$[$0].Text); - this.$ = $$[$0-3]; - */ - -break; -case 13: - //js|php - this.$ = $$[$0-2] != $$[$0]; - - //js - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - // - - /*cs - $$[$0-2].Set($$[$0-2].Text != $$[$0].Text); - this.$ = $$[$0-2]; - */ - -break; -case 14: - //js - this.$ = yy.handler.callFunction.apply(yy.obj, ['GREATER', [$$[$0-2], $$[$0]]]); - - //php this.$ = ($$[$0-2] * 1) > ($$[$0] * 1); - - /*cs - $$[$0-2].Set($$[$0-2].ToDouble() > $$[$0].ToDouble()); - this.$ = $$[$0-2]; - */ - -break; -case 15: - //js - this.$ = yy.handler.callFunction.apply(yy.obj, ['LESS', [$$[$0-2], $$[$0]]]); - - //php this.$ = ($$[$0-2] * 1) < ($$[$0] * 1); - - /*cs - $$[$0-2].Set($$[$0-2].ToDouble() < $$[$0].ToDouble()); - this.$ = $$[$0-2]; - */ - -break; -case 16: - //js|php - this.$ = ($$[$0-2] * 1) - ($$[$0] * 1); - - //js - this.$ = yy.handler.performMath.apply(yy.obj, ['-', $$[$0-2], $$[$0]]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - /*cs - $$[$0-2].Set($$[$0-2].ToDouble() - $$[$0].ToDouble()); - this.$ = $$[$0-2]; - */ - -break; -case 17: - //js - this.$ = yy.handler.performMath.apply(yy.obj, ['*', $$[$0-2], $$[$0]]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - //php this.$ = ($$[$0-2] * 1) * ($$[$0] * 1); - - /*cs - $$[$0-2].Set($$[$0-2].ToDouble() * $$[$0].ToDouble()); - this.$ = $$[$0-2]; - */ - -break; -case 18: - //js - this.$ = yy.handler.performMath.apply(yy.obj, ['/', $$[$0-2], $$[$0]]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - //php this.$ = ($$[$0-2] * 1) / ($$[$0] * 1); - - /*cs - $$[$0-2].Set($$[$0-2].ToDouble() / $$[$0].ToDouble()); - this.$ = $$[$0-2]; - */ - -break; -case 19: - //js - var n1 = yy.handler.number.apply(yy.obj, [$$[$0-2]]), - n2 = yy.handler.number.apply(yy.obj, [$$[$0]]); - - this.$ = yy.handler.performMath.apply(yy.obj, ['^', $$[$0-2], $$[$0]]); - yy.obj.html.pop(); - yy.obj.html.pop(); - yy.obj.html.push(null); - - //php this.$ = pow(($$[$0-2] * 1), ($$[$0] * 1)); - - /*cs - $$[$0-2].Set(Math.Pow($$[$0-2].ToDouble(), $$[$0].ToDouble())); - this.$ = $$[$0-2]; - */ - -break; -case 20: - //js - var n1 = yy.handler.number.apply(yy.obj, [$$[$0]]); - this.$ = n1 * -1; - if (isNaN(this.$)) this.$ = 0; - - //php this.$ = $$[$0-1] * 1; - - /*cs - $$[$0].Set(-$$[$0].ToDouble()); - this.$ = $$[$0]; - */ - -break; -case 21: - //js - var n1 = yy.handler.number.apply(yy.obj, [$$[$0]]); - this.$ = n1 * 1; - if (isNaN(this.$)) this.$ = 0; - - //php this.$ = $$[$0-1] * 1; - - /*cs - $$[$0].Set($$[$0].ToDouble()); - this.$ = $$[$0]; - */ - -break; -case 22:/*this.$ = Math.E;*/; -break; -case 23: - //js - this.$ = yy.handler.callFunction.apply(yy.obj, [$$[$0-2], '']); - - //php this.$ = this->callFunction($$[$0-2]); - - /*cs - this.$ = Functions.Call($$[$0-2].Text); - */ - -break; -case 24: - //js - this.$ = yy.handler.callFunction.apply(yy.obj, [$$[$0-3], $$[$0-1]]); - - //php this.$ = this->callFunction($$[$0-3], $$[$0-1]); - - /*cs - this.$ = Functions.Call($$[$0-3].Text, $$[$0-1]); - */ - -break; -case 28: - //js - this.$ = yy.handler.fixedCellValue.apply(yy.obj, [$$[$0]]); - - //php this.$ = this->fixedCellValue($$[$0]); - - /*cs - this.$ = Spreadsheet.CellValue(Location.ParseFixed($$[$0].Text)); - */ - -break; -case 29: - //js - this.$ = yy.handler.fixedCellRangeValue.apply(yy.obj, [$$[$0-2], $$[$0]]); - - //php this.$ = this->fixedCellRangeValue($$[$0-2], $$[$0]); - - /*cs - this.$ = Spreadsheet.CellValue(Location.ParseFixed($$[$0-2].Text), Location.ParseFixed($$[$0].Text)); - */ - -break; -case 30: - //js - this.$ = yy.handler.cellValue.apply(yy.obj, [$$[$0]]); - - //php this.$ = this->cellValue($$[$0]); - - /*cs - this.$ = Spreadsheet.CellValue(Location.Parse($$[$0].Text)); - */ - -break; -case 31: - //js - this.$ = yy.handler.cellRangeValue.apply(yy.obj, [$$[$0-2], $$[$0]]); - - //php this.$ = this->cellRangeValue($$[$0-2], $$[$0]); - - /*cs - this.$ = Spreadsheet.CellValue(Location.Parse($$[$0-2].Text), Location.Parse($$[$0].Text)); - */ - -break; -case 32: - //js - this.$ = yy.handler.remoteCellValue.apply(yy.obj, [$$[$0-2], $$[$0]]); - - //php this.$ = this->remoteCellValue($$[$0-2], $$[$0]); - - /*cs - this.$ = Spreadsheet.CellValue(Location.ParseRemote($$[$0-2].Text, $$[$0].Text)); - */ - -break; -case 33: - //js - this.$ = yy.handler.remoteCellRangeValue.apply(yy.obj, [$$[$0-4], $$[$0-2], $$[$0]]); - - //php this.$ = this->remoteCellRangeValue($$[$0-4], $$[$0-2], $$[$0]); - - /*cs - this.$ = Spreadsheet.CellValue(Location.ParseRemote($$[$0-4].Text, $$[$0-2].Text), Location.ParseRemote($$[$0-4].Text, $$[$0].Text)); - */ - -break; -case 34: - //js - this.$ = [$$[$0]]; - - //php this.$ = array($$[$0]); - - /*cs - this.$ = $$[$0]; - */ - -break; -case 35: - //js - $$[$0-2].push($$[$0]); - this.$ = $$[$0-2]; - - /*php - $$[$0-2][] = $$[$0]; - this.$ = $$[$0-2]; - */ - - /*cs - $$[$0-2].Push($$[$0]); - this.$ = $$[$0-2]; - */ - -break; -case 36: - //js - $$[$0-2].push($$[$0]); - this.$ = $$[$0-2]; - - /*php - $$[$0-2][] = $$[$0]; - this.$ = $$[$0-2]; - */ - - /*cs - $$[$0-2].Push($$[$0]); - this.$ = $$[$0-2]; - */ - -break; -case 37: - //js - this.$ = [$$[$0]]; - - //php this.$ = array($$[$0]); - - /*cs - this.$ = $$[$0]; - */ - -break; -case 38: - //js - this.$ = ($.isArray($$[$0-2]) ? $$[$0-2] : [$$[$0-2]]); - this.$.push($$[$0]); - - /*php - this.$ = (is_array($$[$0-2]) ? $$[$0-2] : array()); - this.$[] = $$[$0]; - */ - - /*cs - $$[$0-2].Push($$[$0]); - this.$ = $$[$0-2]; - */ - -break; -case 39: - //js|php - this.$ = $$[$0] * 1; - - /*cs - $$[$0].ToDouble(); - this.$ = $$[$0]; - */ - -break; -case 40: - //js - this.$ =($$[$0-2] + '.' + $$[$0]) * 1; - - //php this.$ = $$[$0-2] . '.' . $$[$0]; - - /*cs - $$[$0-2].Text += "." + $$[$0].Text; - $$[$0-2].ToDouble(); - this.$ = $$[$0-2]; - */ - -break; -case 41: - //js - yy.obj.html.push($$[$0-1] + $$[$0]); - - //js|php - this.$ = $$[$0-1] * 0.01; - - /*cs - $$[$0-1].Set($$[$0-1].ToDouble() * 0.01); - this.$ = $$[$0-1]; - */ - -break; -case 42: - //js - this.$ = $$[$0-2] + $$[$0-1] + $$[$0]; - - //php this.$ = $$[$0-2] . $$[$0-1] . $$[$0]; - - /*cs - $$[$0-2].Set($$[$0-2].Text + $$[$0-1].Text + $$[$0].Text); - this.$ = $$[$0-2]; - */ - -break; -case 43: - //js - this.$ = $$[$0-2] + $$[$0-1] + $$[$0]; - - //php this.$ = $$[$0-2] . $$[$0-1] . $$[$0]; - - /*cs - $$[$0-3].Set($$[$0-3].Text + $$[$0-2].Text + $$[$0-1].Text + $$[$0].Text); - this.$ = $$[$0-3]; - */ - -break; -} -}, -table: [{2:14,3:1,4:2,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{1:[3]},{5:[1,21],11:[1,22],12:[1,23],15:[1,24],16:[1,25],17:[1,26],18:[1,27],19:[1,28],20:[1,29],21:[1,30]},{5:[2,2],11:[2,2],12:[2,2],14:[2,2],15:[2,2],16:[2,2],17:[2,2],18:[2,2],19:[2,2],20:[2,2],21:[2,2],31:[2,2],32:[2,2],34:[1,31]},{5:[2,3],11:[2,3],12:[2,3],14:[2,3],15:[2,3],16:[2,3],17:[2,3],18:[2,3],19:[2,3],20:[2,3],21:[2,3],31:[2,3],32:[2,3]},{5:[2,4],11:[2,4],12:[2,4],14:[2,4],15:[2,4],16:[2,4],17:[2,4],18:[2,4],19:[2,4],20:[2,4],21:[2,4],31:[2,4],32:[2,4]},{5:[2,5],11:[2,5],12:[2,5],14:[2,5],15:[2,5],16:[2,5],17:[2,5],18:[2,5],19:[2,5],20:[2,5],21:[2,5],31:[2,5],32:[2,5],36:[1,32]},{5:[2,6],11:[2,6],12:[2,6],14:[2,6],15:[2,6],16:[2,6],17:[2,6],18:[2,6],19:[2,6],20:[2,6],21:[2,6],31:[2,6],32:[2,6]},{2:14,4:33,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:34,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:35,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{5:[2,22],11:[2,22],12:[2,22],14:[2,22],15:[2,22],16:[2,22],17:[2,22],18:[2,22],19:[2,22],20:[2,22],21:[2,22],31:[2,22],32:[2,22]},{13:[1,36]},{5:[2,25],11:[2,25],12:[2,25],14:[2,25],15:[2,25],16:[2,25],17:[2,25],18:[2,25],19:[2,25],20:[2,25],21:[2,25],31:[2,25],32:[2,25]},{2:37,5:[2,26],11:[2,26],12:[2,26],14:[2,26],15:[2,26],16:[2,26],17:[2,26],18:[2,26],19:[2,26],20:[2,26],21:[2,26],31:[2,26],32:[2,26],33:[1,38],37:[1,20]},{5:[2,37],11:[2,37],12:[2,37],14:[2,37],15:[2,37],16:[2,37],17:[2,37],18:[2,37],19:[2,37],20:[2,37],21:[2,37],31:[2,37],32:[2,37],34:[2,37],37:[1,39]},{5:[2,39],11:[2,39],12:[2,39],14:[2,39],15:[2,39],16:[2,39],17:[2,39],18:[2,39],19:[2,39],20:[2,39],21:[2,39],31:[2,39],32:[2,39],34:[1,40],36:[2,39]},{5:[2,28],11:[2,28],12:[2,28],14:[2,28],15:[2,28],16:[2,28],17:[2,28],18:[2,28],19:[2,28],20:[2,28],21:[2,28],27:[1,41],31:[2,28],32:[2,28]},{5:[2,30],11:[2,30],12:[2,30],14:[2,30],15:[2,30],16:[2,30],17:[2,30],18:[2,30],19:[2,30],20:[2,30],21:[2,30],27:[1,42],31:[2,30],32:[2,30]},{30:[1,43]},{33:[1,44]},{1:[2,1]},{2:14,4:45,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:46,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:49,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],11:[1,47],12:[1,10],13:[1,8],16:[1,48],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:51,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],11:[1,50],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:52,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:53,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:54,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:55,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:56,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{33:[1,57]},{5:[2,41],11:[2,41],12:[2,41],14:[2,41],15:[2,41],16:[2,41],17:[2,41],18:[2,41],19:[2,41],20:[2,41],21:[2,41],31:[2,41],32:[2,41],36:[2,41]},{11:[1,22],12:[1,23],14:[1,58],15:[1,24],16:[1,25],17:[1,26],18:[1,27],19:[1,28],20:[1,29],21:[1,30]},{5:[2,20],11:[2,20],12:[2,20],14:[2,20],15:[2,20],16:[2,20],17:[2,20],18:[2,20],19:[1,28],20:[1,29],21:[1,30],31:[2,20],32:[2,20]},{5:[2,21],11:[2,21],12:[2,21],14:[2,21],15:[2,21],16:[2,21],17:[2,21],18:[2,21],19:[1,28],20:[1,29],21:[1,30],31:[2,21],32:[2,21]},{2:14,4:61,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],14:[1,59],18:[1,9],22:[1,11],23:[1,12],24:60,25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{5:[2,27],11:[2,27],12:[2,27],14:[2,27],15:[2,27],16:[2,27],17:[2,27],18:[2,27],19:[2,27],20:[2,27],21:[2,27],31:[2,27],32:[2,27]},{37:[1,39]},{33:[1,62]},{35:[1,63]},{26:[1,64]},{28:[1,65]},{28:[1,66]},{30:[1,67]},{5:[2,7],11:[2,7],12:[1,23],14:[2,7],15:[1,24],16:[1,25],17:[1,26],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,7],32:[2,7]},{5:[2,8],11:[2,8],12:[2,8],14:[2,8],15:[2,8],16:[2,8],17:[2,8],18:[2,8],19:[1,28],20:[1,29],21:[1,30],31:[2,8],32:[2,8]},{2:14,4:68,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:69,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{5:[2,15],11:[2,15],12:[1,23],14:[2,15],15:[2,15],16:[2,15],17:[2,15],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,15],32:[2,15]},{2:14,4:70,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{5:[2,14],11:[2,14],12:[1,23],14:[2,14],15:[2,14],16:[2,14],17:[2,14],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,14],32:[2,14]},{5:[2,13],11:[2,13],12:[1,23],14:[2,13],15:[1,24],16:[1,25],17:[2,13],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,13],32:[2,13]},{5:[2,16],11:[2,16],12:[2,16],14:[2,16],15:[2,16],16:[2,16],17:[2,16],18:[2,16],19:[1,28],20:[1,29],21:[1,30],31:[2,16],32:[2,16]},{5:[2,17],11:[2,17],12:[2,17],14:[2,17],15:[2,17],16:[2,17],17:[2,17],18:[2,17],19:[2,17],20:[2,17],21:[1,30],31:[2,17],32:[2,17]},{5:[2,18],11:[2,18],12:[2,18],14:[2,18],15:[2,18],16:[2,18],17:[2,18],18:[2,18],19:[2,18],20:[2,18],21:[1,30],31:[2,18],32:[2,18]},{5:[2,19],11:[2,19],12:[2,19],14:[2,19],15:[2,19],16:[2,19],17:[2,19],18:[2,19],19:[2,19],20:[2,19],21:[2,19],31:[2,19],32:[2,19]},{5:[2,38],11:[2,38],12:[2,38],14:[2,38],15:[2,38],16:[2,38],17:[2,38],18:[2,38],19:[2,38],20:[2,38],21:[2,38],31:[2,38],32:[2,38],34:[2,38]},{5:[2,9],11:[2,9],12:[2,9],14:[2,9],15:[2,9],16:[2,9],17:[2,9],18:[2,9],19:[2,9],20:[2,9],21:[2,9],31:[2,9],32:[2,9]},{5:[2,23],11:[2,23],12:[2,23],14:[2,23],15:[2,23],16:[2,23],17:[2,23],18:[2,23],19:[2,23],20:[2,23],21:[2,23],31:[2,23],32:[2,23]},{14:[1,71],31:[1,72],32:[1,73]},{11:[1,22],12:[1,23],14:[2,34],15:[1,24],16:[1,25],17:[1,26],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,34],32:[2,34]},{30:[1,74]},{5:[2,40],11:[2,40],12:[2,40],14:[2,40],15:[2,40],16:[2,40],17:[2,40],18:[2,40],19:[2,40],20:[2,40],21:[2,40],31:[2,40],32:[2,40],36:[2,40]},{5:[2,29],11:[2,29],12:[2,29],14:[2,29],15:[2,29],16:[2,29],17:[2,29],18:[2,29],19:[2,29],20:[2,29],21:[2,29],31:[2,29],32:[2,29]},{5:[2,31],11:[2,31],12:[2,31],14:[2,31],15:[2,31],16:[2,31],17:[2,31],18:[2,31],19:[2,31],20:[2,31],21:[2,31],31:[2,31],32:[2,31]},{5:[2,32],11:[2,32],12:[2,32],14:[2,32],15:[2,32],16:[2,32],17:[2,32],18:[2,32],19:[2,32],20:[2,32],21:[2,32],27:[1,75],31:[2,32],32:[2,32]},{5:[2,42],11:[2,42],12:[2,42],14:[2,42],15:[2,42],16:[2,42],17:[2,42],18:[2,42],19:[2,42],20:[2,42],21:[2,42],31:[2,42],32:[2,42],33:[2,42],37:[2,42]},{5:[2,10],11:[2,10],12:[1,23],14:[2,10],15:[2,10],16:[2,10],17:[2,10],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,10],32:[2,10]},{5:[2,12],11:[2,12],12:[1,23],14:[2,12],15:[2,12],16:[2,12],17:[2,12],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,12],32:[2,12]},{5:[2,11],11:[2,11],12:[1,23],14:[2,11],15:[2,11],16:[2,11],17:[2,11],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,11],32:[2,11]},{5:[2,24],11:[2,24],12:[2,24],14:[2,24],15:[2,24],16:[2,24],17:[2,24],18:[2,24],19:[2,24],20:[2,24],21:[2,24],31:[2,24],32:[2,24]},{2:14,4:76,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{2:14,4:77,6:3,7:[1,4],8:[1,5],9:6,10:[1,7],12:[1,10],13:[1,8],18:[1,9],22:[1,11],23:[1,12],25:13,26:[1,17],28:[1,18],29:[1,19],33:[1,15],35:[1,16],37:[1,20]},{5:[2,43],11:[2,43],12:[2,43],14:[2,43],15:[2,43],16:[2,43],17:[2,43],18:[2,43],19:[2,43],20:[2,43],21:[2,43],31:[2,43],32:[2,43],33:[2,43],37:[2,43]},{28:[1,78]},{11:[1,22],12:[1,23],14:[2,35],15:[1,24],16:[1,25],17:[1,26],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,35],32:[2,35]},{11:[1,22],12:[1,23],14:[2,36],15:[1,24],16:[1,25],17:[1,26],18:[1,27],19:[1,28],20:[1,29],21:[1,30],31:[2,36],32:[2,36]},{5:[2,33],11:[2,33],12:[2,33],14:[2,33],15:[2,33],16:[2,33],17:[2,33],18:[2,33],19:[2,33],20:[2,33],21:[2,33],31:[2,33],32:[2,33]}], -defaultActions: {21:[2,1]}, -parseError: function parseError(str, hash) { - if (hash.recoverable) { - this.trace(str); - } else { - throw new Error(str); - } -}, -parse: function parse(input) { - var self = this, - stack = [0], - vstack = [null], // semantic value stack - lstack = [], // location stack - table = this.table, - yytext = '', - yylineno = 0, - yyleng = 0, - recovering = 0, - TERROR = 2, - EOF = 1; - - //this.reductionCount = this.shiftCount = 0; - - this.lexer.setInput(input); - this.lexer.yy = this.yy; - this.yy.lexer = this.lexer; - this.yy.parser = this; - if (typeof this.lexer.yylloc == 'undefined') { - this.lexer.yylloc = {}; - } - var yyloc = this.lexer.yylloc; - lstack.push(yyloc); - - var ranges = this.lexer.options && this.lexer.options.ranges; - - if (typeof this.yy.parseError === 'function') { - this.parseError = this.yy.parseError; - } else { - this.parseError = Object.getPrototypeOf(this).parseError; // because in the generated code 'this.__proto__.parseError' doesn't work for everyone: http://javascriptweblog.wordpress.com/2010/06/07/understanding-javascript-prototypes/ - } - - function popStack (n) { - stack.length = stack.length - 2 * n; - vstack.length = vstack.length - n; - lstack.length = lstack.length - n; - } - - function lex() { - var token; - token = self.lexer.lex() || EOF; // $end = 1 - // if token isn't its numeric value, convert - if (typeof token !== 'number') { - token = self.symbols_[token] || token; - } - return token; - } - - var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; - while (true) { - // retreive state number from top of stack - state = stack[stack.length - 1]; - - // use default actions if available - if (this.defaultActions[state]) { - action = this.defaultActions[state]; - } else { - if (symbol === null || typeof symbol == 'undefined') { - symbol = lex(); - } - // read action for current state and first input - action = table[state] && table[state][symbol]; - } - -_handle_error: - // handle parse error - if (typeof action === 'undefined' || !action.length || !action[0]) { - var error_rule_depth; - var errStr = ''; - - // Return the rule stack depth where the nearest error rule can be found. - // Return FALSE when no error recovery rule was found. - function locateNearestErrorRecoveryRule(state) { - var stack_probe = stack.length - 1; - var depth = 0; - - // try to recover from error - for(;;) { - // check for error recovery rule in this state - if ((TERROR.toString()) in table[state]) { - return depth; - } - if (state === 0 || stack_probe < 2) { - return false; // No suitable error recovery rule available. - } - stack_probe -= 2; // popStack(1): [symbol, action] - state = stack[stack_probe]; - ++depth; - } - } - - if (!recovering) { - // first see if there's any chance at hitting an error recovery rule: - error_rule_depth = locateNearestErrorRecoveryRule(state); - - // Report error - expected = []; - for (p in table[state]) { - if (this.terminals_[p] && p > TERROR) { - expected.push("'"+this.terminals_[p]+"'"); - } - } - if (this.lexer.showPosition) { - errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + (this.terminals_[symbol] || symbol)+ "'"; - } else { - errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " + - (symbol == EOF ? "end of input" : - ("'"+(this.terminals_[symbol] || symbol)+"'")); - } - this.parseError(errStr, { - text: this.lexer.match, - token: this.terminals_[symbol] || symbol, - line: this.lexer.yylineno, - loc: yyloc, - expected: expected, - recoverable: (error_rule_depth !== false) - }); - } else if (preErrorSymbol !== EOF) { - error_rule_depth = locateNearestErrorRecoveryRule(state); - } - - // just recovered from another error - if (recovering == 3) { - if (symbol === EOF || preErrorSymbol === EOF) { - throw new Error(errStr || 'Parsing halted while starting to recover from another error.'); - } - - // discard current lookahead and grab another - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - yyloc = this.lexer.yylloc; - symbol = lex(); - } - - // try to recover from error - if (error_rule_depth === false) { - throw new Error(errStr || 'Parsing halted. No suitable error recovery rule available.'); - } - popStack(error_rule_depth); - - preErrorSymbol = (symbol == TERROR ? null : symbol); // save the lookahead token - symbol = TERROR; // insert generic error symbol as new lookahead - state = stack[stack.length-1]; - action = table[state] && table[state][TERROR]; - recovering = 3; // allow 3 real symbols to be shifted before reporting a new error - } - - // this shouldn't happen, unless resolve defaults are off - if (action[0] instanceof Array && action.length > 1) { - throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol); - } - - switch (action[0]) { - case 1: // shift - //this.shiftCount++; - - stack.push(symbol); - vstack.push(this.lexer.yytext); - lstack.push(this.lexer.yylloc); - stack.push(action[1]); // push state - symbol = null; - if (!preErrorSymbol) { // normal execution/no error - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - yyloc = this.lexer.yylloc; - if (recovering > 0) { - recovering--; - } - } else { - // error just occurred, resume old lookahead f/ before error - symbol = preErrorSymbol; - preErrorSymbol = null; - } - break; - - case 2: - // reduce - //this.reductionCount++; - - len = this.productions_[action[1]][1]; - - // perform semantic action - yyval.$ = vstack[vstack.length-len]; // default to $$ = $1 - // default location, uses first token for firsts, last for lasts - yyval._$ = { - first_line: lstack[lstack.length-(len||1)].first_line, - last_line: lstack[lstack.length-1].last_line, - first_column: lstack[lstack.length-(len||1)].first_column, - last_column: lstack[lstack.length-1].last_column - }; - if (ranges) { - yyval._$.range = [lstack[lstack.length-(len||1)].range[0], lstack[lstack.length-1].range[1]]; - } - r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); - - if (typeof r !== 'undefined') { - return r; - } - - // pop off stack - if (len) { - stack = stack.slice(0,-1*len*2); - vstack = vstack.slice(0, -1*len); - lstack = lstack.slice(0, -1*len); - } - - stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce) - vstack.push(yyval.$); - lstack.push(yyval._$); - // goto new state = table[STATE][NONTERMINAL] - newState = table[stack[stack.length-2]][stack[stack.length-1]]; - stack.push(newState); - break; - - case 3: - // accept - return true; - } - - } - - return true; -}}; - -if (typeof(window) !== 'undefined') { - window.Formula = function(handler) { - var formulaLexer = function () {}; - formulaLexer.prototype = formula.lexer; - - var formulaParser = function () { - this.lexer = new formulaLexer(); - this.yy = {}; - }; - - formulaParser.prototype = formula; - var newParser = new formulaParser; - newParser.setObj = function(obj) { - newParser.yy.obj = obj; - }; - newParser.yy.handler = handler; - return newParser; - }; -}/* generated by jison-lex 0.2.1 */ -var lexer = (function(){ -var lexer = { - -EOF:1, - -parseError:function parseError(str, hash) { - if (this.yy.parser) { - this.yy.parser.parseError(str, hash); - } else { - throw new Error(str); - } - }, - -// resets the lexer, sets new input -setInput:function (input) { - this._input = input; - this._more = this._backtrack = this.done = false; - this.yylineno = this.yyleng = 0; - this.yytext = this.matched = this.match = ''; - this.conditionStack = ['INITIAL']; - this.yylloc = { - first_line: 1, - first_column: 0, - last_line: 1, - last_column: 0 - }; - if (this.options.ranges) { - this.yylloc.range = [0,0]; - } - this.offset = 0; - return this; - }, - -// consumes and returns one char from the input -input:function () { - var ch = this._input[0]; - this.yytext += ch; - this.yyleng++; - this.offset++; - this.match += ch; - this.matched += ch; - var lines = ch.match(/(?:\r\n?|\n).*/g); - if (lines) { - this.yylineno++; - this.yylloc.last_line++; - } else { - this.yylloc.last_column++; - } - if (this.options.ranges) { - this.yylloc.range[1]++; - } - - this._input = this._input.slice(1); - return ch; - }, - -// unshifts one char (or a string) into the input -unput:function (ch) { - var len = ch.length; - var lines = ch.split(/(?:\r\n?|\n)/g); - - this._input = ch + this._input; - this.yytext = this.yytext.substr(0, this.yytext.length - len - 1); - //this.yyleng -= len; - this.offset -= len; - var oldLines = this.match.split(/(?:\r\n?|\n)/g); - this.match = this.match.substr(0, this.match.length - 1); - this.matched = this.matched.substr(0, this.matched.length - 1); - - if (lines.length - 1) { - this.yylineno -= lines.length - 1; - } - var r = this.yylloc.range; - - this.yylloc = { - first_line: this.yylloc.first_line, - last_line: this.yylineno + 1, - first_column: this.yylloc.first_column, - last_column: lines ? - (lines.length === oldLines.length ? this.yylloc.first_column : 0) - + oldLines[oldLines.length - lines.length].length - lines[0].length : - this.yylloc.first_column - len - }; - - if (this.options.ranges) { - this.yylloc.range = [r[0], r[0] + this.yyleng - len]; - } - this.yyleng = this.yytext.length; - return this; - }, - -// When called from action, caches matched text and appends it on next action -more:function () { - this._more = true; - return this; - }, - -// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. -reject:function () { - if (this.options.backtrack_lexer) { - this._backtrack = true; - } else { - return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { - text: "", - token: null, - line: this.yylineno - }); - - } - return this; - }, - -// retain first n characters of the match -less:function (n) { - this.unput(this.match.slice(n)); - }, - -// displays already matched input, i.e. for error messages -pastInput:function () { - var past = this.matched.substr(0, this.matched.length - this.match.length); - return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); - }, - -// displays upcoming input, i.e. for error messages -upcomingInput:function () { - var next = this.match; - if (next.length < 20) { - next += this._input.substr(0, 20-next.length); - } - return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); - }, - -// displays the character position where the lexing error occurred, i.e. for error messages -showPosition:function () { - var pre = this.pastInput(); - var c = new Array(pre.length + 1).join("-"); - return pre + this.upcomingInput() + "\n" + c + "^"; - }, - -// test the lexed token: return FALSE when not a match, otherwise return token -test_match:function (match, indexed_rule) { - var token, - lines, - backup; - - if (this.options.backtrack_lexer) { - // save context - backup = { - yylineno: this.yylineno, - yylloc: { - first_line: this.yylloc.first_line, - last_line: this.last_line, - first_column: this.yylloc.first_column, - last_column: this.yylloc.last_column - }, - yytext: this.yytext, - match: this.match, - matches: this.matches, - matched: this.matched, - yyleng: this.yyleng, - offset: this.offset, - _more: this._more, - _input: this._input, - yy: this.yy, - conditionStack: this.conditionStack.slice(0), - done: this.done - }; - if (this.options.ranges) { - backup.yylloc.range = this.yylloc.range.slice(0); - } - } - - lines = match[0].match(/(?:\r\n?|\n).*/g); - if (lines) { - this.yylineno += lines.length; - } - this.yylloc = { - first_line: this.yylloc.last_line, - last_line: this.yylineno + 1, - first_column: this.yylloc.last_column, - last_column: lines ? - lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : - this.yylloc.last_column + match[0].length - }; - this.yytext += match[0]; - this.match += match[0]; - this.matches = match; - this.yyleng = this.yytext.length; - if (this.options.ranges) { - this.yylloc.range = [this.offset, this.offset += this.yyleng]; - } - this._more = false; - this._backtrack = false; - this._input = this._input.slice(match[0].length); - this.matched += match[0]; - token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); - if (this.done && this._input) { - this.done = false; - } - if (token) { - return token; - } else if (this._backtrack) { - // recover context - for (var k in backup) { - this[k] = backup[k]; - } - return false; // rule action called reject() implying the next rule should be tested instead. - } - return false; - }, - -// return next match in input -next:function () { - if (this.done) { - return this.EOF; - } - if (!this._input) { - this.done = true; - } - - var token, - match, - tempMatch, - index; - if (!this._more) { - this.yytext = ''; - this.match = ''; - } - var rules = this._currentRules(); - for (var i = 0; i < rules.length; i++) { - tempMatch = this._input.match(this.rules[rules[i]]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rules[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = false; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; - } - } else if (!this.options.flex) { - break; - } - } - } - if (match) { - token = this.test_match(match, rules[index]); - if (token !== false) { - return token; - } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; - } - if (this._input === "") { - return this.EOF; - } else { - return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { - text: "", - token: null, - line: this.yylineno - }); - } - }, - -// return next match that has a token -lex:function lex() { - var r = this.next(); - if (r) { - return r; - } else { - return this.lex(); - } - }, - -// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) -begin:function begin(condition) { - this.conditionStack.push(condition); - }, - -// pop the previously active lexer condition state off the condition stack -popState:function popState() { - var n = this.conditionStack.length - 1; - if (n > 0) { - return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; - } - }, - -// produce the lexer rule set which is active for the currently active lexer condition state -_currentRules:function _currentRules() { - if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { - return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; - } else { - return this.conditions["INITIAL"].rules; - } - }, - -// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available -topState:function topState(n) { - n = this.conditionStack.length - 1 - Math.abs(n || 0); - if (n >= 0) { - return this.conditionStack[n]; - } else { - return "INITIAL"; - } - }, - -// alias for begin(condition) -pushState:function pushState(condition) { - this.begin(condition); - }, - -// return the number of states currently on the stack -stateStackSize:function stateStackSize() { - return this.conditionStack.length; - }, -options: {}, -performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { - -var YYSTATE=YY_START; -switch($avoiding_name_collisions) { -case 0:/* skip whitespace */ -break; -case 1:return 10; -break; -case 2:return 10; -break; -case 3:return 23; -break; -case 4:return 7; -break; -case 5:return 8; -break; -case 6: - //js - if (yy.obj.type == 'cell') return 29; - return 33; - - /*php - if ($this->type == 'cell') return 29; - return 33; - */ - - /*cs - return 29; - //return 33; - */ - -break; -case 7: - //js - if (yy.obj.type == 'cell') return 26; - return 33; - - /*php - if ($this->type == 'cell') return 26; - return 33; - */ - - /*cs - return 26; - //return 33; - */ - -break; -case 8: - //js - if (yy.obj.type == 'cell') return 28; - return 33; - - /*php - if ($this->type == 'cell') return 28; - return 33; - */ - - /*cs - return 28; - //return 33; - */ - -break; -case 9:return 23; -break; -case 10:return 33; -break; -case 11:return 33; -break; -case 12:return 35; -break; -case 13:/* skip whitespace */ -break; -case 14:return 34; -break; -case 15:return 27; -break; -case 16:return 31; -break; -case 17:return 32; -break; -case 18:return 19; -break; -case 19:return 20; -break; -case 20:return 18; -break; -case 21:return 12; -break; -case 22:return 21; -break; -case 23:return 13; -break; -case 24:return 14; -break; -case 25:return 16; -break; -case 26:return 15; -break; -case 27:return 17; -break; -case 28:return 22; -break; -case 29:return '"'; -break; -case 30:return "'"; -break; -case 31:return "!"; -break; -case 32:return 11; -break; -case 33:return 36; -break; -case 34:return 37; -break; -case 35:return 5; -break; -} -}, -rules: [/^(?:\s+)/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9]+(?=[(]))/,/^(?:([0]?[1-9]|1[0-2])[:][0-5][0-9]([:][0-5][0-9])?[ ]?(AM|am|aM|Am|PM|pm|pM|Pm))/,/^(?:([0]?[0-9]|1[0-9]|2[0-3])[:][0-5][0-9]([:][0-5][0-9])?)/,/^(?:SHEET[0-9]+)/,/^(?:\$[A-Za-z]+\$[0-9]+)/,/^(?:[A-Za-z]+[0-9]+)/,/^(?:[A-Za-z]+(?=[(]))/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)/,/^(?:[A-Za-z_]+)/,/^(?:[0-9]+)/,/^(?:\\s)/,/^(?:[.])/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:\*)/,/^(?:\/)/,/^(?:-)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\))/,/^(?:>)/,/^(?:<)/,/^(?:NOT\b)/,/^(?:E\b)/,/^(?:")/,/^(?:')/,/^(?:!)/,/^(?:=)/,/^(?:%)/,/^(?:[#])/,/^(?:$)/], -conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],"inclusive":true}} -}; -return lexer; -})(); -parser.lexer = lexer; -function Parser () { - this.yy = {}; -} -Parser.prototype = parser;parser.Parser = Parser; -return new Parser; -})(); - - -if (typeof require !== 'undefined' && typeof exports !== 'undefined') { -exports.parser = formula; -exports.Parser = formula.Parser; -exports.parse = function () { return formula.parse.apply(formula, arguments); }; -exports.main = function commonjsMain(args) { - if (!args[1]) { - console.log('Usage: '+args[0]+' FILE'); - process.exit(1); - } - var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - return exports.parser.parse(source); -}; -if (typeof module !== 'undefined' && require.main === module) { - exports.main(process.argv.slice(1)); -} -} \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/bin/Debug/Jison.exe b/ports/csharp/Jison/Jison/bin/Debug/Jison.exe deleted file mode 100755 index 2d64ad580d4c6809d2d4367893213e0f71737619..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49664 zcmeHw3w#{KnP*MUsOO=F)jiUTY{{OnEn``>h5VL`-;(@7wq?sUHa6I@G`0njM)XL= zM#yn^B!N6OgoHp6vOpl4CwY+vEFsyD5RxM~!tQOdx7l5i%|31~x$JJ(T(ZZ){lBle zd-@wIU~<_Xw|5@9s=x1FRbSQjRn=G3)vcKwSH4q)l~NIemtR)uOSsZ!1IMo%okMa} z=CLaENc=mqzZB~J&g{J>2MgIzCx61}8_xFkjf~{Svd3~+XM7|(IFjw$)tep859C@Z zD-(^b=$G*W4Y5~;Mb7Bk;b}0 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in/Debug/Jison.exe.config deleted file mode 100644 index 8e1564635..000000000 --- a/ports/csharp/Jison/Jison/bin/Debug/Jison.exe.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/bin/Debug/Jison.pdb b/ports/csharp/Jison/Jison/bin/Debug/Jison.pdb deleted file mode 100644 index 3c2fef7fb05d4b8d7d8d0176a7306d3bc2b3e5e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 87552 zcmeI534m2)*~iaihG9omMFbr7)nOQh&6Q=?6a)bkbxektVbOuXSrp9Ws%W^QVrpVy zVOnY*7M5FPiH7B#sg2h zk6U|Wr`O|?PxplXmKMnE@#;VSTk5)}p7mRx-A_j)#>)Y8as&(tKK)cqAuGwBJ>hfR z0&)5uyhs0^Yn?|c_rc<$4tuoK&pWT5A3QYY>n(2HHuZ?>-}u9`o!1{`kK5gN;qjf9 z{JirIh6TX~t!MsV(Kl93e5&lcS>M|+`MGneZoOV^L*cEn_igj+BW-7W^vG>3X5Vp6 z`3xM$i_9IjvPMmvHX+W*p2Ej!5g`ESeaOXpk zv~D7uO^~LmBp>8JS3y@p8=z~TFGJTt*Fo1qUx99bHbSi+)r%qoU7(&&Yp5ecbpnbQ zbcMP>J)r%dUQlnS541m&3-yKiLH(ft&_HMqG#DBJQT>2s4TeJ_paY;hXe5*mje-iG z(NG~Y1{w>EgXFU(KnFqxK?g&JK!-wyK@*`#&}3)|R0K_hra{x88PH59uK%mm)oxiy z{t$E=hlaW5&wq3a?9u;!wEA|t@Sm0cUxyEu|6ha?-5LMC2?s0xUxNdd-`Sb43g3St zE%H?;>igGod?nPBF(BRd?@PRvkbHkTs6Esj+8g>$_x*=chvw3M-W~T=9CYjAJHOTc z)DBZu{o@NIq`ep_h036EXbH3wS_UnLPKHi_Dxek6N~jWA1)U02LDf(VR12L3oer&r z)<9=KUxdzt&VtT{&ViE9xzKsg`OsSEOVEYT1<*R^BIsi166jLsGU#&X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vkf_e5`(^mVdz9VW=D4-?;=X0gbcGPzODZ3d;?A_uKikyKRGaQ6 z&r{J%DRp2ayE4j_eOakt-0u}}xH`qc$!tNhOrD5|-`aPa^FrIL*1TzQ_!9DL=hd>3 zftcA6`2GjZA{i$)ijiMNsUGXz(Kzpgfz|2#LyuV1dr`Gm@oiC!pU<9euv)fUF%Ko| zqUAJZOL-0`)%lm|=xyd)?-YFcpyjI7Hq+{f{!7*eFZ?S9k-x8w-hS_SE$wBYH^aZ# zI5U0e-5WcVFaEze@{X&Eh}{L&hYj@!M1d;$-{8pmCv5{YG+&^GB3?T2S#bPTI6mzs zO*9@h9#bD?p@$;hwEJ6nsOa;J3#2+P zwda_|hY1<)Dk{+AR=nPK{T=??P2tW1Uq5;UPlYQk)N>kEw7q-LA60$1WVcS&hqJwb z9$sQ|79?27e>&y9`TCHrd`jeXGc)ttN8U=`ygw{gBIiu^bl|_SkiAk`v-Z;30ZQx= zQ`LbT(epFhpi-)g(mR9bc=r7RCjy^dzVZHQ48(PSt)^?uyV)yLyghC4tg|P-U^+tg z5a!SPvar
"; - div.firstChild.style.width = "5px"; - support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); - - // Prevent IE 6 from affecting layout for positioned elements #11048 - // Prevent IE from shrinking the body in IE 7 mode #12869 - body.style.zoom = 1; - } - - // Null elements to avoid leaks in IE - body.removeChild( container ); - container = div = tds = marginDiv = null; - }); - - // Null elements to avoid leaks in IE - fragment.removeChild( div ); - all = a = select = opt = input = fragment = div = null; - - // These support checks require Modernizr to be loaded: - support.hasCanvas = (typeof Modernizr !== "undefined" && Modernizr["canvas"]); - support.hasVML = (typeof Modernizr !== "undefined" && Modernizr["vml"]); - - return support; -})(); -var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, - rmultiDash = /([A-Z])/g; - -function internalData( elem, name, data, pvt /* Internal Use Only */ ){ - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var thisCache, ret, - internalKey = jQuery.expando, - getByName = typeof name === "string", - - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, - - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, - - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; - - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { - return; - } - - if ( !id ) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++; - } else { - id = internalKey; - } - } - - if ( !cache[ id ] ) { - cache[ id ] = {}; - - // Avoids exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - if ( !isNode ) { - cache[ id ].toJSON = jQuery.noop; - } - } - - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if ( typeof name === "object" || typeof name === "function" ) { - if ( pvt ) { - cache[ id ] = jQuery.extend( cache[ id ], name ); - } else { - cache[ id ].data = jQuery.extend( cache[ id ].data, name ); - } - } - - thisCache = cache[ id ]; - - // jQuery data() is stored in a separate object inside the object's internal data - // cache in order to avoid key collisions between internal data and user-defined - // data. - if ( !pvt ) { - if ( !thisCache.data ) { - thisCache.data = {}; - } - - thisCache = thisCache.data; - } - - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } - - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if ( getByName ) { - - // First Try to find as-is property data - ret = thisCache[ name ]; - - // Test for null|undefined property data - if ( ret == null ) { - - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase( name ) ]; - } - } else { - ret = thisCache; - } - - return ret; -} - -function internalRemoveData( elem, name, pvt /* For internal use only */ ){ - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var thisCache, i, l, - - isNode = elem.nodeType, - - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } - - if ( name ) { - - thisCache = pvt ? cache[ id ] : cache[ id ].data; - - if ( thisCache ) { - - // Support array or space separated string names for data keys - if ( !jQuery.isArray( name ) ) { - - // try the string as a key before any manipulation - if ( name in thisCache ) { - name = [ name ]; - } else { - - // split the camel cased version by spaces unless a key with the spaces exists - name = jQuery.camelCase( name ); - if ( name in thisCache ) { - name = [ name ]; - } else { - name = name.split(" "); - } - } - } else { - // If "name" is an array of keys... - // When data is initially created, via ("key", "val") signature, - // keys will be converted to camelCase. - // Since there is no way to tell _how_ a key was added, remove - // both plain key and camelCase key. #12786 - // This will only penalize the array argument path. - name = name.concat( jQuery.map( name, jQuery.camelCase ) ); - } - - for ( i = 0, l = name.length; i < l; i++ ) { - delete thisCache[ name[i] ]; - } - - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { - return; - } - } - } - - // See jQuery.data for more information - if ( !pvt ) { - delete cache[ id ].data; - - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject( cache[ id ] ) ) { - return; - } - } - - // Destroy the cache - if ( isNode ) { - jQuery.cleanData( [ elem ], true ); - - // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) - } else if ( jQuery.support.deleteExpando || cache != cache.window ) { - delete cache[ id ]; - - // When all else fails, null - } else { - cache[ id ] = null; - } -} - -jQuery.extend({ - cache: {}, - - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ), - - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", - "applet": true - }, - - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); - }, - - data: function( elem, name, data ) { - return internalData( elem, name, data, false ); - }, - - removeData: function( elem, name ) { - return internalRemoveData( elem, name, false ); - }, - - // For internal use only. - _data: function( elem, name, data ) { - return internalData( elem, name, data, true ); - }, - - _removeData: function( elem, name ) { - return internalRemoveData( elem, name, true ); - }, - - // A method for determining if a DOM node can handle the data expando - acceptData: function( elem ) { - var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; - - // nodes accept data unless otherwise specified; rejection can be conditional - return !noData || noData !== true && elem.getAttribute("classid") === noData; - } -}); - -jQuery.fn.extend({ - data: function( key, value ) { - var attrs, name, - elem = this[0], - i = 0, - data = null; - - // Gets all values - if ( key === undefined ) { - if ( this.length ) { - data = jQuery.data( elem ); - - if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { - attrs = elem.attributes; - for ( ; i < attrs.length; i++ ) { - name = attrs[i].name; - - if ( !name.indexOf( "data-" ) ) { - name = jQuery.camelCase( name.substring(5) ); - - dataAttr( elem, name, data[ name ] ); - } - } - jQuery._data( elem, "parsedAttrs", true ); - } - } - - return data; - } - - // Sets multiple values - if ( typeof key === "object" ) { - return this.each(function() { - jQuery.data( this, key ); - }); - } - - return jQuery.access( this, function( value ) { - - if ( value === undefined ) { - // Try to fetch any internally stored data first - return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null; - } - - this.each(function() { - jQuery.data( this, key, value ); - }); - }, null, value, arguments.length > 1, null, true ); - }, - - removeData: function( key ) { - return this.each(function() { - jQuery.removeData( this, key ); - }); - } -}); - -function dataAttr( elem, key, data ) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - - var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); - - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - // Only convert to a number if it doesn't change the string - +data + "" === data ? +data : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch( e ) {} - - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); - - } else { - data = undefined; - } - } - - return data; -} - -// checks a cache object for emptiness -function isEmptyDataObject( obj ) { - var name; - for ( name in obj ) { - - // if the public data object is empty, the private is still empty - if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { - continue; - } - if ( name !== "toJSON" ) { - return false; - } - } - - return true; -} -jQuery.extend({ - queue: function( elem, type, data ) { - var queue; - - if ( elem ) { - type = ( type || "fx" ) + "queue"; - queue = jQuery._data( elem, type ); - - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !queue || jQuery.isArray(data) ) { - queue = jQuery._data( elem, type, jQuery.makeArray(data) ); - } else { - queue.push( data ); - } - } - return queue || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - startLength = queue.length, - fn = queue.shift(), - hooks = jQuery._queueHooks( elem, type ), - next = function() { - jQuery.dequeue( elem, type ); - }; - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - startLength--; - } - - if ( fn ) { - - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift( "inprogress" ); - } - - // clear up the last queue stop function - delete hooks.stop; - fn.call( elem, next, hooks ); - } - - if ( !startLength && hooks ) { - hooks.empty.fire(); - } - }, - - // not intended for public consumption - generates a queueHooks object, or returns the current one - _queueHooks: function( elem, type ) { - var key = type + "queueHooks"; - return jQuery._data( elem, key ) || jQuery._data( elem, key, { - empty: jQuery.Callbacks("once memory").add(function() { - jQuery._removeData( elem, type + "queue" ); - jQuery._removeData( elem, key ); - }) - }); - } -}); - -jQuery.fn.extend({ - queue: function( type, data ) { - var setter = 2; - - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - setter--; - } - - if ( arguments.length < setter ) { - return jQuery.queue( this[0], type ); - } - - return data === undefined ? - this : - this.each(function() { - var queue = jQuery.queue( this, type, data ); - - // ensure a hooks for this queue - jQuery._queueHooks( this, type ); - - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); - }, - dequeue: function( type ) { - return this.each(function() { - jQuery.dequeue( this, type ); - }); - }, - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; - type = type || "fx"; - - return this.queue( type, function( next, hooks ) { - var timeout = setTimeout( next, time ); - hooks.stop = function() { - clearTimeout( timeout ); - }; - }); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, obj ) { - var tmp, - count = 1, - defer = jQuery.Deferred(), - elements = this, - i = this.length, - resolve = function() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - }; - - if ( typeof type !== "string" ) { - obj = type; - type = undefined; - } - type = type || "fx"; - - while( i-- ) { - tmp = jQuery._data( elements[ i ], type + "queueHooks" ); - if ( tmp && tmp.empty ) { - count++; - tmp.empty.add( resolve ); - } - } - resolve(); - return defer.promise( obj ); - } -}); -var nodeHook, boolHook, - rclass = /[\t\r\n]/g, - rreturn = /\r/g, - rfocusable = /^(?:input|select|textarea|button|object)$/i, - rclickable = /^(?:a|area)$/i, - rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i, - ruseDefault = /^(?:checked|selected)$/i, - getSetAttribute = jQuery.support.getSetAttribute, - getSetInput = jQuery.support.input; - -jQuery.fn.extend({ - attr: function( name, value ) { - return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); - }, - - removeAttr: function( name ) { - return this.each(function() { - jQuery.removeAttr( this, name ); - }); - }, - - prop: function( name, value ) { - return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); - }, - - removeProp: function( name ) { - name = jQuery.propFix[ name ] || name; - return this.each(function() { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch( e ) {} - }); - }, - - addClass: function( value ) { - var classes, elem, cur, clazz, j, - i = 0, - len = this.length, - proceed = typeof value === "string" && value; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).addClass( value.call( this, j, this.className ) ); - }); - } - - if ( proceed ) { - // The disjunction here is for better compressibility (see removeClass) - classes = ( value || "" ).match( core_rnotwhite ) || []; - - for ( ; i < len; i++ ) { - elem = this[ i ]; - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - " " - ); - - if ( cur ) { - j = 0; - while ( (clazz = classes[j++]) ) { - if ( cur.indexOf( " " + clazz + " " ) < 0 ) { - cur += clazz + " "; - } - } - elem.className = jQuery.trim( cur ); - - } - } - } - - return this; - }, - - removeClass: function( value ) { - var classes, elem, cur, clazz, j, - i = 0, - len = this.length, - proceed = arguments.length === 0 || typeof value === "string" && value; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).removeClass( value.call( this, j, this.className ) ); - }); - } - if ( proceed ) { - classes = ( value || "" ).match( core_rnotwhite ) || []; - - for ( ; i < len; i++ ) { - elem = this[ i ]; - // This expression is here for better compressibility (see addClass) - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - "" - ); - - if ( cur ) { - j = 0; - while ( (clazz = classes[j++]) ) { - // Remove *all* instances - while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { - cur = cur.replace( " " + clazz + " ", " " ); - } - } - elem.className = value ? jQuery.trim( cur ) : ""; - } - } - } - - return this; - }, - - toggleClass: function( value, stateVal ) { - var type = typeof value, - isBool = typeof stateVal === "boolean"; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( i ) { - jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); - }); - } - - return this.each(function() { - if ( type === "string" ) { - // toggle individual class names - var className, - i = 0, - self = jQuery( this ), - state = stateVal, - classNames = value.match( core_rnotwhite ) || []; - - while ( (className = classNames[ i++ ]) ) { - // check each className given, space separated list - state = isBool ? state : !self.hasClass( className ); - self[ state ? "addClass" : "removeClass" ]( className ); - } - - // Toggle whole class name - } else if ( type === "undefined" || type === "boolean" ) { - if ( this.className ) { - // store className if set - jQuery._data( this, "__className__", this.className ); - } - - // If the element has a class name or if we're passed "false", - // then remove the whole classname (if there was one, the above saved it). - // Otherwise bring back whatever was previously saved (if anything), - // falling back to the empty string if nothing was stored. - this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; - } - }); - }, - - hasClass: function( selector ) { - var className = " " + selector + " ", - i = 0, - l = this.length; - for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { - return true; - } - } - - return false; - }, - - val: function( value ) { - var hooks, ret, isFunction, - elem = this[0]; - - if ( !arguments.length ) { - if ( elem ) { - hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; - - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { - return ret; - } - - ret = elem.value; - - return typeof ret === "string" ? - // handle most common string cases - ret.replace(rreturn, "") : - // handle cases where value is null/undef or number - ret == null ? "" : ret; - } - - return; - } - - isFunction = jQuery.isFunction( value ); - - return this.each(function( i ) { - var val, - self = jQuery(this); - - if ( this.nodeType !== 1 ) { - return; - } - - if ( isFunction ) { - val = value.call( this, i, self.val() ); - } else { - val = value; - } - - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - } else if ( typeof val === "number" ) { - val += ""; - } else if ( jQuery.isArray( val ) ) { - val = jQuery.map(val, function ( value ) { - return value == null ? "" : value + ""; - }); - } - - hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; - - // If set returns undefined, fall back to normal setting - if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { - this.value = val; - } - }); - } -}); - -jQuery.extend({ - valHooks: { - option: { - get: function( elem ) { - // attributes.value is undefined in Blackberry 4.7 but - // uses .value. See #6932 - var val = elem.attributes.value; - return !val || val.specified ? elem.value : elem.text; - } - }, - select: { - get: function( elem ) { - var value, option, - options = elem.options, - index = elem.selectedIndex, - one = elem.type === "select-one" || index < 0, - values = one ? null : [], - max = one ? index + 1 : options.length, - i = index < 0 ? - max : - one ? index : 0; - - // Loop through all the selected options - for ( ; i < max; i++ ) { - option = options[ i ]; - - // oldIE doesn't update selected after form reset (#2551) - if ( ( option.selected || i === index ) && - // Don't return options that are disabled or in a disabled optgroup - ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && - ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { - - // Get the specific value for the option - value = jQuery( option ).val(); - - // We don't need an array for one selects - if ( one ) { - return value; - } - - // Multi-Selects return an array - values.push( value ); - } - } - - return values; - }, - - set: function( elem, value ) { - var values = jQuery.makeArray( value ); - - jQuery(elem).find("option").each(function() { - this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; - }); - - if ( !values.length ) { - elem.selectedIndex = -1; - } - return values; - } - } - }, - - attr: function( elem, name, value ) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set attributes on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === "undefined" ) { - return jQuery.prop( elem, name, value ); - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - // All attributes are lowercase - // Grab necessary hook if one is defined - if ( notxml ) { - name = name.toLowerCase(); - hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); - } - - if ( value !== undefined ) { - - if ( value === null ) { - jQuery.removeAttr( elem, name ); - - } else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - elem.setAttribute( name, value + "" ); - return value; - } - - } else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - - ret = elem.getAttribute( name ); - - // Non-existent attributes return null, we normalize to undefined - return ret == null ? - undefined : - ret; - } - }, - - removeAttr: function( elem, value ) { - var name, propName, - i = 0, - attrNames = value && value.match( core_rnotwhite ); - - if ( attrNames && elem.nodeType === 1 ) { - while ( (name = attrNames[i++]) ) { - propName = jQuery.propFix[ name ] || name; - - // Boolean attributes get special treatment (#10870) - if ( rboolean.test( name ) ) { - // Set corresponding property to false for boolean attributes - // Also clear defaultChecked/defaultSelected (if appropriate) for IE<8 - if ( !getSetAttribute && ruseDefault.test( name ) ) { - elem[ jQuery.camelCase( "default-" + name ) ] = - elem[ propName ] = false; - } else { - elem[ propName ] = false; - } - - // See #9699 for explanation of this approach (setting first, then removal) - } else { - jQuery.attr( elem, name, "" ); - } - - elem.removeAttribute( getSetAttribute ? name : propName ); - } - } - }, - - attrHooks: { - type: { - set: function( elem, value ) { - if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { - // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to default in case type is set after value during creation - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } - } - } - }, - - propFix: { - tabindex: "tabIndex", - readonly: "readOnly", - "for": "htmlFor", - "class": "className", - maxlength: "maxLength", - cellspacing: "cellSpacing", - cellpadding: "cellPadding", - rowspan: "rowSpan", - colspan: "colSpan", - usemap: "useMap", - frameborder: "frameBorder", - contenteditable: "contentEditable" - }, - - prop: function( elem, name, value ) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set properties on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - if ( notxml ) { - // Fix name and attach hooks - name = jQuery.propFix[ name ] || name; - hooks = jQuery.propHooks[ name ]; - } - - if ( value !== undefined ) { - if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - return ( elem[ name ] = value ); - } - - } else { - if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - return elem[ name ]; - } - } - }, - - propHooks: { - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - var attributeNode = elem.getAttributeNode("tabindex"); - - return attributeNode && attributeNode.specified ? - parseInt( attributeNode.value, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - } - } -}); - -// Hook for boolean attributes -boolHook = { - get: function( elem, name ) { - var - // Use .prop to determine if this attribute is understood as boolean - prop = jQuery.prop( elem, name ), - - // Fetch it accordingly - attr = typeof prop === "boolean" && elem.getAttribute( name ), - detail = typeof prop === "boolean" ? - - getSetInput && getSetAttribute ? - attr != null : - // oldIE fabricates an empty string for missing boolean attributes - // and conflates checked/selected into attroperties - ruseDefault.test( name ) ? - elem[ jQuery.camelCase( "default-" + name ) ] : - !!attr : - - // fetch an attribute node for properties not recognized as boolean - elem.getAttributeNode( name ); - - return detail && detail.value !== false ? - name.toLowerCase() : - undefined; - }, - set: function( elem, value, name ) { - if ( value === false ) { - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { - // IE<8 needs the *property* name - elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); - - // Use defaultChecked and defaultSelected for oldIE - } else { - elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; - } - - return name; - } -}; - -// fix oldIE value attroperty -if ( !getSetInput || !getSetAttribute ) { - jQuery.attrHooks.value = { - get: function( elem, name ) { - var ret = elem.getAttributeNode( name ); - return jQuery.nodeName( elem, "input" ) ? - - // Ignore the value *property* by using defaultValue - elem.defaultValue : - - ret && ret.specified ? ret.value : undefined; - }, - set: function( elem, value, name ) { - if ( jQuery.nodeName( elem, "input" ) ) { - // Does not return so that setAttribute is also used - elem.defaultValue = value; - } else { - // Use nodeHook if defined (#1954); otherwise setAttribute is fine - return nodeHook && nodeHook.set( elem, value, name ); - } - } - }; -} - -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !getSetAttribute ) { - - // Use this for any attribute in IE6/7 - // This fixes almost every IE6/7 issue - nodeHook = jQuery.valHooks.button = { - get: function( elem, name ) { - var ret = elem.getAttributeNode( name ); - return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ? - ret.value : - undefined; - }, - set: function( elem, value, name ) { - // Set the existing or create a new attribute node - var ret = elem.getAttributeNode( name ); - if ( !ret ) { - elem.setAttributeNode( - (ret = elem.ownerDocument.createAttribute( name )) - ); - } - - ret.value = value += ""; - - // Break association with cloned elements by also using setAttribute (#9646) - return name === "value" || value === elem.getAttribute( name ) ? - value : - undefined; - } - }; - - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - get: nodeHook.get, - set: function( elem, value, name ) { - nodeHook.set( elem, value === "" ? false : value, name ); - } - }; - - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each([ "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - set: function( elem, value ) { - if ( value === "" ) { - elem.setAttribute( name, "auto" ); - return value; - } - } - }); - }); -} - - -// Some attributes require a special call on IE -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !jQuery.support.hrefNormalized ) { - jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - get: function( elem ) { - var ret = elem.getAttribute( name, 2 ); - return ret == null ? undefined : ret; - } - }); - }); - - // href/src property should get the full normalized URL (#10299/#12915) - jQuery.each([ "href", "src" ], function( i, name ) { - jQuery.propHooks[ name ] = { - get: function( elem ) { - return elem.getAttribute( name, 4 ); - } - }; - }); -} - -if ( !jQuery.support.style ) { - jQuery.attrHooks.style = { - get: function( elem ) { - // Return undefined in the case of empty string - // Normalize to lowercase since IE uppercases css property names - return elem.style.cssText.toLowerCase() || undefined; - }, - set: function( elem, value ) { - return ( elem.style.cssText = value + "" ); - } - }; -} - -// Safari mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it -if ( !jQuery.support.optSelected ) { - jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { - get: function( elem ) { - var parent = elem.parentNode; - - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } - } - return null; - } - }); -} - -// IE6/7 call enctype encoding -if ( !jQuery.support.enctype ) { - jQuery.propFix.enctype = "encoding"; -} - -// Radios and checkboxes getter/setter -if ( !jQuery.support.checkOn ) { - jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = { - get: function( elem ) { - // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; - } - }; - }); -} -jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { - set: function( elem, value ) { - if ( jQuery.isArray( value ) ) { - return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); - } - } - }); -}); -var rformElems = /^(?:input|select|textarea)$/i, - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|contextmenu)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; - -/* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ -jQuery.event = { - - add: function( elem, types, handler, data, selector ) { - var elemData, eventHandle, events, - tns, type, namespaces, handleObj, - handleObjIn, handlers, special, - t = 0; - - // Don't attach events to noData or text/comment nodes (allow plain objects tho) - if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - selector = handleObjIn.selector; - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - events = elemData.events; - if ( !events ) { - elemData.events = events = {}; - } - eventHandle = elemData.handle; - if ( !eventHandle ) { - elemData.handle = eventHandle = function( e ) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : - undefined; - }; - // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events - eventHandle.elem = elem; - } - - // Handle multiple events separated by a space - // jQuery(...).bind("mouseover mouseout", fn); - types = ( types || "" ).match( core_rnotwhite ) || [""]; - for ( ; t < types.length; t++ ) { - - tns = rtypenamespace.exec( types[t] ) || []; - type = tns[1]; - namespaces = ( tns[2] || "" ).split( "." ).sort(); - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = ( selector ? special.delegateType : special.bindType ) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend({ - type: type, - origType: tns[1], - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - needsContext: selector && jQuery.expr.match.needsContext.test( selector ), - namespace: namespaces.join(".") - }, handleObjIn ); - - // Init the event handler queue if we're the first - handlers = events[ type ]; - if ( !handlers ) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener/attachEvent if the special events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if ( selector ) { - handlers.splice( handlers.delegateCount++, 0, handleObj ); - } else { - handlers.push( handleObj ); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - - global: {}, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, selector, mappedTypes ) { - - var tns, type, origType, namespaces, origCount, - j, events, special, eventType, handleObj, - t = 0, - elemData = jQuery.hasData( elem ) && jQuery._data( elem ); - - if ( !elemData || !(events = elemData.events) ) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = ( types || "" ).match( core_rnotwhite ) || [""]; - for ( ; t < types.length; t++ ) { - tns = rtypenamespace.exec( types[t] ) || []; - type = origType = tns[1]; - namespaces = tns[2]; - - // Unbind all events (on this namespace, if provided) for the element - if ( !type ) { - for ( type in events ) { - jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = ( selector? special.delegateType : special.bindType ) || type; - eventType = events[ type ] || []; - origCount = eventType.length; - namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null; - - // Remove matching events - for ( j = 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !namespaces || namespaces.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { - eventType.splice( j--, 1 ); - - if ( handleObj.selector ) { - eventType.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if ( eventType.length === 0 && origCount !== eventType.length ) { - if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { - jQuery.removeEvent( elem, type, elemData.handle ); - } - - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - delete elemData.handle; - - // removeData also checks for emptiness and clears the expando if empty - // so use it instead of delete - jQuery._removeData( elem, "events" ); - } - }, - - trigger: function( event, data, elem, onlyHandlers ) { - - var i, cur, old, ontype, special, handle, eventPath, bubbleType, - type = event.type || event, - namespaces = event.namespace ? event.namespace.split(".") : []; - - elem = elem || document; - - // Don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { - return; - } - - if ( type.indexOf(".") >= 0 ) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split("."); - type = namespaces.shift(); - namespaces.sort(); - } - - // Caller can pass in an Event, Object, or just an event type string - event = typeof event === "object" ? - // jQuery.Event object - event[ jQuery.expando ] ? event : - // Object literal - new jQuery.Event( type, event ) : - // Just the event type (string) - new jQuery.Event( type ); - - event.type = type; - event.isTrigger = true; - event.namespace = namespaces.join("."); - event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; - ontype = type.indexOf(":") < 0 ? "on" + type : ""; - - // Clean up the event in case it is being reused - event.result = undefined; - if ( !event.target ) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data != null ? jQuery.makeArray( data ) : []; - data.unshift( event ); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - eventPath = [[ elem, special.bindType || type ]]; - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { - - bubbleType = special.delegateType || type; - cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; - for ( old = elem; cur; cur = cur.parentNode ) { - eventPath.push([ cur, bubbleType ]); - old = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( old === (elem.ownerDocument || document) ) { - eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); - } - } - - // Fire handlers on the event path - for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { - - cur = eventPath[i][0]; - event.type = eventPath[i][1]; - - handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); - if ( handle ) { - handle.apply( cur, data ); - } - // Note that this is a bare JS function and not a jQuery handler - handle = ontype && cur[ ontype ]; - if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { - event.preventDefault(); - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if ( !onlyHandlers && !event.isDefaultPrevented() ) { - - if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && - !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { - - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. - // Don't do default actions on window, that's where global variables be (#6170) - if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { - - // Don't re-trigger an onFOO event when we call its FOO() method - old = elem[ ontype ]; - - if ( old ) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - try { - elem[ type ](); - } catch ( e ) { - // IE<9 dies on focus/blur to hidden element (#1486,#12518) - // only reproducible on winXP IE8 native, not IE9 in IE8 mode - } - jQuery.event.triggered = undefined; - - if ( old ) { - elem[ ontype ] = old; - } - } - } - } - - return event.result; - }, - - dispatch: function( event ) { - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( event ); - - var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, - handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), - delegateCount = handlers.delegateCount, - args = core_slice.call( arguments ), - special = jQuery.event.special[ event.type ] || {}, - handlerQueue = []; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[0] = event; - event.delegateTarget = this; - - // Call the preDispatch hook for the mapped type, and let it bail if desired - if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { - return; - } - - // Determine handlers that should run if there are delegated events - // Avoid non-left-click bubbling in Firefox (#3861) - if ( delegateCount && !(event.button && event.type === "click") ) { - - for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { - - // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764) - if ( cur.disabled !== true || event.type !== "click" ) { - selMatch = {}; - matches = []; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - sel = handleObj.selector; - - if ( selMatch[ sel ] === undefined ) { - selMatch[ sel ] = handleObj.needsContext ? - jQuery( sel, this ).index( cur ) >= 0 : - jQuery.find( sel, this, null, [ cur ] ).length; - } - if ( selMatch[ sel ] ) { - matches.push( handleObj ); - } - } - if ( matches.length ) { - handlerQueue.push({ elem: cur, matches: matches }); - } - } - } - } - - // Add the remaining (directly-bound) handlers - if ( handlers.length > delegateCount ) { - handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); - } - - // Run delegates first; they may want to stop propagation beneath us - for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { - matched = handlerQueue[ i ]; - event.currentTarget = matched.elem; - - for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { - handleObj = matched.matches[ j ]; - - // Triggered event must either 1) have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). - if ( !event.namespace || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { - - event.data = handleObj.data; - event.handleObj = handleObj; - - ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) - .apply( matched.elem, args ); - - if ( ret !== undefined ) { - event.result = ret; - if ( ret === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - // Call the postDispatch hook for the mapped type - if ( special.postDispatch ) { - special.postDispatch.call( this, event ); - } - - return event.result; - }, - - // Includes some event props shared by KeyEvent and MouseEvent - props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), - - fixHooks: {}, - - keyHooks: { - props: "char charCode key keyCode".split(" "), - filter: function( event, original ) { - - // Add which for key events - if ( event.which == null ) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } - - return event; - } - }, - - mouseHooks: { - props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), - filter: function( event, original ) { - var eventDoc, doc, body, - button = original.button, - fromElement = original.fromElement; - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && original.clientX != null ) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); - event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); - } - - // Add relatedTarget, if necessary - if ( !event.relatedTarget && fromElement ) { - event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && button !== undefined ) { - event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); - } - - return event; - } - }, - - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, - originalEvent = event, - fixHook = jQuery.event.fixHooks[ event.type ] || {}, - copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; - - event = jQuery.Event( originalEvent ); - - for ( i = copy.length; i; ) { - prop = copy[ --i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) - if ( !event.target ) { - event.target = originalEvent.srcElement || document; - } - - // Target should not be a text node (#504, Safari) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8) - event.metaKey = !!event.metaKey; - - return fixHook.filter? fixHook.filter( event, originalEvent ) : event; - }, - - special: { - load: { - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - click: { - // For checkbox, fire native event so checked state will be right - trigger: function() { - if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { - this.click(); - return false; - } - } - }, - focus: { - // Fire native event if possible so blur/focus sequence is correct - trigger: function() { - if ( this !== document.activeElement && this.focus ) { - try { - this.focus(); - return false; - } catch ( e ) { - // IE<9 dies on focus to hidden element (#1486,#12518) - // If this happens, let .trigger() run the handlers - } - } - }, - delegateType: "focusin" - }, - blur: { - trigger: function() { - if ( this === document.activeElement && this.blur ) { - this.blur(); - return false; - } - }, - delegateType: "focusout" - }, - - beforeunload: { - postDispatch: function( event ) { - - // Even when returnValue equals to undefined Firefox will still show alert - if ( event.result !== undefined ) { - event.originalEvent.returnValue = event.result; - } - } - } - }, - - simulate: function( type, elem, event, bubble ) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - var e = jQuery.extend( - new jQuery.Event(), - event, - { type: type, - isSimulated: true, - originalEvent: {} - } - ); - if ( bubble ) { - jQuery.event.trigger( e, null, elem ); - } else { - jQuery.event.dispatch.call( elem, e ); - } - if ( e.isDefaultPrevented() ) { - event.preventDefault(); - } - } -}; - -// Some plugins are using, but it's undocumented/deprecated and will be removed. -// The 1.7 special event interface should provide all the hooks needed now. -jQuery.event.handle = jQuery.event.dispatch; - -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle, false ); - } - } : - function( elem, type, handle ) { - var name = "on" + type; - - if ( elem.detachEvent ) { - - // #8545, #7054, preventing memory leaks for custom events in IE6-8 - // detachEvent needed property on element, by name of that event, to properly expose it to GC - if ( typeof elem[ name ] === "undefined" ) { - elem[ name ] = null; - } - - elem.detachEvent( name, handle ); - } - }; - -jQuery.Event = function( src, props ) { - // Allow instantiation without the 'new' keyword - if ( !(this instanceof jQuery.Event) ) { - return new jQuery.Event( src, props ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -function returnFalse() { - return false; -} -function returnTrue() { - return true; -} - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - preventDefault: function() { - this.isDefaultPrevented = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - - // if preventDefault exists run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // otherwise set the returnValue property of the original event to false (IE) - } else { - e.returnValue = false; - } - }, - stopPropagation: function() { - this.isPropagationStopped = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - // if stopPropagation exists run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } - // otherwise set the cancelBubble property of the original event to true (IE) - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - }, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse -}; - -// Create mouseenter/leave events using mouseover/out and event-time checks -jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, - - handle: function( event ) { - var ret, - target = this, - related = event.relatedTarget, - handleObj = event.handleObj; - - // For mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || (related !== target && !jQuery.contains( target, related )) ) { - event.type = handleObj.origType; - ret = handleObj.handler.apply( this, arguments ); - event.type = fix; - } - return ret; - } - }; -}); - -// IE submit delegation -if ( !jQuery.support.submitBubbles ) { - - jQuery.event.special.submit = { - setup: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Lazy-add a submit handler when a descendant form may potentially be submitted - jQuery.event.add( this, "click._submit keypress._submit", function( e ) { - // Node name check avoids a VML-related crash in IE (#9807) - var elem = e.target, - form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; - if ( form && !jQuery._data( form, "_submit_attached" ) ) { - jQuery.event.add( form, "submit._submit", function( event ) { - event._submit_bubble = true; - }); - jQuery._data( form, "_submit_attached", true ); - } - }); - // return undefined since we don't need an event listener - }, - - postDispatch: function( event ) { - // If form was submitted by the user, bubble the event up the tree - if ( event._submit_bubble ) { - delete event._submit_bubble; - if ( this.parentNode && !event.isTrigger ) { - jQuery.event.simulate( "submit", this.parentNode, event, true ); - } - } - }, - - teardown: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Remove delegated handlers; cleanData eventually reaps submit handlers attached above - jQuery.event.remove( this, "._submit" ); - } - }; -} - -// IE change delegation and checkbox/radio fix -if ( !jQuery.support.changeBubbles ) { - - jQuery.event.special.change = { - - setup: function() { - - if ( rformElems.test( this.nodeName ) ) { - // IE doesn't fire change on a check/radio until blur; trigger it on click - // after a propertychange. Eat the blur-change in special.change.handle. - // This still fires onchange a second time for check/radio after blur. - if ( this.type === "checkbox" || this.type === "radio" ) { - jQuery.event.add( this, "propertychange._change", function( event ) { - if ( event.originalEvent.propertyName === "checked" ) { - this._just_changed = true; - } - }); - jQuery.event.add( this, "click._change", function( event ) { - if ( this._just_changed && !event.isTrigger ) { - this._just_changed = false; - } - // Allow triggered, simulated change events (#11500) - jQuery.event.simulate( "change", this, event, true ); - }); - } - return false; - } - // Delegated event; lazy-add a change handler on descendant inputs - jQuery.event.add( this, "beforeactivate._change", function( e ) { - var elem = e.target; - - if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) { - jQuery.event.add( elem, "change._change", function( event ) { - if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { - jQuery.event.simulate( "change", this.parentNode, event, true ); - } - }); - jQuery._data( elem, "_change_attached", true ); - } - }); - }, - - handle: function( event ) { - var elem = event.target; - - // Swallow native change events from checkbox/radio, we already triggered them above - if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { - return event.handleObj.handler.apply( this, arguments ); - } - }, - - teardown: function() { - jQuery.event.remove( this, "._change" ); - - return !rformElems.test( this.nodeName ); - } - }; -} - -// Create "bubbling" focus and blur events -if ( !jQuery.support.focusinBubbles ) { - jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0, - handler = function( event ) { - jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); - }; - - jQuery.event.special[ fix ] = { - setup: function() { - if ( attaches++ === 0 ) { - document.addEventListener( orig, handler, true ); - } - }, - teardown: function() { - if ( --attaches === 0 ) { - document.removeEventListener( orig, handler, true ); - } - } - }; - }); -} - -jQuery.fn.extend({ - - on: function( types, selector, data, fn, /*INTERNAL*/ one ) { - var origFn, type; - - // Types can be a map of types/handlers - if ( typeof types === "object" ) { - // ( types-Object, selector, data ) - if ( typeof selector !== "string" ) { // && selector != null - // ( types-Object, data ) - data = data || selector; - selector = undefined; - } - for ( type in types ) { - this.on( type, selector, data, types[ type ], one ); - } - return this; - } - - if ( data == null && fn == null ) { - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if ( fn == null ) { - if ( typeof selector === "string" ) { - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - if ( fn === false ) { - fn = returnFalse; - } else if ( !fn ) { - return this; - } - - if ( one === 1 ) { - origFn = fn; - fn = function( event ) { - // Can use an empty set, since event contains the info - jQuery().off( event ); - return origFn.apply( this, arguments ); - }; - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); - } - return this.each( function() { - jQuery.event.add( this, types, fn, data, selector ); - }); - }, - one: function( types, selector, data, fn ) { - return this.on( types, selector, data, fn, 1 ); - }, - off: function( types, selector, fn ) { - var handleObj, type; - if ( types && types.preventDefault && types.handleObj ) { - // ( event ) dispatched jQuery.Event - handleObj = types.handleObj; - jQuery( types.delegateTarget ).off( - handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, - handleObj.selector, - handleObj.handler - ); - return this; - } - if ( typeof types === "object" ) { - // ( types-object [, selector] ) - for ( type in types ) { - this.off( type, selector, types[ type ] ); - } - return this; - } - if ( selector === false || typeof selector === "function" ) { - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if ( fn === false ) { - fn = returnFalse; - } - return this.each(function() { - jQuery.event.remove( this, types, fn, selector ); - }); - }, - - bind: function( types, data, fn ) { - return this.on( types, null, data, fn ); - }, - unbind: function( types, fn ) { - return this.off( types, null, fn ); - }, - - delegate: function( selector, types, data, fn ) { - return this.on( types, selector, data, fn ); - }, - undelegate: function( selector, types, fn ) { - // ( namespace ) or ( selector, types [, fn] ) - return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); - }, - - trigger: function( type, data ) { - return this.each(function() { - jQuery.event.trigger( type, data, this ); - }); - }, - triggerHandler: function( type, data ) { - if ( this[0] ) { - return jQuery.event.trigger( type, data, this[0], true ); - } - }, - - hover: function( fnOver, fnOut ) { - return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); - } -}); - -jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { - - // Handle event binding - jQuery.fn[ name ] = function( data, fn ) { - return arguments.length > 0 ? - this.on( name, null, data, fn ) : - this.trigger( name ); - }; - - if ( rkeyEvent.test( name ) ) { - jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; - } - - if ( rmouseEvent.test( name ) ) { - jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; - } -}); -/*! - * Sizzle CSS Selector Engine - * Copyright 2012 jQuery Foundation and other contributors - * Released under the MIT license - * http://sizzlejs.com/ - */ -(function( window, undefined ) { - -var i, - cachedruns, - Expr, - getText, - isXML, - compile, - hasDuplicate, - outermostContext, - - // Local document vars - setDocument, - document, - docElem, - documentIsXML, - rbuggyQSA, - rbuggyMatches, - matches, - contains, - sortOrder, - - expando = "sizzle" + -(new Date()), - - strundefined = typeof undefined, - - // Used in sorting - MAX_NEGATIVE = 1 << 31, - preferredDoc = window.document, - - Token = String, - dirruns = 0, - done = 0, - support = {}, - - // Array methods - arr = [], - pop = arr.pop, - push = arr.push, - slice = arr.slice, - // Use a stripped-down indexOf if we can't use a native one - indexOf = arr.indexOf || function( elem ) { - var i = 0, - len = this.length; - for ( ; i < len; i++ ) { - if ( this[i] === elem ) { - return i; - } - } - return -1; - }, - - // Augment a function for special use by Sizzle - markFunction = function( fn, value ) { - fn[ expando ] = value == null || value; - return fn; - }, - - createCache = function() { - var cache = {}, - keys = []; - - return markFunction(function( key, value ) { - // Only keep the most recent entries - if ( keys.push( key ) > Expr.cacheLength ) { - delete cache[ keys.shift() ]; - } - - // Retrieve with (key + " ") to avoid collision with native Object.prototype properties (see Issue #157) - return (cache[ key + " " ] = value); - }, cache ); - }, - - classCache = createCache(), - tokenCache = createCache(), - compilerCache = createCache(), - - // Regex - - // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace - whitespace = "[\\x20\\t\\r\\n\\f]", - // http://www.w3.org/TR/css3-syntax/#characters - characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", - - // Loosely modeled on CSS identifier characters - // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors) - // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - identifier = characterEncoding.replace( "w", "w#" ), - - // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors - operators = "([*^$|!~]?=)", - attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + - "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", - - // Prefer arguments quoted, - // then not containing pseudos/brackets, - // then attribute selectors/non-parenthetical expressions, - // then anything else - // These preferences are here to reduce the number of selectors - // needing tokenize in the PSEUDO preFilter - pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", - - // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter - rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), - - rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), - rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ), - rpseudo = new RegExp( pseudos ), - ridentifier = new RegExp( "^" + identifier + "$" ), - - // Easily-parseable/retrievable ID or TAG or CLASS selectors - rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/, - - rsibling = /[\x20\t\r\n\f]*[+~]/, - - rheader = /h\d/i, - rinputs = /input|select|textarea|button/i, - - rnative = /\{\s*\[native code\]\s*\}/, - - rbackslash = /\\(?!\\)/g, - rsingleBackslash = /([^\\])(\\(?!\\))/g, - - rescape = /'|\\/g, - rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, - - matchExpr = { - "ID": new RegExp( "^#(" + characterEncoding + ")" ), - "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), - "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ), - "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), - "ATTR": new RegExp( "^" + attributes ), - "PSEUDO": new RegExp( "^" + pseudos ), - "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + - "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + - "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), - // For use in libraries implementing .is() - // We use this for POS matching in `select` - "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + - whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) - }, - - /** - * For feature detection - * @param {Function} fn The function to test for native support - */ - isNative = function( fn ) { - return rnative.test( fn + "" ); - }, - - /** - * Support testing using an element - * @param {Function} fn Passed the created div and expects a boolean result - */ - assert = function( fn ) { - var div = document.createElement("div"); - - try { - return fn( div ); - } catch (e) { - return false; - } finally { - // release memory in IE - div = null; - } - }; - -// Use a stripped-down slice if we can't use a native one -try { - slice.call( docElem.childNodes, 0 )[0].nodeType; -} catch ( e ) { - slice = function( i ) { - var elem, - results = []; - for ( ; (elem = this[i]); i++ ) { - results.push( elem ); - } - return results; - }; -} - -function Sizzle( selector, context, results, seed ) { - var match, elem, m, nodeType, - // QSA vars - i, groups, old, nid, newContext, newSelector; - - if ( context && (( context.ownerDocument || context ) !== document) ) { - setDocument( context ); - } - - context = context || document; - results = results || []; - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { - return []; - } - - if ( !documentIsXML && !seed ) { - - // Shortcuts - if ( (match = rquickExpr.exec( selector )) ) { - // Speed-up: Sizzle("#ID") - if ( (m = match[1]) ) { - if ( nodeType === 9 ) { - elem = context.getElementById( m ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE, Opera, and Webkit return items - // by name instead of ID - if ( elem.id === m ) { - results.push( elem ); - return results; - } - } else { - return results; - } - } else { - // Context is not a document - if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && - contains( context, elem ) && elem.id === m ) { - results.push( elem ); - return results; - } - } - - // Speed-up: Sizzle("TAG") - } else if ( match[2] ) { - push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) ); - return results; - - // Speed-up: Sizzle(".CLASS") - } else if ( (m = match[3]) && support.getByClassName && context.getElementsByClassName ) { - push.apply( results, slice.call(context.getElementsByClassName( m ), 0) ); - return results; - } - } - - // QSA path - if ( support.qsa && !rbuggyQSA.test(selector) ) { - old = true; - nid = expando; - newContext = context; - newSelector = nodeType === 9 && selector; - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - groups = tokenize( selector ); - - if ( (old = context.getAttribute("id")) ) { - nid = old.replace( rescape, "\\$&" ); - } else { - context.setAttribute( "id", nid ); - } - nid = "[id='" + nid + "'] "; - - i = groups.length; - while ( i-- ) { - groups[i] = nid + groups[i].join(""); - } - newContext = rsibling.test( selector ) && context.parentNode || context; - newSelector = groups.join(","); - } - - if ( newSelector ) { - try { - push.apply( results, slice.call( newContext.querySelectorAll( - newSelector - ), 0 ) ); - return results; - } catch(qsaError) { - } finally { - if ( !old ) { - context.removeAttribute("id"); - } - } - } - } - } - - // All others - return select( selector.replace( rtrim, "$1" ), context, results, seed ); -} - -/** - * Detect xml - * @param {Element|Object} elem An element or a document - */ -isXML = Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = elem && (elem.ownerDocument || elem).documentElement; - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -/** - * Sets document-related variables once based on the current document - * @param {Element|Object} [doc] An element or document object to use to set the document - * @returns {Object} Returns the current document - */ -setDocument = Sizzle.setDocument = function( doc ) { - doc = doc && doc.ownerDocument || doc || window.document; - - // If no document and documentElement is available, return - if ( !doc || doc.nodeType !== 9 || !doc.documentElement || document === doc ) { - return document; - } - - // Set our document - document = doc; - docElem = doc.documentElement; - - // Support tests - documentIsXML = isXML( doc ); - - // Check if getElementsByTagName("*") returns only elements - support.tagNameNoComments = assert(function( div ) { - div.appendChild( doc.createComment("") ); - return !div.getElementsByTagName("*").length; - }); - - // Check if attributes should be retrieved by attribute nodes - support.attributes = assert(function( div ) { - div.innerHTML = ""; - var type = typeof div.lastChild.getAttribute("multiple"); - // IE8 returns a string for some attributes even when not present - return type !== "boolean" && type !== "string"; - }); - - // Check if getElementsByClassName can be trusted - support.getByClassName = assert(function( div ) { - // Opera can't find a second classname (in 9.6) - div.innerHTML = ""; - if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) { - return false; - } - - // Safari 3.2 caches class attributes and doesn't catch changes - div.lastChild.className = "e"; - return div.getElementsByClassName("e").length === 2; - }); - - // Check if getElementById returns elements by name - // Check if getElementsByName privileges form controls or returns elements by ID - support.getByName = assert(function( div ) { - // Inject content - div.id = expando + 0; - div.innerHTML = "
"; - docElem.insertBefore( div, docElem.firstChild ); - - // Test - var pass = doc.getElementsByName && - // buggy browsers will return fewer than the correct 2 - doc.getElementsByName( expando ).length === 2 + - // buggy browsers will return more than the correct 0 - doc.getElementsByName( expando + 0 ).length; - support.getIdNotName = !doc.getElementById( expando ); - - // Cleanup - docElem.removeChild( div ); - - return pass; - }); - - // IE6/7 return modified attributes - Expr.attrHandle = assert(function( div ) { - div.innerHTML = ""; - return div.firstChild && typeof div.firstChild.getAttribute !== strundefined && - div.firstChild.getAttribute("href") === "#"; - }) ? - {} : - { - "href": function( elem ) { - return elem.getAttribute( "href", 2 ); - }, - "type": function( elem ) { - return elem.getAttribute("type"); - } - }; - - // ID find and filter - if ( support.getIdNotName ) { - Expr.find["ID"] = function( id, context ) { - if ( typeof context.getElementById !== strundefined && !documentIsXML ) { - var m = context.getElementById( id ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - }; - Expr.filter["ID"] = function( id ) { - var attrId = id.replace( rbackslash, "" ); - return function( elem ) { - return elem.getAttribute("id") === attrId; - }; - }; - } else { - Expr.find["ID"] = function( id, context ) { - if ( typeof context.getElementById !== strundefined && !documentIsXML ) { - var m = context.getElementById( id ); - - return m ? - m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? - [m] : - undefined : - []; - } - }; - Expr.filter["ID"] = function( id ) { - var attrId = id.replace( rbackslash, "" ); - return function( elem ) { - var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); - return node && node.value === attrId; - }; - }; - } - - // Tag - Expr.find["TAG"] = support.tagNameNoComments ? - function( tag, context ) { - if ( typeof context.getElementsByTagName !== strundefined ) { - return context.getElementsByTagName( tag ); - } - } : - function( tag, context ) { - var elem, - tmp = [], - i = 0, - results = context.getElementsByTagName( tag ); - - // Filter out possible comments - if ( tag === "*" ) { - for ( ; (elem = results[i]); i++ ) { - if ( elem.nodeType === 1 ) { - tmp.push( elem ); - } - } - - return tmp; - } - return results; - }; - - // Name - Expr.find["NAME"] = support.getByName && function( tag, context ) { - if ( typeof context.getElementsByName !== strundefined ) { - return context.getElementsByName( name ); - } - }; - - // Class - Expr.find["CLASS"] = support.getByClassName && function( className, context ) { - if ( typeof context.getElementsByClassName !== strundefined && !documentIsXML ) { - return context.getElementsByClassName( className ); - } - }; - - // QSA and matchesSelector support - - // matchesSelector(:active) reports false when true (IE9/Opera 11.5) - rbuggyMatches = []; - - // qSa(:focus) reports false when true (Chrome 21), - // no need to also add to buggyMatches since matches checks buggyQSA - // A support test would require too much code (would include document ready) - rbuggyQSA = [ ":focus" ]; - - if ( (support.qsa = isNative(doc.querySelectorAll)) ) { - // Build QSA regex - // Regex strategy adopted from Diego Perini - assert(function( div ) { - // Select is set to empty string on purpose - // This is to test IE's treatment of not explictly - // setting a boolean content attribute, - // since its presence should be enough - // http://bugs.jquery.com/ticket/12359 - div.innerHTML = ""; - - // IE8 - Some boolean attributes are not treated correctly - if ( !div.querySelectorAll("[selected]").length ) { - rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" ); - } - - // Webkit/Opera - :checked should return selected option elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - // IE8 throws error here and will not see later tests - if ( !div.querySelectorAll(":checked").length ) { - rbuggyQSA.push(":checked"); - } - }); - - assert(function( div ) { - - // Opera 10-12/IE9 - ^= $= *= and empty values - // Should not select anything - div.innerHTML = "

"; - if ( div.querySelectorAll("[test^='']").length ) { - rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" ); - } - - // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) - // IE8 throws error here and will not see later tests - div.innerHTML = ""; - if ( !div.querySelectorAll(":enabled").length ) { - rbuggyQSA.push( ":enabled", ":disabled" ); - } - - // Opera 10-11 does not throw on post-comma invalid pseudos - div.querySelectorAll("*,:x"); - rbuggyQSA.push(",.*:"); - }); - } - - if ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector || - docElem.mozMatchesSelector || - docElem.webkitMatchesSelector || - docElem.oMatchesSelector || - docElem.msMatchesSelector) )) ) { - - assert(function( div ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9) - support.disconnectedMatch = matches.call( div, "div" ); - - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( div, "[test!='']:x" ); - rbuggyMatches.push( "!=", pseudos ); - }); - } - - rbuggyQSA = new RegExp( rbuggyQSA.join("|") ); - rbuggyMatches = new RegExp( rbuggyMatches.join("|") ); - - // Element contains another - // Purposefully does not implement inclusive descendent - // As in, an element does not contain itself - contains = isNative(docElem.contains) || docElem.compareDocumentPosition ? - function( a, b ) { - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - return a === bup || !!( bup && bup.nodeType === 1 && ( - adown.contains ? - adown.contains( bup ) : - a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 - )); - } : - function( a, b ) { - if ( b ) { - while ( (b = b.parentNode) ) { - if ( b === a ) { - return true; - } - } - } - return false; - }; - - // Document order sorting - sortOrder = docElem.compareDocumentPosition ? - function( a, b ) { - var compare; - - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - if ( (compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b )) ) { - if ( compare & 1 || a.parentNode && a.parentNode.nodeType === 11 ) { - if ( a === doc || contains( preferredDoc, a ) ) { - return -1; - } - if ( b === doc || contains( preferredDoc, b ) ) { - return 1; - } - return 0; - } - return compare & 4 ? -1 : 1; - } - - return a.compareDocumentPosition ? -1 : 1; - } : - function( a, b ) { - var cur, - i = 0, - aup = a.parentNode, - bup = b.parentNode, - ap = [ a ], - bp = [ b ]; - - // The nodes are identical, we can exit early - if ( a === b ) { - hasDuplicate = true; - return 0; - - // Fallback to using sourceIndex (in IE) if it's available on both nodes - } else if ( a.sourceIndex && b.sourceIndex ) { - return ( ~b.sourceIndex || MAX_NEGATIVE ) - ( contains( preferredDoc, a ) && ~a.sourceIndex || MAX_NEGATIVE ); - - // Parentless nodes are either documents or disconnected - } else if ( !aup || !bup ) { - return a === doc ? -1 : - b === doc ? 1 : - aup ? -1 : - bup ? 1 : - 0; - - // If the nodes are siblings, we can do a quick check - } else if ( aup === bup ) { - return siblingCheck( a, b ); - } - - // Otherwise we need full lists of their ancestors for comparison - cur = a; - while ( (cur = cur.parentNode) ) { - ap.unshift( cur ); - } - cur = b; - while ( (cur = cur.parentNode) ) { - bp.unshift( cur ); - } - - // Walk down the tree looking for a discrepancy - while ( ap[i] === bp[i] ) { - i++; - } - - return i ? - // Do a sibling check if the nodes have a common ancestor - siblingCheck( ap[i], bp[i] ) : - - // Otherwise nodes in our document sort first - ap[i] === preferredDoc ? -1 : - bp[i] === preferredDoc ? 1 : - 0; - }; - - // Always assume the presence of duplicates if sort doesn't - // pass them to our comparison function (as in Google Chrome). - hasDuplicate = false; - [0, 0].sort( sortOrder ); - support.detectDuplicates = hasDuplicate; - - return document; -}; - -Sizzle.matches = function( expr, elements ) { - return Sizzle( expr, window.document, null, elements ); -}; - -Sizzle.matchesSelector = function( elem, expr ) { - // Set document vars if needed - if ( elem && (( elem.ownerDocument || elem ) !== document) ) { - setDocument( elem ); - } - - // Make sure that attribute selectors are quoted - expr = expr.replace( rattributeQuotes, "='$1']" ); - - // rbuggyQSA always contains :focus, so no need for an existence check - if ( support.matchesSelector && !documentIsXML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) { - try { - var ret = matches.call( elem, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || support.disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9 - elem.document && elem.document.nodeType !== 11 ) { - return ret; - } - } catch(e) {} - } - - return Sizzle( expr, document, null, [elem] ).length > 0; -}; - -Sizzle.contains = function( context, elem ) { - // Set document vars if needed - if ( context && (( context.ownerDocument || context ) !== document) ) { - setDocument( context ); - } - return contains( context, elem ); -}; - -Sizzle.attr = function( elem, name ) { - var val; - - // Set document vars if needed - if ( elem && (( elem.ownerDocument || elem ) !== document) ) { - setDocument( elem ); - } - - if ( !documentIsXML ) { - name = name.toLowerCase(); - } - if ( (val = Expr.attrHandle[ name ]) ) { - return val( elem ); - } - if ( documentIsXML || support.attributes ) { - return elem.getAttribute( name ); - } - return ( (val = elem.getAttributeNode( name )) || elem.getAttribute( name ) ) && elem[ name ] === true ? - name : - val && val.specified ? val.value : null; -}; - -Sizzle.error = function( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); -}; - -// Document sorting and removing duplicates -Sizzle.uniqueSort = function( results ) { - var elem, - duplicates = [], - i = 1, - j = 0; - - // Unless we *know* we can detect duplicates, assume their presence - hasDuplicate = !support.detectDuplicates; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - for ( ; (elem = results[i]); i++ ) { - if ( elem === results[ i - 1 ] ) { - j = duplicates.push( i ); - } - } - while ( j-- ) { - results.splice( duplicates[ j ], 1 ); - } - } - - return results; -}; - -function siblingCheck( a, b ) { - var cur = a && b && a.nextSibling; - - for ( ; cur; cur = cur.nextSibling ) { - if ( cur === b ) { - return -1; - } - } - - return a ? 1 : -1; -} - -// Returns a function to use in pseudos for input types -function createInputPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === type; - }; -} - -// Returns a function to use in pseudos for buttons -function createButtonPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && elem.type === type; - }; -} - -// Returns a function to use in pseudos for positionals -function createPositionalPseudo( fn ) { - return markFunction(function( argument ) { - argument = +argument; - return markFunction(function( seed, matches ) { - var j, - matchIndexes = fn( [], seed.length, argument ), - i = matchIndexes.length; - - // Match elements found at the specified indexes - while ( i-- ) { - if ( seed[ (j = matchIndexes[i]) ] ) { - seed[j] = !(matches[j] = seed[j]); - } - } - }); - }); -} - -/** - * Utility function for retrieving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ -getText = Sizzle.getText = function( elem ) { - var node, - ret = "", - i = 0, - nodeType = elem.nodeType; - - if ( !nodeType ) { - // If no nodeType, this is expected to be an array - for ( ; (node = elem[i]); i++ ) { - // Do not traverse comment nodes - ret += getText( node ); - } - } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { - // Use textContent for elements - // innerText usage removed for consistency of new lines (see #11153) - if ( typeof elem.textContent === "string" ) { - return elem.textContent; - } else { - // Traverse its children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - ret += getText( elem ); - } - } - } else if ( nodeType === 3 || nodeType === 4 ) { - return elem.nodeValue; - } - // Do not include comment or processing instruction nodes - - return ret; -}; - -Expr = Sizzle.selectors = { - - // Can be adjusted by the user - cacheLength: 50, - - createPseudo: markFunction, - - match: matchExpr, - - find: {}, - - relative: { - ">": { dir: "parentNode", first: true }, - " ": { dir: "parentNode" }, - "+": { dir: "previousSibling", first: true }, - "~": { dir: "previousSibling" } - }, - - preFilter: { - "ATTR": function( match ) { - match[1] = match[1].replace( rbackslash, "" ); - - // Move the given value to match[3] whether quoted or unquoted - match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" ); - - if ( match[2] === "~=" ) { - match[3] = " " + match[3] + " "; - } - - return match.slice( 0, 4 ); - }, - - "CHILD": function( match ) { - /* matches from matchExpr["CHILD"] - 1 type (only|nth|...) - 2 what (child|of-type) - 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) - 4 xn-component of xn+y argument ([+-]?\d*n|) - 5 sign of xn-component - 6 x of xn-component - 7 sign of y-component - 8 y of y-component - */ - match[1] = match[1].toLowerCase(); - - if ( match[1].slice( 0, 3 ) === "nth" ) { - // nth-* requires argument - if ( !match[3] ) { - Sizzle.error( match[0] ); - } - - // numeric x and y parameters for Expr.filter.CHILD - // remember that false/true cast respectively to 0/1 - match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); - match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); - - // other types prohibit arguments - } else if ( match[3] ) { - Sizzle.error( match[0] ); - } - - return match; - }, - - "PSEUDO": function( match ) { - var excess, - unquoted = !match[5] && match[2]; - - if ( matchExpr["CHILD"].test( match[0] ) ) { - return null; - } - - // Accept quoted arguments as-is - if ( match[4] ) { - match[2] = match[4]; - - // Strip excess characters from unquoted arguments - } else if ( unquoted && rpseudo.test( unquoted ) && - // Get excess from tokenize (recursively) - (excess = tokenize( unquoted, true )) && - // advance to the next closing parenthesis - (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { - - // excess is a negative index - match[0] = match[0].slice( 0, excess ); - match[2] = unquoted.slice( 0, excess ); - } - - // Return only captures needed by the pseudo filter method (type and argument) - return match.slice( 0, 3 ); - } - }, - - filter: { - - "TAG": function( nodeName ) { - if ( nodeName === "*" ) { - return function() { return true; }; - } - - nodeName = nodeName.replace( rbackslash, "" ).toLowerCase(); - return function( elem ) { - return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; - }; - }, - - "CLASS": function( className ) { - var pattern = classCache[ expando ][ className + " " ]; - - return pattern || - (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && - classCache( className, function( elem ) { - return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" ); - }); - }, - - "ATTR": function( name, operator, check ) { - return function( elem ) { - var result = Sizzle.attr( elem, name ); - - if ( result == null ) { - return operator === "!="; - } - if ( !operator ) { - return true; - } - - result += ""; - - return operator === "=" ? result === check : - operator === "!=" ? result !== check : - operator === "^=" ? check && result.indexOf( check ) === 0 : - operator === "*=" ? check && result.indexOf( check ) > -1 : - operator === "$=" ? check && result.substr( result.length - check.length ) === check : - operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : - operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" : - false; - }; - }, - - "CHILD": function( type, what, argument, first, last ) { - var simple = type.slice( 0, 3 ) !== "nth", - forward = type.slice( -4 ) !== "last", - ofType = what === "of-type"; - - return first === 1 && last === 0 ? - - // Shortcut for :nth-*(n) - function( elem ) { - return !!elem.parentNode; - } : - - function( elem, context, xml ) { - var cache, outerCache, node, diff, nodeIndex, start, - dir = simple !== forward ? "nextSibling" : "previousSibling", - parent = elem.parentNode, - name = ofType && elem.nodeName.toLowerCase(), - useCache = !xml && !ofType; - - if ( parent ) { - - // :(first|last|only)-(child|of-type) - if ( simple ) { - while ( dir ) { - node = elem; - while ( (node = node[ dir ]) ) { - if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { - return false; - } - } - // Reverse direction for :only-* (if we haven't yet done so) - start = dir = type === "only" && !start && "nextSibling"; - } - return true; - } - - start = [ forward ? parent.firstChild : parent.lastChild ]; - - // non-xml :nth-child(...) stores cache data on `parent` - if ( forward && useCache ) { - // Seek `elem` from a previously-cached index - outerCache = parent[ expando ] || (parent[ expando ] = {}); - cache = outerCache[ type ] || []; - nodeIndex = cache[0] === dirruns && cache[1]; - diff = cache[0] === dirruns && cache[2]; - node = nodeIndex && parent.childNodes[ nodeIndex ]; - - while ( (node = ++nodeIndex && node && node[ dir ] || - - // Fallback to seeking `elem` from the start - (diff = nodeIndex = 0) || start.pop()) ) { - - // When found, cache indexes on `parent` and break - if ( node.nodeType === 1 && ++diff && node === elem ) { - outerCache[ type ] = [ dirruns, nodeIndex, diff ]; - break; - } - } - - // Use previously-cached element index if available - } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { - diff = cache[1]; - - // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) - } else { - // Use the same loop as above to seek `elem` from the start - while ( (node = ++nodeIndex && node && node[ dir ] || - (diff = nodeIndex = 0) || start.pop()) ) { - - if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { - // Cache the index of each encountered element - if ( useCache ) { - (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; - } - - if ( node === elem ) { - break; - } - } - } - } - - // Incorporate the offset, then check against cycle size - diff -= last; - return diff === first || ( diff % first === 0 && diff / first >= 0 ); - } - }; - }, - - "PSEUDO": function( pseudo, argument ) { - // pseudo-class names are case-insensitive - // http://www.w3.org/TR/selectors/#pseudo-classes - // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters - // Remember that setFilters inherits from pseudos - var args, - fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || - Sizzle.error( "unsupported pseudo: " + pseudo ); - - // The user may use createPseudo to indicate that - // arguments are needed to create the filter function - // just as Sizzle does - if ( fn[ expando ] ) { - return fn( argument ); - } - - // But maintain support for old signatures - if ( fn.length > 1 ) { - args = [ pseudo, pseudo, "", argument ]; - return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? - markFunction(function( seed, matches ) { - var idx, - matched = fn( seed, argument ), - i = matched.length; - while ( i-- ) { - idx = indexOf.call( seed, matched[i] ); - seed[ idx ] = !( matches[ idx ] = matched[i] ); - } - }) : - function( elem ) { - return fn( elem, 0, args ); - }; - } - - return fn; - } - }, - - pseudos: { - // Potentially complex pseudos - "not": markFunction(function( selector ) { - // Trim the selector passed to compile - // to avoid treating leading and trailing - // spaces as combinators - var input = [], - results = [], - matcher = compile( selector.replace( rtrim, "$1" ) ); - - return matcher[ expando ] ? - markFunction(function( seed, matches, context, xml ) { - var elem, - unmatched = matcher( seed, null, xml, [] ), - i = seed.length; - - // Match elements unmatched by `matcher` - while ( i-- ) { - if ( (elem = unmatched[i]) ) { - seed[i] = !(matches[i] = elem); - } - } - }) : - function( elem, context, xml ) { - input[0] = elem; - matcher( input, null, xml, results ); - return !results.pop(); - }; - }), - - "has": markFunction(function( selector ) { - return function( elem ) { - return Sizzle( selector, elem ).length > 0; - }; - }), - - "contains": markFunction(function( text ) { - return function( elem ) { - return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; - }; - }), - - // "Whether an element is represented by a :lang() selector - // is based solely on the element's language value - // being equal to the identifier C, - // or beginning with the identifier C immediately followed by "-". - // The matching of C against the element's language value is performed case-insensitively. - // The identifier C does not have to be a valid language name." - // http://www.w3.org/TR/selectors/#lang-pseudo - "lang": markFunction( function( lang ) { - // lang value must be a valid identifider - if ( !ridentifier.test(lang || "") ) { - Sizzle.error( "unsupported lang: " + lang ); - } - var rlang = new RegExp( "^" + lang.replace(rsingleBackslash, "$1\\$2") + "(?:-|$)", "i" ); - return function( elem, context, xml ) { - var elemLang; - do { - elemLang = xml && elem.getAttribute("xml:lang") || elem.getAttribute("lang"); - } while ( (elem = elem.parentNode) && elem !== context && !elemLang ); - if ( rlang.test(elemLang) ) { - return true; - } - return false; - }; - }), - - // Miscellaneous - "target": function( elem ) { - var hash = window.location && window.location.hash; - return hash && hash.slice( 1 ) === elem.id; - }, - - "root": function( elem ) { - return elem === docElem; - }, - - "focus": function( elem ) { - return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); - }, - - // Boolean properties - "enabled": function( elem ) { - return elem.disabled === false; - }, - - "disabled": function( elem ) { - return elem.disabled === true; - }, - - "checked": function( elem ) { - // In CSS3, :checked should return both checked and selected elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - var nodeName = elem.nodeName.toLowerCase(); - return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); - }, - - "selected": function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - // Contents - "empty": function( elem ) { - // http://www.w3.org/TR/selectors/#empty-pseudo - // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), - // not comment, processing instructions, or others - // Thanks to Diego Perini for the nodeName shortcut - // Greater than "@" means alpha characters (specifically not starting with "#" or "?") - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) { - return false; - } - } - return true; - }, - - "parent": function( elem ) { - return !Expr.pseudos["empty"]( elem ); - }, - - // Element/input types - "header": function( elem ) { - return rheader.test( elem.nodeName ); - }, - - "input": function( elem ) { - return rinputs.test( elem.nodeName ); - }, - - "button": function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === "button" || name === "button"; - }, - - "text": function( elem ) { - var attr; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && - elem.type === "text" && - ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type ); - }, - - // Position-in-collection - "first": createPositionalPseudo(function() { - return [ 0 ]; - }), - - "last": createPositionalPseudo(function( matchIndexes, length ) { - return [ length - 1 ]; - }), - - "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { - return [ argument < 0 ? argument + length : argument ]; - }), - - "even": createPositionalPseudo(function( matchIndexes, length ) { - var i = 0; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "odd": createPositionalPseudo(function( matchIndexes, length ) { - var i = 1; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; --i >= 0; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; ++i < length; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }) - } -}; - -// Add button/input type pseudos -for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { - Expr.pseudos[ i ] = createInputPseudo( i ); -} -for ( i in { submit: true, reset: true } ) { - Expr.pseudos[ i ] = createButtonPseudo( i ); -} - -function tokenize( selector, parseOnly ) { - var matched, match, tokens, type, - soFar, groups, preFilters, - cached = tokenCache[ expando ][ selector + " " ]; - - if ( cached ) { - return parseOnly ? 0 : cached.slice( 0 ); - } - - soFar = selector; - groups = []; - preFilters = Expr.preFilter; - - while ( soFar ) { - - // Comma and first run - if ( !matched || (match = rcomma.exec( soFar )) ) { - if ( match ) { - // Don't consume trailing commas as valid - soFar = soFar.slice( match[0].length ) || soFar; - } - groups.push( tokens = [] ); - } - - matched = false; - - // Combinators - if ( (match = rcombinators.exec( soFar )) ) { - tokens.push( matched = new Token( match.shift() ) ); - soFar = soFar.slice( matched.length ); - - // Cast descendant combinators to space - matched.type = match[0].replace( rtrim, " " ); - } - - // Filters - for ( type in Expr.filter ) { - if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || - (match = preFilters[ type ]( match ))) ) { - - tokens.push( matched = new Token( match.shift() ) ); - soFar = soFar.slice( matched.length ); - matched.type = type; - matched.matches = match; - } - } - - if ( !matched ) { - break; - } - } - - // Return the length of the invalid excess - // if we're just parsing - // Otherwise, throw an error or return tokens - return parseOnly ? - soFar.length : - soFar ? - Sizzle.error( selector ) : - // Cache the tokens - tokenCache( selector, groups ).slice( 0 ); -} - -function addCombinator( matcher, combinator, base ) { - var dir = combinator.dir, - checkNonElements = base && combinator.dir === "parentNode", - doneName = done++; - - return combinator.first ? - // Check against closest ancestor/preceding element - function( elem, context, xml ) { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - return matcher( elem, context, xml ); - } - } - } : - - // Check against all ancestor/preceding elements - function( elem, context, xml ) { - var data, cache, outerCache, - dirkey = dirruns + " " + doneName; - - // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching - if ( xml ) { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - if ( matcher( elem, context, xml ) ) { - return true; - } - } - } - } else { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - outerCache = elem[ expando ] || (elem[ expando ] = {}); - if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) { - if ( (data = cache[1]) === true || data === cachedruns ) { - return data === true; - } - } else { - cache = outerCache[ dir ] = [ dirkey ]; - cache[1] = matcher( elem, context, xml ) || cachedruns; - if ( cache[1] === true ) { - return true; - } - } - } - } - } - }; -} - -function elementMatcher( matchers ) { - return matchers.length > 1 ? - function( elem, context, xml ) { - var i = matchers.length; - while ( i-- ) { - if ( !matchers[i]( elem, context, xml ) ) { - return false; - } - } - return true; - } : - matchers[0]; -} - -function condense( unmatched, map, filter, context, xml ) { - var elem, - newUnmatched = [], - i = 0, - len = unmatched.length, - mapped = map != null; - - for ( ; i < len; i++ ) { - if ( (elem = unmatched[i]) ) { - if ( !filter || filter( elem, context, xml ) ) { - newUnmatched.push( elem ); - if ( mapped ) { - map.push( i ); - } - } - } - } - - return newUnmatched; -} - -function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { - if ( postFilter && !postFilter[ expando ] ) { - postFilter = setMatcher( postFilter ); - } - if ( postFinder && !postFinder[ expando ] ) { - postFinder = setMatcher( postFinder, postSelector ); - } - return markFunction(function( seed, results, context, xml ) { - var temp, i, elem, - preMap = [], - postMap = [], - preexisting = results.length, - - // Get initial elements from seed or context - elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), - - // Prefilter to get matcher input, preserving a map for seed-results synchronization - matcherIn = preFilter && ( seed || !selector ) ? - condense( elems, preMap, preFilter, context, xml ) : - elems, - - matcherOut = matcher ? - // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, - postFinder || ( seed ? preFilter : preexisting || postFilter ) ? - - // ...intermediate processing is necessary - [] : - - // ...otherwise use results directly - results : - matcherIn; - - // Find primary matches - if ( matcher ) { - matcher( matcherIn, matcherOut, context, xml ); - } - - // Apply postFilter - if ( postFilter ) { - temp = condense( matcherOut, postMap ); - postFilter( temp, [], context, xml ); - - // Un-match failing elements by moving them back to matcherIn - i = temp.length; - while ( i-- ) { - if ( (elem = temp[i]) ) { - matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); - } - } - } - - if ( seed ) { - if ( postFinder || preFilter ) { - if ( postFinder ) { - // Get the final matcherOut by condensing this intermediate into postFinder contexts - temp = []; - i = matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) ) { - // Restore matcherIn since elem is not yet a final match - temp.push( (matcherIn[i] = elem) ); - } - } - postFinder( null, (matcherOut = []), temp, xml ); - } - - // Move matched elements from seed to results to keep them synchronized - i = matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) && - (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { - - seed[temp] = !(results[temp] = elem); - } - } - } - - // Add elements to results, through postFinder if defined - } else { - matcherOut = condense( - matcherOut === results ? - matcherOut.splice( preexisting, matcherOut.length ) : - matcherOut - ); - if ( postFinder ) { - postFinder( null, results, matcherOut, xml ); - } else { - push.apply( results, matcherOut ); - } - } - }); -} - -function matcherFromTokens( tokens ) { - var checkContext, matcher, j, - len = tokens.length, - leadingRelative = Expr.relative[ tokens[0].type ], - implicitRelative = leadingRelative || Expr.relative[" "], - i = leadingRelative ? 1 : 0, - - // The foundational matcher ensures that elements are reachable from top-level context(s) - matchContext = addCombinator( function( elem ) { - return elem === checkContext; - }, implicitRelative, true ), - matchAnyContext = addCombinator( function( elem ) { - return indexOf.call( checkContext, elem ) > -1; - }, implicitRelative, true ), - matchers = [ function( elem, context, xml ) { - return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( - (checkContext = context).nodeType ? - matchContext( elem, context, xml ) : - matchAnyContext( elem, context, xml ) ); - } ]; - - for ( ; i < len; i++ ) { - if ( (matcher = Expr.relative[ tokens[i].type ]) ) { - matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; - } else { - matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); - - // Return special upon seeing a positional matcher - if ( matcher[ expando ] ) { - // Find the next relative operator (if any) for proper handling - j = ++i; - for ( ; j < len; j++ ) { - if ( Expr.relative[ tokens[j].type ] ) { - break; - } - } - return setMatcher( - i > 1 && elementMatcher( matchers ), - i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ), - matcher, - i < j && matcherFromTokens( tokens.slice( i, j ) ), - j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), - j < len && tokens.join("") - ); - } - matchers.push( matcher ); - } - } - - return elementMatcher( matchers ); -} - -function matcherFromGroupMatchers( elementMatchers, setMatchers ) { - // A counter to specify which element is currently being matched - var matcherCachedRuns = 0, - bySet = setMatchers.length > 0, - byElement = elementMatchers.length > 0, - superMatcher = function( seed, context, xml, results, expandContext ) { - var elem, j, matcher, - setMatched = [], - matchedCount = 0, - i = "0", - unmatched = seed && [], - outermost = expandContext != null, - contextBackup = outermostContext, - // We must always have either seed elements or context - elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), - // Nested matchers should use non-integer dirruns - dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E); - - if ( outermost ) { - outermostContext = context !== document && context; - cachedruns = matcherCachedRuns; - } - - // Add elements passing elementMatchers directly to results - for ( ; (elem = elems[i]) != null; i++ ) { - if ( byElement && elem ) { - for ( j = 0; (matcher = elementMatchers[j]); j++ ) { - if ( matcher( elem, context, xml ) ) { - results.push( elem ); - break; - } - } - if ( outermost ) { - dirruns = dirrunsUnique; - cachedruns = ++matcherCachedRuns; - } - } - - // Track unmatched elements for set filters - if ( bySet ) { - // They will have gone through all possible matchers - if ( (elem = !matcher && elem) ) { - matchedCount--; - } - - // Lengthen the array for every element, matched or not - if ( seed ) { - unmatched.push( elem ); - } - } - } - - // Apply set filters to unmatched elements - // `i` starts as a string, so matchedCount would equal "00" if there are no elements - matchedCount += i; - if ( bySet && i !== matchedCount ) { - for ( j = 0; (matcher = setMatchers[j]); j++ ) { - matcher( unmatched, setMatched, context, xml ); - } - - if ( seed ) { - // Reintegrate element matches to eliminate the need for sorting - if ( matchedCount > 0 ) { - while ( i-- ) { - if ( !(unmatched[i] || setMatched[i]) ) { - setMatched[i] = pop.call( results ); - } - } - } - - // Discard index placeholder values to get only actual matches - setMatched = condense( setMatched ); - } - - // Add matches to results - push.apply( results, setMatched ); - - // Seedless set matches succeeding multiple successful matchers stipulate sorting - if ( outermost && !seed && setMatched.length > 0 && - ( matchedCount + setMatchers.length ) > 1 ) { - - Sizzle.uniqueSort( results ); - } - } - - // Override manipulation of globals by nested matchers - if ( outermost ) { - dirruns = dirrunsUnique; - outermostContext = contextBackup; - } - - return unmatched; - }; - - return bySet ? - markFunction( superMatcher ) : - superMatcher; -} - -compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { - var i, - setMatchers = [], - elementMatchers = [], - cached = compilerCache[ expando ][ selector + " " ]; - - if ( !cached ) { - // Generate a function of recursive functions that can be used to check each element - if ( !group ) { - group = tokenize( selector ); - } - i = group.length; - while ( i-- ) { - cached = matcherFromTokens( group[i] ); - if ( cached[ expando ] ) { - setMatchers.push( cached ); - } else { - elementMatchers.push( cached ); - } - } - - // Cache the compiled function - cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); - } - return cached; -}; - -function multipleContexts( selector, contexts, results ) { - var i = 0, - len = contexts.length; - for ( ; i < len; i++ ) { - Sizzle( selector, contexts[i], results ); - } - return results; -} - -function select( selector, context, results, seed ) { - var i, tokens, token, type, find, - match = tokenize( selector ); - - if ( !seed ) { - // Try to minimize operations if there is only one group - if ( match.length === 1 ) { - - // Take a shortcut and set the context if the root selector is an ID - tokens = match[0] = match[0].slice( 0 ); - if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && - context.nodeType === 9 && !documentIsXML && - Expr.relative[ tokens[1].type ] ) { - - context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context )[0]; - if ( !context ) { - return results; - } - - selector = selector.slice( tokens.shift().length ); - } - - // Fetch a seed set for right-to-left matching - for ( i = matchExpr["needsContext"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) { - token = tokens[i]; - - // Abort if we hit a combinator - if ( Expr.relative[ (type = token.type) ] ) { - break; - } - if ( (find = Expr.find[ type ]) ) { - // Search, expanding context for leading sibling combinators - if ( (seed = find( - token.matches[0].replace( rbackslash, "" ), - rsibling.test( tokens[0].type ) && context.parentNode || context - )) ) { - - // If seed is empty or no tokens remain, we can return early - tokens.splice( i, 1 ); - selector = seed.length && tokens.join(""); - if ( !selector ) { - push.apply( results, slice.call( seed, 0 ) ); - return results; - } - - break; - } - } - } - } - } - - // Compile and execute a filtering function - // Provide `match` to avoid retokenization if we modified the selector above - compile( selector, match )( - seed, - context, - documentIsXML, - results, - rsibling.test( selector ) - ); - return results; -} - -// Deprecated -Expr.pseudos["nth"] = Expr.pseudos["eq"]; - -// Easy API for creating new setFilters -function setFilters() {} -Expr.filters = setFilters.prototype = Expr.pseudos; -Expr.setFilters = new setFilters(); - -// Initialize with the default document -setDocument(); - -// Override sizzle attribute retrieval -Sizzle.attr = jQuery.attr; -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.pseudos; -jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; - - -})( window ); -var runtil = /Until$/, - rparentsprev = /^(?:parents|prev(?:Until|All))/, - isSimple = /^.[^:#\[\.,]*$/, - rneedsContext = jQuery.expr.match.needsContext, - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - -jQuery.fn.extend({ - find: function( selector ) { - var i, ret, self; - - if ( typeof selector !== "string" ) { - self = this; - return this.pushStack( jQuery( selector ).filter(function() { - for ( i = 0; i < self.length; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - }) ); - } - - ret = []; - for ( i = 0; i < this.length; i++ ) { - jQuery.find( selector, this[ i ], ret ); - } - - // Needed because $( selector, context ) becomes $( context ).find( selector ) - ret = this.pushStack( jQuery.unique( ret ) ); - ret.selector = ( this.selector ? this.selector + " " : "" ) + selector; - return ret; - }, - - has: function( target ) { - var i, - targets = jQuery( target, this ), - len = targets.length; - - return this.filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( this, targets[i] ) ) { - return true; - } - } - }); - }, - - not: function( selector ) { - return this.pushStack( winnow(this, selector, false) ); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector, true) ); - }, - - is: function( selector ) { - return !!selector && ( - typeof selector === "string" ? - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - rneedsContext.test( selector ) ? - jQuery( selector, this.context ).index( this[0] ) >= 0 : - jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0 ); - }, - - closest: function( selectors, context ) { - var cur, - i = 0, - l = this.length, - ret = [], - pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? - jQuery( selectors, context || this.context ) : - 0; - - for ( ; i < l; i++ ) { - cur = this[i]; - - while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { - if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { - ret.push( cur ); - break; - } - cur = cur.parentNode; - } - } - - return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - - // No argument, return index in parent - if ( !elem ) { - return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; - } - - // index in selector - if ( typeof elem === "string" ) { - return jQuery.inArray( this[0], jQuery( elem ) ); - } - - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this ); - }, - - add: function( selector, context ) { - var set = typeof selector === "string" ? - jQuery( selector, context ) : - jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), - all = jQuery.merge( this.get(), set ); - - return this.pushStack( jQuery.unique(all) ); - }, - - addBack: function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter(selector) - ); - } -}); - -jQuery.fn.andSelf = jQuery.fn.addBack; - -function sibling( cur, dir ) { - do { - cur = cur[ dir ]; - } while ( cur && cur.nodeType !== 1 ); - - return cur; -} - -jQuery.each({ - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return jQuery.dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return jQuery.dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return sibling( elem, "nextSibling" ); - }, - prev: function( elem ) { - return sibling( elem, "previousSibling" ); - }, - nextAll: function( elem ) { - return jQuery.dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return jQuery.dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return jQuery.dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return jQuery.dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); - }, - children: function( elem ) { - return jQuery.sibling( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.merge( [], elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ); - - if ( !runtil.test( name ) ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } - - ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; - - if ( this.length > 1 && rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - - return this.pushStack( ret ); - }; -}); - -jQuery.extend({ - filter: function( expr, elems, not ) { - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 ? - jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : - jQuery.find.matches(expr, elems); - }, - - dir: function( elem, dir, until ) { - var matched = [], - cur = elem[ dir ]; - - while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { - if ( cur.nodeType === 1 ) { - matched.push( cur ); - } - cur = cur[dir]; - } - return matched; - }, - - sibling: function( n, elem ) { - var r = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - r.push( n ); - } - } - - return r; - } -}); - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, keep ) { - - // Can't pass null or undefined to indexOf in Firefox 4 - // Set to 0 to skip string check - qualifier = qualifier || 0; - - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep(elements, function( elem, i ) { - var retVal = !!qualifier.call( elem, i, elem ); - return retVal === keep; - }); - - } else if ( qualifier.nodeType ) { - return jQuery.grep(elements, function( elem ) { - return ( elem === qualifier ) === keep; - }); - - } else if ( typeof qualifier === "string" ) { - var filtered = jQuery.grep(elements, function( elem ) { - return elem.nodeType === 1; - }); - - if ( isSimple.test( qualifier ) ) { - return jQuery.filter(qualifier, filtered, !keep); - } else { - qualifier = jQuery.filter( qualifier, filtered ); - } - } - - return jQuery.grep(elements, function( elem ) { - return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; - }); -} -function createSafeFragment( document ) { - var list = nodeNames.split( "|" ), - safeFrag = document.createDocumentFragment(); - - if ( safeFrag.createElement ) { - while ( list.length ) { - safeFrag.createElement( - list.pop() - ); - } - } - return safeFrag; -} - -var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + - "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", - rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, - rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, - rtagName = /<([\w:]+)/, - rtbody = /\s*$/g, - wrapMap = { - option: [ 1, " -

- -

The grammar

- This Jison grammar was used to create the parser/evaluator: - -
-      
-      /* description: Parses end evaluates mathematical expressions. */
-
-      /* lexical grammar */
-      %lex
-      %%
-      \s+                   {/* skip whitespace */}
-      [0-9]+("."[0-9]+)?\b  {return 'NUMBER';}
-      "*"                   {return '*';}
-      "/"                   {return '/';}
-      "-"                   {return '-';}
-      "+"                   {return '+';}
-      "^"                   {return '^';}
-      "("                   {return '(';}
-      ")"                   {return ')';}
-      "PI"                  {return 'PI';}
-      "E"                   {return 'E';}
-      <<EOF>>               {return 'EOF';}
-
-      /lex
-
-      /* operator associations and precedence */
-
-      %left '+' '-'
-      %left '*' '/'
-      %left '^'
-      %left UMINUS
-
-      %start expressions
-
-      %% /* language grammar */
-
-      expressions
-          : e EOF
-              {return $1;}
-          ;
-
-      e
-          : e '+' e
-              {$$ = $1 + $3;}
-          | e '-' e
-              {$$ = $1 - $3;}
-          | e '*' e
-              {$$ = $1 * $3;}
-          | e '/' e
-              {$$ = $1 / $3;}
-          | e '^' e
-              {$$ = Math.pow($1, $3);}
-          | '-' e %prec UMINUS
-              {$$ = -$2;}
-          | '(' e ')'
-              {$$ = $2;}
-          | NUMBER
-              {$$ = Number(yytext);}
-          | E
-              {$$ = Math.E;}
-          | PI
-              {$$ = Math.PI;}
-          ;
-
-  
diff --git a/web/content/docs.html b/web/content/docs.html deleted file mode 100644 index 74e44087a..000000000 --- a/web/content/docs.html +++ /dev/null @@ -1,438 +0,0 @@ ---- -title: Documentation ---- -Documentation -============= - -Jison takes a context-free grammar as input and outputs a JavaScript file capable of parsing the language described by that grammar. You can then use the generated script to parse inputs and accept, reject, or perform actions based on the input. If you're familiar with Bison or Yacc, or other clones, you're almost ready to roll. - -* [Installation](#installation) -* [Usage from the command line](#usage-from-the-command-line) -* [Usage from a CommonJS Module](#usage-from-a-commonjs-module) -* [Using the Generated Parser](#using-the-generated-parser) -* [Using the Parser from the Web](#using-the-parser-from-the-web) -* [The Concepts of Jison](#the-concepts-of-jison) -* [Specifying a Language](#specifying-a-language) -* [Lexical Analysis](#lexical-analysis) -* [Tracking Locations](#tracking-locations) -* [Custom Scanners](#custom-scanners) -* [Sharing Scope](#sharing-scope) -* [Parsing algorithms](#parsing-algorithms) -* [Projects using Jison](#projects-using-jison) -* [Contributors](#contributors) -* [License](#license) - -Installation ------------- -Jison can be installed for [Node](http://nodejs.org) using [`npm`](http://github.com/isaacs/npm/) - -Using npm: - - npm install jison -g - -Usage from the command line ------------------------ - -Clone the github repository for examples: - - git clone git://github.com/zaach/jison.git - cd jison/examples - -Now you're ready to generate some parsers: - - jison calculator.jison - -This will generate `calculator.js` in your current working directory. This script can be used to parse an input file, like so: - - echo "2^32 / 1024" > testcalc - node calculator.js testcalc - -This will print out `4194304`. - -Usage from a CommonJS Module --------------------------- - -You can generate parsers programatically from JavaScript as well. Assuming Jison is in your commonjs environment's load path: - - // mygenerator.js - var Parser = require("jison").Parser; - - var grammar = { - "lex": { - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["[a-f0-9]+", "return 'HEX';"] - ] - }, - - "bnf": { - "hex_strings" :[ "hex_strings HEX", - "HEX" ] - } - }; - - var parser = new Parser(grammar); - - // generate source, ready to be written to disk - var parserSource = parser.generate(); - - // you can also use the parser directly from memory - - parser.parse("adfe34bc e82a"); - // returns true - - parser.parse("adfe34bc zxg"); - // throws lexical error - -Using the Generated Parser --------------------------- -Once you have generated the parser and saved it, you no longer need Jison or any other dependencies. - -As demonstrated before, the parser can be used from the command line: - - node calculator.js testcalc - -Though, more ideally, the parser will be a dependency of another module. You can require it from another module like so: - - // mymodule.js - var parser = require("./calculator").parser; - - function exec (input) { - return parser.parse(input); - } - - var twenty = exec("4 * 5"); - -Or more succinctly: - - // mymodule.js - function exec (input) { - return require("./calculator").parse(input); - } - - var twenty = exec("4 * 5"); - -Using the Parser from the Web ----------------------------- - -The generated parser script may be included in a web page without any need for a CommonJS loading environment. It's as simple as pointing to it via a script tag: - - - -When you generate the parser, you can specify the variable name it will be declared as: - - // mygenerator.js - var parserSource = generator.generate({moduleName: "calc"}); - // then write parserSource to a file called, say, calc.js - -Whatever `moduleName` you specified will be the the variable you can access the parser from in your web page: - - - - -The moduleName you specify can also include a namespace, e.g: - - // mygenerator.js - var parserSource = parser.generate({moduleName: "myCalculator.parser"}); - -And could be used like so: - - - - - - - -Or something like that -- you get the picture. - -A demo of the calculator script used in a web page is [here](/jison/demos/calc/). - -The Concepts of Jison ---------------------- - -Until the [Bison guide](http://dinosaur.compilertools.net/bison/bison_4.html#SEC7) is properly ported for Jison, you can refer to it for the major concepts, which are equivalent (except for the bits about static typing of semantic values, and other obvious C artifacts.) - -Other helpful sections: - -* [Bison Grammar Files](http://dinosaur.compilertools.net/bison/bison_6.html#SEC34) -* [The Bison Parser Algorithm](http://dinosaur.compilertools.net/bison/bison_8.html#SEC68) -* [Error Recovery](http://dinosaur.compilertools.net/bison/bison_9.html#SEC81) (alpha support, at this point) - -Specifying a Language ---------------------- -The process of parsing a language involves two phases: **lexical analysis** (tokenizing) and **parsing**, which the Lex/Yacc and Flex/Bison combinations are famous for. Jison lets you specify a parser much like you would using Bison/Flex, with separate files for tokenization rules and for the language grammar, or with the tokenization rules embedded in the main grammar. - -For example, here is the grammar for the calculator parser: - - /* description: Parses end executes mathematical expressions. */ - - /* lexical grammar */ - %lex - - %% - \s+ /* skip whitespace */ - [0-9]+("."[0-9]+)?\b return 'NUMBER'; - "*" return '*'; - "/" return '/'; - "-" return '-'; - "+" return '+'; - "^" return '^'; - "(" return '('; - ")" return ')'; - "PI" return 'PI'; - "E" return 'E'; - <> return 'EOF'; - - /lex - - /* operator associations and precedence */ - - %left '+' '-' - %left '*' '/' - %left '^' - %left UMINUS - - %start expressions - - %% /* language grammar */ - - expressions - : e EOF - {print($1); return $1;} - ; - - e - : e '+' e - {$$ = $1+$3;} - | e '-' e - {$$ = $1-$3;} - | e '*' e - {$$ = $1*$3;} - | e '/' e - {$$ = $1/$3;} - | e '^' e - {$$ = Math.pow($1, $3);} - | '-' e %prec UMINUS - {$$ = -$2;} - | '(' e ')' - {$$ = $2;} - | NUMBER - {$$ = Number(yytext);} - | E - {$$ = Math.E;} - | PI - {$$ = Math.PI;} - ; - - -which compiles down to this JSON representation used directly by Jison: - - { - "lex": { - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["[0-9]+(?:\\.[0-9]+)?\\b", "return 'NUMBER';"], - ["\\*", "return '*';"], - ["\\/", "return '/';"], - ["-", "return '-';"], - ["\\+", "return '+';"], - ["\\^", "return '^';"], - ["\\(", "return '(';"], - ["\\)", "return ')';"], - ["PI\\b", "return 'PI';"], - ["E\\b", "return 'E';"], - ["$", "return 'EOF';"] - ] - }, - - "operators": [ - ["left", "+", "-"], - ["left", "*", "/"], - ["left", "^"], - ["left", "UMINUS"] - ], - - "bnf": { - "expressions" :[[ "e EOF", "print($1); return $1;" ]], - - "e" :[[ "e + e", "$$ = $1 + $3;" ], - [ "e - e", "$$ = $1 - $3;" ], - [ "e * e", "$$ = $1 * $3;" ], - [ "e / e", "$$ = $1 / $3;" ], - [ "e ^ e", "$$ = Math.pow($1, $3);" ], - [ "- e", "$$ = -$2;", {"prec": "UMINUS"} ], - [ "( e )", "$$ = $2;" ], - [ "NUMBER", "$$ = Number(yytext);" ], - [ "E", "$$ = Math.E;" ], - [ "PI", "$$ = Math.PI;" ]] - } - } - -Jison accepts both the Bison/Flex style format, or the raw JSON format, e.g: - - node bin/jison examples/calculator.jison - -or - - node bin/jison examples/calculator.json - -When the lexical grammar resides in its own (.jisonlex) file, use that as the second argument to Jison, e.g.: - - node bin/jison examples/classy.jison examples/classy.jisonlex - -More examples can be found in the [`examples/`](http://github.com/zaach/jison/tree/master/examples/) and [`tests/parser/`](http://github.com/zaach/jison/tree/master/tests/parser/) directories. - -Lexical Analysis ----------------- -Jison includes a rather rudimentary scanner generator, though **any module that supports the basic scanner API could be used** in its place. - -The format of the [input file](http://dinosaur.compilertools.net/flex/flex_6.html#SEC6) (including macro support) and the style of the [pattern matchers](http://dinosaur.compilertools.net/flex/flex_7.html#SEC7) are modeled after Flex. Several [metacharacters have been added](https://github.com/zaach/jison/wiki/Deviations-From-Flex-Bison), but there is also one minor inconvenience compared to Flex patterns, namely exact string patterns must be placed in quotes e.g.: - -Bad: - - [0-9]+zomg print(yytext) - -Good: - - [0-9]+"zomg" print(yytext); - -Actions that span multiple lines should be surrounded by braces: - - [0-9]+"zomg" %{ print(yytext); - return 'ZOMG'; %} - -A recently added feature are **[start conditions](http://dinosaur.compilertools.net/flex/flex_11.html)**, which allow certain rules to only match in certain states. If the lexer is not in that state, then the rule is ignored. The lexer starts in the `INITIAL` state, but can move to new states specified by you. Read that link for the run-down. An example below shows where Jison differs, namely `this.begin('state')` instead of `BEGIN(STATE)` for changing states within an action: - - %s expect - - %% - expect-floats this.begin('expect'); - - [0-9]+"."[0-9]+ { - console.log( "found a float, = " + yytext ); - } - \n %{ - /* that's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers - */ - this.begin('INITIAL'); - %} - - [0-9]+ console.log( "found an integer, = " + yytext ); - - "." console.log( "found a dot" ); - -Additionaly, use `this.popState()` within an action to revert to the previous state. - -Using the JSON format, start conditions are defined with an array before the rule's matcher: - - { - rules: [ - [['expect'], '[0-9]+"."[0-9]+', 'console.log( "found a float, = " + yytext );'] - ] - } - -The array contains the list of start conditions for the rule. - -Tracking Locations ------------------- - -Jison's lexical analyzer will track line number and column number information for each token and make them available within parser actions. -The API is identical to [Bison's](http://www.gnu.org/software/bison/manual/html_node/Actions-and-Locations.html#Actions-and-Locations). - -Custom Scanners ---------------- - -You don't have to use the builtin Jison lexical scanner. An object with a `lex` and a `setInput` function would suffice, e.g.: - - parser.lexer = {lex: function () { return 'NIL'; }, setInput: function (str) {} } - -This lexer would simply return `NIL` tokens *ad infinitum*. - -*TODO: more examples* - -Sharing Scope ------------- - -In Bison, code is expected to be lexically defined within the scope of the semantic actions. E.g., chunks of code may be included in the generated parser source, which are available from semantic actions. - -Jison supports inline code blocks like Bison, but also exposes state that can be accessed from other modules. Instead of pulling code into the generated module, the generated module can be required and used by other modules.The parser has a `yy` property which is exposed to actions as the `yy` free variable. Any functionality attached to this property is available in both lexical and semantic actions through the `yy` free variable. - -An example from orderly.js: - - var parser = require("./orderly/parse").parser; - - // set parser's shared scope - parser.yy = require("./orderly/scope"); - - // returns the JSON object - var parse = exports.parse = function (input) { - return parser.parse(input); - }; - ... - -The `scope` module contains logic for building data structures, which is used within the semantic actions. - -Parsing algorithms ------------------- -Like Bison, Jison can recognize languages described by LALR(1) grammars, though it also has modes for LR(0), SLR(1), and LR(1). It also has a special mode for generating LL(1) parse tables (requested by my professor,) and could be extended to generate a recursive descent parser for LL(k) languages in the future. But, for now, Jison is geared toward bottom-up parsing. - -**LR(1) mode is currently not practical for use with anything other than toy grammars, but that is entirely a consequence of the algorithm used, and may change in the future.* - -Projects using Jison --------------------- -View them on the [wiki](https://github.com/zaach/jison/wiki/ProjectsUsingJison), or add your own. - -Contributors ------------- - -via [github](http://github.com/zaach/jison/contributors) - -License -------- - -> Copyright (c) 2009-2013 Zachary Carter -> -> 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. - - - [1]: http://dinosaur.compilertools.net/bison/bison_4.html diff --git a/web/content/index.html b/web/content/index.html deleted file mode 100644 index 75de54a38..000000000 --- a/web/content/index.html +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: Home ---- - - - - - - Jison - - - - - - - - -
-

Hunh?

-

- Read the documentation, see - some demos, try it online, or - install! -

-
- - - - Fork me on GitHub - - - - diff --git a/web/content/install.html b/web/content/install.html deleted file mode 100644 index 216f01b57..000000000 --- a/web/content/install.html +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: A New Item ---- - -Hi, I'm a new item! diff --git a/web/content/try.html b/web/content/try.html deleted file mode 100644 index 4a0de15c9..000000000 --- a/web/content/try.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - -
-

Try Jison Online

-

Build, test, and download your parser from the web!

-

Describe Your Language

- -

- Load an example: - -

- - -

- - -

-

-
-    
-
-
- - -
-

Test Your Parser

-
- -
-

-
-    
-
- -
-

Suggestion

-

You may also want to try the Jison USF page which includes logic to show the productions and state transition diagram. This can be very useful for debugging your grammar!

-
- - - - - - - diff --git a/web/content/try/usf.html b/web/content/try/usf.html deleted file mode 100644 index ddee5e392..000000000 --- a/web/content/try/usf.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - Jison, parse table visualation page - - - - -
-

Jison

-

Jison is a parser generator written in JavaScript. This page uses Jison to display an interactive parsing table based on the grammar and parsing algorithm chosen, which can be very helpful for debugging.

-

Special thanks to Dr. Ligatti for suggesting and giving feedback on the interface.

- -

Input

- -

Input a BNF grammar as you would with Bison. -

- -

- Load an example: - -

- - - -

- Parser type: - * WARNING: LR(1) may take considerable time to execute for large/ambigous grammars. -

-

-

- - -

Output

-

Process your grammar to see the result here.

-
-
- - -
-

Parse a program

-

Grammars with lexing information allow for parsing. Use the form below to parse a program using your grammar:

-
- -

Result

- -
- -
- -

- Zach Carter (zcarter@mail.usf.edu) 2009 -

- -
- - - - - - - - diff --git a/web/jison/examples/ansic.jison b/web/jison/examples/ansic.jison deleted file mode 100644 index 092ae5568..000000000 --- a/web/jison/examples/ansic.jison +++ /dev/null @@ -1,415 +0,0 @@ -%token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF -%token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP -%token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN -%token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN -%token XOR_ASSIGN OR_ASSIGN TYPE_NAME - -%token TYPEDEF EXTERN STATIC AUTO REGISTER -%token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID -%token STRUCT UNION ENUM ELLIPSIS - -%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN - -%start translation_unit -%% - -primary_expression - : IDENTIFIER - | CONSTANT - | STRING_LITERAL - | '(' expression ')' - ; - -postfix_expression - : primary_expression - | postfix_expression '[' expression ']' - | postfix_expression '(' ')' - | postfix_expression '(' argument_expression_list ')' - | postfix_expression '.' IDENTIFIER - | postfix_expression PTR_OP IDENTIFIER - | postfix_expression INC_OP - | postfix_expression DEC_OP - ; - -argument_expression_list - : assignment_expression - | argument_expression_list ',' assignment_expression - ; - -unary_expression - : postfix_expression - | INC_OP unary_expression - | DEC_OP unary_expression - | unary_operator cast_expression - | SIZEOF unary_expression - | SIZEOF '(' type_name ')' - ; - -unary_operator - : '&' - | '*' - | '+' - | '-' - | '~' - | '!' - ; - -cast_expression - : unary_expression - | '(' type_name ')' cast_expression - ; - -multiplicative_expression - : cast_expression - | multiplicative_expression '*' cast_expression - | multiplicative_expression '/' cast_expression - | multiplicative_expression '%' cast_expression - ; - -additive_expression - : multiplicative_expression - | additive_expression '+' multiplicative_expression - | additive_expression '-' multiplicative_expression - ; - -shift_expression - : additive_expression - | shift_expression LEFT_OP additive_expression - | shift_expression RIGHT_OP additive_expression - ; - -relational_expression - : shift_expression - | relational_expression '<' shift_expression - | relational_expression '>' shift_expression - | relational_expression LE_OP shift_expression - | relational_expression GE_OP shift_expression - ; - -equality_expression - : relational_expression - | equality_expression EQ_OP relational_expression - | equality_expression NE_OP relational_expression - ; - -and_expression - : equality_expression - | and_expression '&' equality_expression - ; - -exclusive_or_expression - : and_expression - | exclusive_or_expression '^' and_expression - ; - -inclusive_or_expression - : exclusive_or_expression - | inclusive_or_expression '|' exclusive_or_expression - ; - -logical_and_expression - : inclusive_or_expression - | logical_and_expression AND_OP inclusive_or_expression - ; - -logical_or_expression - : logical_and_expression - | logical_or_expression OR_OP logical_and_expression - ; - -conditional_expression - : logical_or_expression - | logical_or_expression '?' expression ':' conditional_expression - ; - -assignment_expression - : conditional_expression - | unary_expression assignment_operator assignment_expression - ; - -assignment_operator - : '=' - | MUL_ASSIGN - | DIV_ASSIGN - | MOD_ASSIGN - | ADD_ASSIGN - | SUB_ASSIGN - | LEFT_ASSIGN - | RIGHT_ASSIGN - | AND_ASSIGN - | XOR_ASSIGN - | OR_ASSIGN - ; - -expression - : assignment_expression - | expression ',' assignment_expression - ; - -constant_expression - : conditional_expression - ; - -declaration - : declaration_specifiers ';' - | declaration_specifiers init_declarator_list ';' - ; - -declaration_specifiers - : storage_class_specifier - | storage_class_specifier declaration_specifiers - | type_specifier - | type_specifier declaration_specifiers - | type_qualifier - | type_qualifier declaration_specifiers - ; - -init_declarator_list - : init_declarator - | init_declarator_list ',' init_declarator - ; - -init_declarator - : declarator - | declarator '=' initializer - ; - -storage_class_specifier - : TYPEDEF - | EXTERN - | STATIC - | AUTO - | REGISTER - ; - -type_specifier - : VOID - | CHAR - | SHORT - | INT - | LONG - | FLOAT - | DOUBLE - | SIGNED - | UNSIGNED - | struct_or_union_specifier - | enum_specifier - | TYPE_NAME - ; - -struct_or_union_specifier - : struct_or_union IDENTIFIER '{' struct_declaration_list '}' - | struct_or_union '{' struct_declaration_list '}' - | struct_or_union IDENTIFIER - ; - -struct_or_union - : STRUCT - | UNION - ; - -struct_declaration_list - : struct_declaration - | struct_declaration_list struct_declaration - ; - -struct_declaration - : specifier_qualifier_list struct_declarator_list ';' - ; - -specifier_qualifier_list - : type_specifier specifier_qualifier_list - | type_specifier - | type_qualifier specifier_qualifier_list - | type_qualifier - ; - -struct_declarator_list - : struct_declarator - | struct_declarator_list ',' struct_declarator - ; - -struct_declarator - : declarator - | ':' constant_expression - | declarator ':' constant_expression - ; - -enum_specifier - : ENUM '{' enumerator_list '}' - | ENUM IDENTIFIER '{' enumerator_list '}' - | ENUM IDENTIFIER - ; - -enumerator_list - : enumerator - | enumerator_list ',' enumerator - ; - -enumerator - : IDENTIFIER - | IDENTIFIER '=' constant_expression - ; - -type_qualifier - : CONST - | VOLATILE - ; - -declarator - : pointer direct_declarator - | direct_declarator - ; - -direct_declarator - : IDENTIFIER - | '(' declarator ')' - | direct_declarator '[' constant_expression ']' - | direct_declarator '[' ']' - | direct_declarator '(' parameter_type_list ')' - | direct_declarator '(' identifier_list ')' - | direct_declarator '(' ')' - ; - -pointer - : '*' - | '*' type_qualifier_list - | '*' pointer - | '*' type_qualifier_list pointer - ; - -type_qualifier_list - : type_qualifier - | type_qualifier_list type_qualifier - ; - - -parameter_type_list - : parameter_list - | parameter_list ',' ELLIPSIS - ; - -parameter_list - : parameter_declaration - | parameter_list ',' parameter_declaration - ; - -parameter_declaration - : declaration_specifiers declarator - | declaration_specifiers abstract_declarator - | declaration_specifiers - ; - -identifier_list - : IDENTIFIER - | identifier_list ',' IDENTIFIER - ; - -type_name - : specifier_qualifier_list - | specifier_qualifier_list abstract_declarator - ; - -abstract_declarator - : pointer - | direct_abstract_declarator - | pointer direct_abstract_declarator - ; - -direct_abstract_declarator - : '(' abstract_declarator ')' - | '[' ']' - | '[' constant_expression ']' - | direct_abstract_declarator '[' ']' - | direct_abstract_declarator '[' constant_expression ']' - | '(' ')' - | '(' parameter_type_list ')' - | direct_abstract_declarator '(' ')' - | direct_abstract_declarator '(' parameter_type_list ')' - ; - -initializer - : assignment_expression - | '{' initializer_list '}' - | '{' initializer_list ',' '}' - ; - -initializer_list - : initializer - | initializer_list ',' initializer - ; - -statement - : labeled_statement - | compound_statement - | expression_statement - | selection_statement - | iteration_statement - | jump_statement - ; - -labeled_statement - : IDENTIFIER ':' statement - | CASE constant_expression ':' statement - | DEFAULT ':' statement - ; - -compound_statement - : '{' '}' - | '{' statement_list '}' - | '{' declaration_list '}' - | '{' declaration_list statement_list '}' - ; - -declaration_list - : declaration - | declaration_list declaration - ; - -statement_list - : statement - | statement_list statement - ; - -expression_statement - : ';' - | expression ';' - ; - -selection_statement - : IF '(' expression ')' statement - | IF '(' expression ')' statement ELSE statement - | SWITCH '(' expression ')' statement - ; - -iteration_statement - : WHILE '(' expression ')' statement - | DO statement WHILE '(' expression ')' ';' - | FOR '(' expression_statement expression_statement ')' statement - | FOR '(' expression_statement expression_statement expression ')' statement - ; - -jump_statement - : GOTO IDENTIFIER ';' - | CONTINUE ';' - | BREAK ';' - | RETURN ';' - | RETURN expression ';' - ; - -translation_unit - : external_declaration - | translation_unit external_declaration - ; - -external_declaration - : function_definition - | declaration - ; - -function_definition - : declaration_specifiers declarator declaration_list compound_statement - | declaration_specifiers declarator compound_statement - | declarator declaration_list compound_statement - | declarator compound_statement - ; diff --git a/web/jison/examples/basic.jison b/web/jison/examples/basic.jison deleted file mode 100644 index c23c801e0..000000000 --- a/web/jison/examples/basic.jison +++ /dev/null @@ -1,11 +0,0 @@ -%% - -E - : E PLUS T - | T - ; - -T - : ZERO - ; - diff --git a/web/jison/examples/basic2.jison b/web/jison/examples/basic2.jison deleted file mode 100644 index f47e179e9..000000000 --- a/web/jison/examples/basic2.jison +++ /dev/null @@ -1,10 +0,0 @@ - -/* description: Basic grammar that contains a nullable A nonterminal. */ - -%% - -A - : A x - | - ; - diff --git a/web/jison/examples/basic2_lex.json b/web/jison/examples/basic2_lex.json deleted file mode 100644 index b542fb6bd..000000000 --- a/web/jison/examples/basic2_lex.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "comment": "Basic grammar that contains a nullable A nonterminal.", - - "lex": { - "rules": [ - ["x", "return 'x';"] - ] - }, - - "tokens": "x", - "bnf": { - "A" :[ "A x", - "" ] - } -} diff --git a/web/jison/examples/classy.json b/web/jison/examples/classy.json deleted file mode 100644 index 11a79133a..000000000 --- a/web/jison/examples/classy.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "comment": "ClassyLang grammar. Very classy.", - "author": "Zach Carter", - - "lex": { - "macros": { - "digit": "[0-9]", - "id": "[a-zA-Z][a-zA-Z0-9]*" - }, - - "rules": [ - ["//.*", "/* ignore comment */"], - ["main\\b", "return 'MAIN';"], - ["class\\b", "return 'CLASS';"], - ["extends\\b", "return 'EXTENDS';"], - ["nat\\b", "return 'NATTYPE';"], - ["if\\b", "return 'IF';"], - ["else\\b", "return 'ELSE';"], - ["for\\b", "return 'FOR';"], - ["printNat\\b", "return 'PRINTNAT';"], - ["readNat\\b", "return 'READNAT';"], - ["this\\b", "return 'THIS';"], - ["new\\b", "return 'NEW';"], - ["var\\b", "return 'VAR';"], - ["null\\b", "return 'NUL';"], - ["{digit}+", "return 'NATLITERAL';"], - ["{id}", "return 'ID';"], - ["==", "return 'EQUALITY';"], - ["=", "return 'ASSIGN';"], - ["\\+", "return 'PLUS';"], - ["-", "return 'MINUS';"], - ["\\*", "return 'TIMES';"], - [">", "return 'GREATER';"], - ["\\|\\|", "return 'OR';"], - ["!", "return 'NOT';"], - ["\\.", "return 'DOT';"], - ["\\{", "return 'LBRACE';"], - ["\\}", "return 'RBRACE';"], - ["\\(", "return 'LPAREN';"], - ["\\)", "return 'RPAREN';"], - [";", "return 'SEMICOLON';"], - ["\\s+", "/* skip whitespace */"], - [".", "throw 'Illegal character: '+yytext;"], - ["$", "return 'ENDOFFILE';"] - ] - }, - - "tokens": "MAIN CLASS EXTENDS NATTYPE IF ELSE FOR PRINTNAT READNAT THIS NEW VAR NUL NATLITERAL ID ASSIGN PLUS MINUS TIMES EQUALITY GREATER OR NOT DOT SEMICOLON LBRACE RBRACE LPAREN RPAREN ENDOFFILE", - "operators": [ - ["right", "ASSIGN"], - ["left", "OR"], - ["nonassoc", "EQUALITY", "GREATER"], - ["left", "PLUS", "MINUS"], - ["left", "TIMES"], - ["right", "NOT"], - ["left", "DOT"] - ], - - "bnf": { - "pgm": ["cdl MAIN LBRACE vdl el RBRACE ENDOFFILE"], - - "cdl": ["c cdl", - ""], - - "c": ["CLASS id EXTENDS id LBRACE vdl mdl RBRACE"], - - "vdl": ["VAR t id SEMICOLON vdl", - ""], - - "mdl": ["t id LPAREN t id RPAREN LBRACE vdl el RBRACE mdl", - ""], - - "t": ["NATTYPE", - "id"], - - "id": ["ID"], - - "el": ["e SEMICOLON el", - "e SEMICOLON"], - - "e": ["NATLITERAL", - "NUL", - "id", - "NEW id", - "THIS", - "IF LPAREN e RPAREN LBRACE el RBRACE ELSE LBRACE el RBRACE", - "FOR LPAREN e SEMICOLON e SEMICOLON e RPAREN LBRACE el RBRACE", - "READNAT LPAREN RPAREN", - "PRINTNAT LPAREN e RPAREN", - "e PLUS e", - "e MINUS e", - "e TIMES e", - "e EQUALITY e", - "e GREATER e", - "NOT e", - "e OR e", - "e DOT id", - "id ASSIGN e", - "e DOT id ASSIGN e", - "id LPAREN e RPAREN", - "e DOT id LPAREN e RPAREN", - "LPAREN e RPAREN"] - } -} - diff --git a/web/jison/examples/classy_ast.json b/web/jison/examples/classy_ast.json deleted file mode 100644 index d0e4b08b4..000000000 --- a/web/jison/examples/classy_ast.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "comment": "ClassyLang grammar with AST-building actions. Very classy.", - "author": "Zach Carter", - "lex": { - "macros": { - "digit": "[0-9]", - "id": "[a-zA-Z][a-zA-Z0-9]*" - }, - - "rules": [ - ["//.*", "/* ignore comment */"], - ["main\\b", "return 'MAIN';"], - ["class\\b", "return 'CLASS';"], - ["extends\\b", "return 'EXTENDS';"], - ["nat\\b", "return 'NATTYPE';"], - ["if\\b", "return 'IF';"], - ["else\\b", "return 'ELSE';"], - ["for\\b", "return 'FOR';"], - ["printNat\\b", "return 'PRINTNAT';"], - ["readNat\\b", "return 'READNAT';"], - ["this\\b", "return 'THIS';"], - ["new\\b", "return 'NEW';"], - ["var\\b", "return 'VAR';"], - ["null\\b", "return 'NUL';"], - ["{digit}+", "return 'NATLITERAL';"], - ["{id}", "return 'ID';"], - ["==", "return 'EQUALITY';"], - ["=", "return 'ASSIGN';"], - ["\\+", "return 'PLUS';"], - ["-", "return 'MINUS';"], - ["\\*", "return 'TIMES';"], - [">", "return 'GREATER';"], - ["\\|\\|", "return 'OR';"], - ["!", "return 'NOT';"], - ["\\.", "return 'DOT';"], - ["\\{", "return 'LBRACE';"], - ["\\}", "return 'RBRACE';"], - ["\\(", "return 'LPAREN';"], - ["\\)", "return 'RPAREN';"], - [";", "return 'SEMICOLON';"], - ["\\s+", "/* skip whitespace */"], - [".", "throw 'Illegal character: '+yytext;"], - ["$", "return 'ENDOFFILE';"] - ] - }, - - "tokens": "MAIN CLASS EXTENDS NATTYPE IF ELSE FOR PRINTNAT READNAT THIS NEW VAR NUL NATLITERAL ID ASSIGN PLUS MINUS TIMES EQUALITY GREATER OR NOT DOT SEMICOLON LBRACE RBRACE LPAREN RPAREN ENDOFFILE", - "operators": [ - ["right", "ASSIGN"], - ["left", "OR"], - ["nonassoc", "EQUALITY", "GREATER"], - ["left", "PLUS", "MINUS"], - ["left", "TIMES"], - ["right", "NOT"], - ["left", "DOT"] - ], - - "bnf": { - "pgm": [["cdl MAIN LBRACE vdl el RBRACE ENDOFFILE", - "$$ = ['PROGRAM',{},$1,$4,$5]; return $$;"]], - - "cdl": [["c cdl", - "$$ = prependChild($2, $1);"], - ["", - "$$ = ['CLASS_DECL_LIST',{}];"]], - - "c": [["CLASS id EXTENDS id LBRACE vdl mdl RBRACE", - "$$ = ['CLASS_DECL',{},$2,$4,$6,$7];"]], - - "vdl": [["VAR t id SEMICOLON vdl", - "$$ = prependChild($5, ['VAR_DECL',{},$2,$3]);"], - ["", - "$$ = ['VAR_DECL_LIST',{}];"]], - - "mdl": [["t id LPAREN t id RPAREN LBRACE vdl el RBRACE mdl", - "$$ = prependChild($11, ['METHOD_DECL',{},$1,$2,$4,$5,$8,$9]);"], - ["", - "$$ = ['METHOD_DECL_LIST',{}];"]], - - "t": [["NATTYPE", - "$$ = ['NAT_TYPE',{}];"], - ["id", - "$$ = $1"]], - - "id": [["ID", - "$$ = ['AST_ID',{val:yytext}]"]], - "el": [["e SEMICOLON el", - "$$ = prependChild($3, $1);"], - ["e SEMICOLON", - "$$ = ['EXPR_LIST',{},$1];"]], - - "e": [["NATLITERAL", "$$ = ['NAT_LITERAL_EXPR',{val:parseInt(yytext)}];"], - ["NUL", "$$ = ['NULL_EXPR',{}];"], - ["id", "$$ = ['ID_EXPR',{},$1];"], - ["NEW id", "$$ = ['NEW_EXPR',{},$2];"], - ["THIS", "$$ = ['THIS_EXPR',{}];"], - ["IF LPAREN e RPAREN LBRACE el RBRACE ELSE LBRACE el RBRACE", - "$$ = ['IF_THEN_ELSE_EXPR',{},$3,$6,$10];"], - ["FOR LPAREN e SEMICOLON e SEMICOLON e RPAREN LBRACE el RBRACE", - "$$ = ['FOR_EXPR',{},$3,$5,$7,$10];"], - ["READNAT LPAREN RPAREN", - "$$ = ['READ_EXPR',{}];"], - ["PRINTNAT LPAREN e RPAREN", - "$$ = ['PRINT_EXPR',{},$3];"], - ["e PLUS e", "$$ = ['PLUS_EXPR',{},$1,$3];"], - ["e MINUS e", "$$ = ['MINUS_EXPR',{},$1,$3];"], - ["e TIMES e", "$$ = ['TIMES_EXPR',{},$1,$3];"], - ["e EQUALITY e", "$$ = ['EQUALITY_EXPR',{},$1,$3];"], - ["e GREATER e", "$$ = ['GREATER_THAN_EXPR',{},$1,$3];"], - ["NOT e", "$$ = ['NOT_EXPR',{},$2];"], - ["e OR e", "$$ = ['OR_EXPR',{},$1,$3];"], - ["e DOT id", "$$ = ['DOT_ID_EXPR',{},$1,$3];"], - ["id ASSIGN e", "$$ = ['ASSIGN_EXPR',{},$1,$3];"], - ["e DOT id ASSIGN e", - "$$ = ['DOT_ASSIGN_EXPR',{},$1,$3,$5];"], - ["id LPAREN e RPAREN", - "$$ = ['METHOD_CALL_EXPR',{},$1,$3];"], - ["e DOT id LPAREN e RPAREN", - "$$ = ['DOT_METHOD_CALL_EXPR',{},$1,$3,$5];"], - ["LPAREN e RPAREN", - "$$ = $2;"]] - }, - - "actionInclude": "function prependChild(node, child){ node.splice(2,0,child); return node; }" -} - diff --git a/web/jison/examples/dism.jison b/web/jison/examples/dism.jison deleted file mode 100644 index e6c913195..000000000 --- a/web/jison/examples/dism.jison +++ /dev/null @@ -1,39 +0,0 @@ - -/* author: Jay Ligatti */ - -%% - -pgm - : instlist - ; - -instlist - : label COLON inst instlist - | inst instlist - | - ; - -inst - : ADD intt intt intt - | SUB intt intt intt - | MUL intt intt intt - | MOV intt intt - | LOD intt intt intt - | STR intt intt intt - | JMP intt intt intt - | BEQ intt intt intt - | BLT intt intt intt - | RDN intt - | PTN intt - | HLT intt - ; - -label - : LABEL - ; - -intt - : INT - | label - ; - diff --git a/web/jison/examples/dism_lr0.jison b/web/jison/examples/dism_lr0.jison deleted file mode 100644 index 74cbe5dbd..000000000 --- a/web/jison/examples/dism_lr0.jison +++ /dev/null @@ -1,35 +0,0 @@ - -/* author: Jay Ligatti */ - -%% - -instlist - : instlist label COLON inst - | instlist inst - | inst - ; - -inst - : ADD intt intt intt - | SUB intt intt intt - | MUL intt intt intt - | MOV intt intt - | LOD intt intt intt - | STR intt intt intt - | JMP intt intt intt - | BEQ intt intt intt - | BLT intt intt intt - | RDN intt - | PTN intt - | HLT intt - ; - -label - : LABEL - ; - -intt - : INT - | label - ; - diff --git a/web/jison/examples/json.js b/web/jison/examples/json.js deleted file mode 100644 index a2bbf51e1..000000000 --- a/web/jison/examples/json.js +++ /dev/null @@ -1,87 +0,0 @@ -var Parser = require("jison").Parser; -var system = require("system"); -var fs = require("file"); - -exports.grammar = { - "comment": "ECMA-262 5th Edition, 15.12.1 The JSON Grammar.", - "author": "Zach Carter", - - "lex": { - "macros": { - "digit": "[0-9]", - "exp": "([eE][-+]?{digit}+)" - }, - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["-?{digit}+(\\.{digit}+)?{exp}?", "return 'NUMBER';"], - ["\"[^\"]*", function(){ - if(yytext.charAt(yyleng-1) == '\\') { - // remove escape - yytext = yytext.substr(0,yyleng-2); - this.more(); - } else { - yytext = yytext.substr(1); // swallow start quote - this.input(); // swallow end quote - return "STRING"; - } - }], - ["\\{", "return '{'"], - ["\\}", "return '}'"], - ["\\[", "return '['"], - ["\\]", "return ']'"], - [",", "return ','"], - [":", "return ':'"], - ["true\\b", "return 'TRUE'"], - ["false\\b", "return 'FALSE'"], - ["null\\b", "return 'NULL'"] - ] - }, - - "tokens": "STRING NUMBER { } [ ] , : TRUE FALSE NULL", - "start": "JSONText", - - "bnf": { - "JSONString": [ "STRING" ], - - "JSONNumber": [ "NUMBER" ], - - "JSONBooleanLiteral": [ "TRUE", "FALSE" ], - - - "JSONText": [ "JSONValue" ], - - "JSONValue": [ "JSONNullLiteral", - "JSONBooleanLiteral", - "JSONString", - "JSONNumber", - "JSONObject", - "JSONArray" ], - - "JSONObject": [ "{ }", - "{ JSONMemberList }" ], - - "JSONMember": [ "JSONString : JSONValue" ], - - "JSONMemberList": [ "JSONMember", - "JSONMemberList , JSONMember" ], - - "JSONArray": [ "[ ]", - "[ JSONElementList ]" ], - - "JSONElementList": [ "JSONValue", - "JSONElementList , JSONValue" ] - } -}; - -var options = {type: "slr", moduleType: "commonjs", moduleName: "jsoncheck"}; - -exports.main = function main (args) { - var cwd = fs.path(fs.cwd()), - code = new Parser(exports.grammar, options).generate(), - stream = cwd.join(options.moduleName+".js").open("w"); - stream.print(code).close(); -}; - -if (require.main === module.id) - exports.main(system.args); - diff --git a/web/jison/examples/jsonAST.js b/web/jison/examples/jsonAST.js deleted file mode 100644 index ad30ef997..000000000 --- a/web/jison/examples/jsonAST.js +++ /dev/null @@ -1,90 +0,0 @@ -var Parser = require("jison").Parser; -var system = require("system"); -var fs = require("file"); - -exports.grammar = { - "comment": "ECMA-262 5th Edition, 15.12.1 The JSON Grammar. (Incomplete implementation)", - "author": "Zach Carter", - - "lex": { - "macros": { - "digit": "[0-9]", - "exp": "([eE][-+]?{digit}+)" - }, - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["-?{digit}+(\\.{digit}+)?{exp}?", "return 'NUMBER';"], - ["\"[^\"]*", function () { - if (yytext.charAt(yyleng-1) == '\\') { - // remove escape - yytext = yytext.substr(0,yyleng-2); - this.more(); - } else { - yytext = yytext.substr(1); // swallow start quote - this.input(); // swallow end quote - return "STRING"; - } - }], - ["\\{", "return '{'"], - ["\\}", "return '}'"], - ["\\[", "return '['"], - ["\\]", "return ']'"], - [",", "return ','"], - [":", "return ':'"], - ["true\\b", "return 'TRUE'"], - ["false\\b", "return 'FALSE'"], - ["null\\b", "return 'NULL'"] - ] - }, - - "tokens": "STRING NUMBER { } [ ] , : TRUE FALSE NULL", - "start": "JSONText", - - "bnf": { - "JSONString": [[ "STRING", "$$ = yytext;" ]], - - "JSONNumber": [[ "NUMBER", "$$ = Number(yytext);" ]], - - "JSONNullLiteral": [[ "NULL", "$$ = null;" ]], - - "JSONBooleanLiteral": [[ "TRUE", "$$ = true;" ], - [ "FALSE", "$$ = false;" ]], - - - "JSONText": [[ "JSONValue", "return $$ = $1;" ]], - - "JSONValue": [[ "JSONNullLiteral", "$$ = $1;" ], - [ "JSONBooleanLiteral", "$$ = $1;" ], - [ "JSONString", "$$ = $1;" ], - [ "JSONNumber", "$$ = $1;" ], - [ "JSONObject", "$$ = $1;" ], - [ "JSONArray", "$$ = $1;" ]], - - "JSONObject": [[ "{ }", "$$ = {};" ], - [ "{ JSONMemberList }", "$$ = $2;" ]], - - "JSONMember": [[ "JSONString : JSONValue", "$$ = [$1, $3];" ]], - - "JSONMemberList": [[ "JSONMember", "$$ = {}; $$[$1[0]] = $1[1];" ], - [ "JSONMemberList , JSONMember", "$$ = $1; $1[$3[0]] = $3[1];" ]], - - "JSONArray": [[ "[ ]", "$$ = [];" ], - [ "[ JSONElementList ]", "$$ = $2;" ]], - - "JSONElementList": [[ "JSONValue", "$$ = [$1];" ], - [ "JSONElementList , JSONValue", "$$ = $1; $1.push($3);" ]] - } -}; - -var options = {type: "slr", moduleType: "commonjs", moduleName: "jsonparse"}; - -exports.main = function main (args) { - var cwd = fs.path(fs.cwd()), - code = new Parser(exports.grammar, options).generate(), - stream = cwd.join(options.moduleName+".js").open("w"); - stream.print(code).close(); -}; - -if (require.main === module.id) - exports.main(system.args); - diff --git a/web/jison/examples/precedence.jison b/web/jison/examples/precedence.jison deleted file mode 100644 index 55356dac6..000000000 --- a/web/jison/examples/precedence.jison +++ /dev/null @@ -1,24 +0,0 @@ - -/* description: Grammar showing precedence operators and semantic actions. */ - -%left '+' '-' -%left '*' - -%% - -S - : e EOF - {return $1;} - ; - -e - : e '+' e - {$$ = [$1,'+', $3];} - | e '-' e - {$$ = [$1,'-', $3];} - | e '*' e - {$$ = [$1, '*', $3];} - | NAT - {$$ = parseInt(yytext);} - ; - diff --git a/web/jison/examples/reduce_conflict.jison b/web/jison/examples/reduce_conflict.jison deleted file mode 100644 index baed52b34..000000000 --- a/web/jison/examples/reduce_conflict.jison +++ /dev/null @@ -1,23 +0,0 @@ - -/* description: Produces a reduce-reduce conflict unless using LR(1). */ - - -%start S - -%% - -S - : a A c - | a B d - | b A d - | b B c - ; - -A - : z - ; - -B - : z - ; - diff --git a/web/jison/index.html b/web/jison/index.html deleted file mode 100644 index b13a7c0f4..000000000 --- a/web/jison/index.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - Jison, parse table visualation page - - - - - - - - - - - - - - - - - -
-
-

Jison is a parser generator written in JavaScript. This page uses Jison to display an interactive parsing table based on the grammar and parsing algorithm chosen, which can be very helpful for debugging.

-
-

Special thanks to Dr. Ligatti for suggesting and giving feedback on the initial interface.

- -

Input

- -

Input a BNF grammar along with a token list and optional start symbol, in JSON format. -

- -

- Load an example: - -

- - - -

- Parser type: - * WARNING: LR(1) may take considerable time to execute for large/ambigous grammars. -

-

-

- - -

Output

-

Process your grammar to see the result here.

-
-
- - -
-

Parse a program

-

Grammars with lexing information allow for parsing. Use the form below to parse a program using your grammar:

-
- -

Result

- -
- -
- -

- Zach Carter (zcarter@mail.usf.edu) 2009 -

- -
- - diff --git a/web/jison/main.js b/web/jison/main.js deleted file mode 100644 index 98a1dba1e..000000000 --- a/web/jison/main.js +++ /dev/null @@ -1,249 +0,0 @@ -var parser, - parser2; - -if(typeof console === 'undefined'){ - console = {}; - console.log = function(str){document.getElementById("out").value = uneval(str)}; -} -var printOut = function(str){document.getElementById("out").value = JSON.stringify(str)}; - -$(function () { - - $("#process_btn").click(processGrammar); - $("#parse_btn").click(runParser); - - $(".action, .state").on("click", function (ev){ - if (!$(ev.target).is("a")) - $(this).toggleClass("open"); - }); - - $(".action, .state").on("dblclick", function (ev){ - var row = this.className.match(/(row_[0-9]+)/)[1]; - $(this).hasClass("open") ? - $("."+row).removeClass("open") : - $("."+row).addClass("open"); - return false; - }); - - $("#examples").change(function(ev) { - var file = this.options[this.selectedIndex].value; - $(document.body).addClass("loading"); - $.get("examples/"+file, function (data) { - $("#grammar").val(data); - $(document.body).removeClass("loading"); - }); - }); - -}); - -function processGrammar () { - var type = $("#type")[0].options[$("#type")[0].selectedIndex].value || "slr"; - - var grammar = $("#grammar").val(); - try { - var cfg = JSON.parse(grammar); - } catch(e) { - try { - var cfg = bnf.parse(grammar); - } catch (e) { - return alert("Oops. Make sure your grammar is in the correct format.\n"+e); - } - } - - if (cfg.lex) $("#parsing").show(); - else $("#parsing").hide(); - - Jison.print = function () {}; - parser = new Jison.Generator(cfg, {type: type,noDefaultResolve:true}); - if (parser.computeLookaheads) - parser.computeLookaheads(); - - $("#out").val(''); - - nonterminalInfo(parser); - productions(parser); - - if (type === 'll') - llTable(parser); - else - lrTable(parser); -} - -function runParser () { - if (!parser) processGrammer(); - if (!parser2) parser2 = parser.createParser(); - printOut("Parsing..."); - var source = $("#source").val(); - try { - printOut(parser2.parse(source)); - } catch(e) { - printOut(e.message || e); - } -} - -function nonterminalInfo (p){ - var out = ["

Nonterminals

"]; - for(var nt in p.nonterminals){ - out.push("
",nt,"
"); - out.push("
", "nullable: "+(p.nonterminals[nt].nullable ? 'Yes':'No')+"
firsts: "+p.nonterminals[nt].first+"
follows: "+p.nonterminals[nt].follows); - out.push("

Productions: "); - p.nonterminals[nt].productions.forEach(function (prod) { - out.push(''+prod.id+''); - }); - out.push("

"); - } - out.push("
"); - $("#nonterminals").html(out.join("\n")); -} - -function productions (p){ - var out = ['
    ']; - p.productions.forEach(function (prod) { - out.push("
  1. ", prod, "
  2. "); - }); - out.push('
'); - $("#productions").html("

Productions

"+out.join("")); -} - - -function printCell (cell){ - var out = cell.join(","); - - out += "
"; - for (var i=0;i"; - out += "
"; - - return out; -} - -function llTable (p){ - var out = ['','','']; - out.push(''); - p.terminals.forEach(function(t){ - out.push(''); - }); - out.push('', ''); - - for (var nt in p.table){ - out.push(''); - p.terminals.forEach(function(t){ - var cell = p.table[nt][t]; - if(cell) - out.push(''); - else - out.push(''); - }); - out.push(''); - } - - out.push('
','',t,'
',nt,'',printCell(cell),' 
'); - $("#table").html("

LL(1) Parse Table

"+out.join("")); -} - -function printActionDetails (a, token) { - var out = "
"; - if (!a || !a[0]) return ''; - - if (a[0] instanceof Array) { - a.forEach(function (ar) { out += printActionDetails_(ar, token); }); - } else { - out += printActionDetails_(a, token); - } - - return out+"
"; -} - -function printActionDetails_ (a, token) { - var out = ''; - if (a[0] == 1) { - var link = "Go to state "+a[1]+""; - out += "- Shift "+parser.symbols[token]+" then "+link+"
"; - } - else if (a[0] == 2) { - var text = "- Reduce by "+a[1]+") "+parser.productions[a[1]]; - out += text+"
"; - } - return out; -} - -function printAction (a){ - var actions = {"1":"s", "2":"r","3":"a"}; - if (!a[0]) return ''; - var out = '', - ary = []; - - if (a[0] instanceof Array) { - for(var i=0;i'+(actions[a[i][0]])+(a[i][1]||'')+''); - } else { - ary.push(''+(actions[a[0]])+(a[1]||'')+''); - } - - out += ary.join(','); - - return out; -} - -function sym2int (sym){ return parser.symbols_[sym]; } - -function lrTable (p){ - var actions = {"1":"s", "2":"r","3":"a"}; - var gs = p.symbols.slice(0).sort(); - var out = ['','','']; - out.push(''); - var ntout = []; - gs.shift(); - gs.forEach(function(t){ - if (p.nonterminals[t]) - ntout.push(''); - else if (t != 'error' || p.hasErrorRecovery) - out.push(''); - }); - out.push.apply(out, ntout); - out.push('',''); - - for (var i=0,state;i < p.table.length;i++){ - state=p.table[i]; - if (!state) continue; - ntout = []; - out.push(''); - gs.forEach(function(ts){ - if (ts == 'error' && !p.hasErrorRecovery) - return; - var t = sym2int(ts); - - if (p.nonterminals[ts]){ - if (typeof state[t] === 'number') - ntout.push(''); - else - ntout.push(''); - } else if (state[t]) { - out.push(''); - }); - out.push.apply(out, ntout); - out.push(''); - } - - out.push('
↓states','',t,'',t,'
',i,'
'); - parser.states.item(i).forEach(function (item, k) { - out.push(item,'
'); - }); - out.push('
',state[t],' ',printAction(state[t]),printActionDetails(state[t], t)); - } else - out.push(' 
'); - - $("#table").html("

"+parser.type+" Parse Table

Click cells to show details

"+out.join("")); - - p.resolutions.forEach(function (res){ - var r = res[2]; - var el = document.getElementById('act-'+res[0]+'-'+p.symbols_[res[1]]); - if (r.bydefault) { - el.className += ' conflict'; - } - if (el) - el.title += r.msg+"\n"+"("+r.s+", "+r.r+") -> "+r.action; - }); - -} - diff --git a/web/jison/states.html b/web/jison/states.html deleted file mode 100644 index 0a4afe695..000000000 --- a/web/jison/states.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - Jison, parse table visualation page - - - - - - - - - - - - - - - - - - - - -

- Algorithm: - * WARNING: LR(1) may take considerable time to execute for large/ambigous grammars. -

-

-

- -
- -
- - diff --git a/web/jison/usf.html b/web/jison/usf.html deleted file mode 100644 index b28aac8c6..000000000 --- a/web/jison/usf.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - Jison, parse table visualation page - - - - - - - - - - - - - - - - - -
-

Jison

-

Jison is a parser generator written in JavaScript. This page uses Jison to display an interactive parsing table based on the grammar and parsing algorithm chosen, which can be very helpful for debugging.

-

Special thanks to Dr. Ligatti for suggesting and giving feedback on the interface.

- -

Input

- -

Input a BNF grammar along with a token list and optional start symbol, in JSON format. -

- -

- Load an example: - -

- - - -

- Parser type: - * WARNING: LR(1) may take considerable time to execute for large/ambigous grammars. -

-

-

- - -

Output

-

Process your grammar to see the result here.

-
-
- - -
-

Parse a program

-

Grammars with lexing information allow for parsing. Use the form below to parse a program using your grammar:

-
- -

Result

- -
- -
- -

- Zach Carter (zcarter@mail.usf.edu) 2009 -

- -
- - diff --git a/web/layouts/default.html b/web/layouts/default.html deleted file mode 100644 index 522f29125..000000000 --- a/web/layouts/default.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - Jison / <%= @item[:title] %> - - - - - -
- <%= yield %> -
- - - Fork me on GitHub - - - diff --git a/web/lib/default.rb b/web/lib/default.rb deleted file mode 100644 index a4df0ccb7..000000000 --- a/web/lib/default.rb +++ /dev/null @@ -1,2 +0,0 @@ -# All files in the 'lib' directory will be loaded -# before nanoc starts compiling. From 2b8b7aae33a4624d8c8e9f57e6039550be63a9a8 Mon Sep 17 00:00:00 2001 From: Steve Shreeve Date: Wed, 16 Jul 2025 09:23:17 -0600 Subject: [PATCH 2/4] Remove all dependencies, focus on LALR(1), simplify everything, improve performance --- lib/jison.js | 2384 ++++++++++++++++++-------------------------------- package.json | 17 +- 2 files changed, 869 insertions(+), 1532 deletions(-) diff --git a/lib/jison.js b/lib/jison.js index d078056ee..93ba24bc0 100755 --- a/lib/jison.js +++ b/lib/jison.js @@ -1,1361 +1,1044 @@ -// Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator -// Zachary Carter -// MIT X Licensed +// LALR(1) Parser Generator - DeRemer-Pennello Algorithm Implementation +// +// This implementation uses canonical naming conventions from established literature to +// serve as a reference implementation for computer science education and research. +// Canonical naming conventions based on established literature: +// +// - "Compilers: Principles, Techniques, and Tools" (Dragon Book) +// - "Efficient Computation of LALR(1) Look-Ahead Sets" (DeRemer & Pennello, 1982) +// - "LR Parsing: Theory and Practice" (Knuth, 1965) +// +// Function Reference: +// +// Utility Functions: +// - union(a, b) - Merge array b into array a, avoiding duplicates +// +// Constructor Functions: +// - Nonterminal(symbol) - Represents a nonterminal symbol in the grammar +// - Production(symbol, handle, id) - Represents a production rule in the grammar +// - Item(production, dot, lookaheadSet, predecessor) - Represents an LR(0) item [A → α•β] with lookahead +// - LRState() - Represents a set of LR items (parser state) +// - LALRGenerator(grammar, options) - Unified LALR(1) parser generator class +// +// LRState Methods: +// - concat(set) - Merge another LRState or array into this LRState +// - push(item) - Add an item to this LRState +// - contains(item) - Check if this LRState contains a specific item +// - valueOf() - Generate unique string representation for ItemSet comparison +// +// LALRGenerator Core Methods: +// - gotoEncoded(stateId, symbolSequence) - Specialized GOTO method for lookahead computation +// - processGrammar(grammar) - Process and validate the input grammar specification +// - processOperators(ops) - Process operator precedence and associativity declarations +// - augmentGrammar(grammar) - Add augmented start production for parser generation +// - buildProductions(bnf, productions, nonterminals, symbols, operators) - Build production rules from BNF grammar +// +// Lookahead Computation: +// - computeLookaheads() - Compute LALR(1) lookaheads using DeRemer-Pennello algorithm +// - computeNullableSets() - Compute NULLABLE sets for all nonterminals +// - isNullable(symbol) - Check if a symbol or symbol sequence is nullable +// - computeFirstSets() - Compute FIRST sets for all nonterminals +// - first(symbol) - Get FIRST set for a symbol or symbol sequence +// - computeFollowSets() - Compute FOLLOW sets for all nonterminals +// +// LR Automaton Construction: +// - closure(itemSet) - Compute closure of an item set (add all implied items) +// - goto(itemSet, symbol) - Compute goto operation (items after shifting a symbol) +// - buildLRAutomaton() - Generate canonical collection of LR(0) item sets +// - insertLRState(symbol, itemSet, states, stateNum) - Insert or merge item set into canonical collection +// +// Parse Table Generation: +// - buildParseTable(itemSets) - Generate LALR(1) parsing table from item sets +// - resolveConflict(production, op, reduce, shift) - Resolve shift/reduce conflicts using operator precedence +// - computeDefaultActions(states) - Find default actions for parser states to reduce table size +// - getLookaheadSet(state, item) - Get lookahead symbols for an item in a state +// +// Navigation and State Management: +// - gotoState(startState, symbolSequence) - Navigate through parser states following a symbol sequence +// - gotoStateWithPath(startState, symbolSequence) - Navigate through parser states and record the path taken +// - buildAugmentedGrammar() - Build augmented grammar for lookahead computation +// - unionLookaheads() - Propagate lookaheads from augmented grammar back to original states +// +// Code Generation: +// - generate(opt) - Generate parser code with specified options +// - generateCommonJSModule(opt) - Generate CommonJS module wrapper for parser +// - generateModule(opt) - Generate module wrapper for parser +// - generateModuleExpr() - Generate self-executing module expression +// - generateModule_() - Generate core parser module code +// - generateTableCode(table) - Generate optimized parsing table code +// +// Parser Runtime: +// - parseError(str, hash) - Handle parsing errors with context information +// - parse(input) - Parse input string using generated LALR(1) parser +// - trace() - Debug tracing function (no-op by default) +// - createParser() - Create executable parser instance from generated code +// +// Export Functions: +// - Jison.Parser(grammar, options) - Create parser from grammar +// - Jison.Generator(g, options) - Create generator instance +// - Parser(g, options) - Main parser factory function +// +// Original implementation by Jison team +// https://github.com/zaach/jison/blob/master/lib/jison.js -var typal = require('./util/typal').typal; -var Set = require('./util/set').Set; -var Lexer = require('jison-lex'); -var ebnfParser = require('ebnf-parser'); -var JSONSelect = require('JSONSelect'); -var esprima = require('esprima'); -var escodegen = require('escodegen'); +var Jison = exports.Jison = exports; +var version = require('../package.json').version; +// Merge array b into array a, avoiding duplicates +function union(a, b) { + var s = Object.create(null); + var i, len; + for (i = 0, len = a.length; i < len; i++) { + s[a[i]] = 1; + } + for (i = 0, len = b.length; i < len; i++) { + if (!s[b[i]]) { + a.push(b[i]); + } + } + return a; +} -var version = require('../package.json').version; +// Represents a nonterminal symbol in the grammar +function Nonterminal(symbol) { + this.symbol = symbol; + this.productions = []; + this.first = []; + this.follows = []; + this.nullable = false; +} -var Jison = exports.Jison = exports; -Jison.version = version; - -// detect print -if (typeof console !== 'undefined' && console.log) { - Jison.print = console.log; -} else if (typeof puts !== 'undefined') { - Jison.print = function print () { puts([].join.call(arguments, ' ')); }; -} else if (typeof print !== 'undefined') { - Jison.print = print; -} else { - Jison.print = function print () {}; +// Represents a production rule in the grammar +function Production(symbol, handle, id) { + this.symbol = symbol; + this.handle = handle; + this.id = id; + this.nullable = false; + this.first = []; + this.precedence = 0; } -Jison.Parser = (function () { +// Represents an LR(0) item [A → α•β] with lookahead (canonical: LR item) +function Item(production, dot, lookaheadSet, predecessor) { + this.production = production; + this.dot = dot || 0; // Position of • in production + this.follows = lookaheadSet || []; // LALR(1) lookahead symbols + this.predecessor = predecessor; + this.nextSymbol = this.production.handle[this.dot]; // Symbol after • + this.id = parseInt(production.id + 'a' + this.dot, 36); +} -// iterator utility -function each (obj, func) { - if (obj.forEach) { - obj.forEach(func); - } else { - var p; - for (p in obj) { - if (obj.hasOwnProperty(p)) { - func.call(obj, obj[p], p, obj); - } +// Represents a set of LR items (parser state) - canonical: LR state +function LRState() { + this.list = []; + this.length = 0; + this.reductions = []; // Reductions in this state + this.handleToSymbols = {}; // Maps production handles to generating symbols + this.transitions = {}; // State transitions + this.hasShifts = false; // Has shift actions + this.hasConflicts = false; // Has SR/RR conflicts + this.keys = {}; + + if (arguments.length) { + this.list = Array.prototype.slice.call(arguments); + this.length = this.list.length; + for (var i = this.length - 1; i >= 0; i--) { + this.keys[this.list[i].id] = true; } } } -var Nonterminal = typal.construct({ - constructor: function Nonterminal (symbol) { - this.symbol = symbol; - this.productions = new Set(); - this.first = []; - this.follows = []; - this.nullable = false; - }, - toString: function Nonterminal_toString () { - var str = this.symbol+"\n"; - str += (this.nullable ? 'nullable' : 'not nullable'); - str += "\nFirsts: "+this.first.join(', '); - str += "\nFollows: "+this.first.join(', '); - str += "\nProductions:\n "+this.productions.join('\n '); - - return str; - } -}); - -var Production = typal.construct({ - constructor: function Production (symbol, handle, id) { - this.symbol = symbol; - this.handle = handle; - this.nullable = false; - this.id = id; - this.first = []; - this.precedence = 0; - }, - toString: function Production_toString () { - return this.symbol+" -> "+this.handle.join(' '); +// Merge another LRState or array into this LRState +LRState.prototype.concat = function(set) { + var a = set.list || set; + for (var i = a.length - 1; i >= 0; i--) { + this.keys[a[i].id] = true; } -}); + this.list.push.apply(this.list, a); + this.length = this.list.length; + return this; +}; -var generator = typal.beget(); +// Add an item to this LRState +LRState.prototype.push = function(item) { + this.keys[item.id] = true; + this.list.push(item); + this.length = this.list.length; + return this.length; +}; -generator.constructor = function Jison_Generator (grammar, opt) { - if (typeof grammar === 'string') { - grammar = ebnfParser.parse(grammar); - } +// Check if this LRState contains a specific item +LRState.prototype.contains = function(item) { + return this.keys[item.id]; +}; + +// Generate unique string representation for ItemSet comparison +LRState.prototype.valueOf = function() { + var v = this.list.map(function(a) { return a.id; }).sort().join('|'); + this.valueOf = function() { return v; }; + return v; +}; - var options = typal.mix.call({}, grammar.options, opt); - this.terms = {}; +// Unified LALR(1) parser generator class (canonical: LALRGenerator) +function LALRGenerator(grammar, options) { + options = Object.assign({}, grammar.options, options); + this.terminals = {}; // Terminal symbols this.operators = {}; this.productions = []; this.conflicts = 0; this.resolutions = []; this.options = options; this.parseParams = grammar.parseParams; - this.yy = {}; // accessed as yy free variable in the parser/lexer actions + this.yy = {}; - // source included in semantic action execution scope if (grammar.actionInclude) { if (typeof grammar.actionInclude === 'function') { - grammar.actionInclude = String(grammar.actionInclude).replace(/^\s*function \(\) \{/, '').replace(/\}\s*$/, ''); + grammar.actionInclude = String(grammar.actionInclude) + .replace(/^\s*function \(\) \{/, '') + .replace(/\}\s*$/, ''); } this.actionInclude = grammar.actionInclude; } this.moduleInclude = grammar.moduleInclude || ''; - this.DEBUG = options.debug || false; - if (this.DEBUG) this.mix(generatorDebug); // mixin debug methods - + console.time('processGrammar'); this.processGrammar(grammar); + console.timeEnd('processGrammar'); - if (grammar.lex) { - this.lexer = new Lexer(grammar.lex, null, this.terminals_); - } -}; + console.time('buildLRAutomaton'); + this.states = this.buildLRAutomaton(); + console.timeEnd('buildLRAutomaton'); -generator.processGrammar = function processGrammarDef (grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions, - self = this; + this.terminalMap = {}; // Maps symbols to terminal representations - if (!grammar.bnf && grammar.ebnf) { - bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); - } + // Initialize lookahead state (replaces newg creation) + this.lookahead = { + nonterminalMap: {}, // Maps nonterminals to states + nonterminals: {}, + productions: [] + }; - if (tokens) { - if (typeof tokens === 'string') { - tokens = tokens.trim().split(' '); - } else { - tokens = tokens.slice(0); - } - } + this.conflictStates = []; // States with conflicts + this.onDemandLookahead = options.onDemandLookahead || false; + + console.time('buildAugmentedGrammar'); + this.buildAugmentedGrammar(); + console.timeEnd('buildAugmentedGrammar'); + // Compute lookaheads in lookahead context (replaces newg.computeLookaheads()) + var savedNonterminals = this.nonterminals; + var savedProductions = this.productions; + + this.nonterminals = this.lookahead.nonterminals; + this.productions = this.lookahead.productions; + + console.time('computeLookaheads'); + this.computeLookaheads(); + console.timeEnd('computeLookaheads'); + + this.nonterminals = savedNonterminals; + this.productions = savedProductions; + + console.time('unionLookaheads'); + this.unionLookaheads(); + console.timeEnd('unionLookaheads'); + + console.time('buildParseTable'); + this.stateTable = this.buildParseTable(this.states); + console.timeEnd('buildParseTable'); + + console.time('computeDefaultActions'); + this.defaultActions = this.computeDefaultActions(this.stateTable); + console.timeEnd('computeDefaultActions'); +} + +// Specialized GOTO method for lookahead computation (DeRemer-Pennello algorithm) +LALRGenerator.prototype.gotoEncoded = function(stateId, symbolSequence) { + stateId = stateId.split(":")[0]; + symbolSequence = symbolSequence.map(function(s) { return s.slice(s.indexOf(":") + 1); }); + return this.gotoState(stateId, symbolSequence); +}; + +// Process and validate the input grammar specification +LALRGenerator.prototype.processGrammar = function(grammar) { + var bnf = grammar.bnf; + var tokens = grammar.tokens; + var nonterminals = this.nonterminals = {}; + var productions = this.productions; var symbols = this.symbols = []; + var operators = this.operators = this.processOperators(grammar.operators); - // calculate precedence of operators - var operators = this.operators = processOperators(grammar.operators); + if (tokens) { + tokens = typeof tokens === 'string' ? tokens.trim().split(' ') : tokens.slice(0); + } - // build productions from cfg this.buildProductions(bnf, productions, nonterminals, symbols, operators); if (tokens && this.terminals.length !== tokens.length) { - self.trace("Warning: declared tokens differ from tokens found in rules."); - self.trace(this.terminals); - self.trace(tokens); + this.trace("Warning: declared tokens differ from tokens found in rules."); } - // augment the grammar this.augmentGrammar(grammar); }; -generator.augmentGrammar = function augmentGrammar (grammar) { +// Process operator precedence and associativity declarations +LALRGenerator.prototype.processOperators = function(ops) { + if (!ops) return {}; + var operators = {}; + for (var i = 0, prec; prec = ops[i]; i++) { + for (var k = 1; k < prec.length; k++) { + operators[prec[k]] = { + precedence: i + 1, + assoc: prec[0] + }; + } + } + return operators; +}; + +// Add augmented start production for parser generation +LALRGenerator.prototype.augmentGrammar = function(grammar) { if (this.productions.length === 0) { throw new Error("Grammar error: must have at least one rule."); } - // use specified start symbol, or default to first user defined production + this.startSymbol = grammar.start || grammar.startSymbol || this.productions[0].symbol; if (!this.nonterminals[this.startSymbol]) { throw new Error("Grammar error: startSymbol must be a non-terminal found in your grammar."); } - this.EOF = "$end"; - // augment the grammar + this.EOF = "$end"; var acceptProduction = new Production('$accept', [this.startSymbol, '$end'], 0); this.productions.unshift(acceptProduction); - - // prepend parser tokens - this.symbols.unshift("$accept",this.EOF); - this.symbols_.$accept = 0; - this.symbols_[this.EOF] = 1; + this.symbols.unshift("$accept", this.EOF); + this.symbolMap.$accept = 0; + this.symbolMap[this.EOF] = 1; this.terminals.unshift(this.EOF); this.nonterminals.$accept = new Nonterminal("$accept"); this.nonterminals.$accept.productions.push(acceptProduction); - - // add follow $ to start symbol this.nonterminals[this.startSymbol].follows.push(this.EOF); }; -// set precedence and associativity of operators -function processOperators (ops) { - if (!ops) return {}; - var operators = {}; - for (var i=0,k,prec;prec=ops[i]; i++) { - for (k=1;k < prec.length;k++) { - operators[prec[k]] = {precedence: i+1, assoc: prec[0]}; - } - } - return operators; -} - - -generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators) { +// Build production rules from BNF grammar specification +LALRGenerator.prototype.buildProductions = function(bnf, productions, nonterminals, symbols, operators) { var actions = [ - '/* this == yyval */', - this.actionInclude || '', - 'var $0 = $$.length - 1;', - 'switch (yystate) {' + '/* this == yyval */', + this.actionInclude || '', + 'var $0 = $$.length - 1;', + 'switch (yystate) {' ]; var actionGroups = {}; - var prods, symbol; - var productions_ = [0]; + var productionTable = [0]; var symbolId = 1; - var symbols_ = {}; + var symbolMap = {}; - var her = false; // has error recovery - - function addSymbol (s) { - if (s && !symbols_[s]) { - symbols_[s] = ++symbolId; + function addSymbol(s) { + if (s && !symbolMap[s]) { + symbolMap[s] = ++symbolId; symbols.push(s); } } - // add error symbol; will be third symbol, or "2" ($accept, $end, error) addSymbol("error"); - for (symbol in bnf) { + for (var symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; addSymbol(symbol); nonterminals[symbol] = new Nonterminal(symbol); - if (typeof bnf[symbol] === 'string') { - prods = bnf[symbol].split(/\s*\|\s*/g); - } else { - prods = bnf[symbol].slice(0); - } - - prods.forEach(buildProduction); - } - for (var action in actionGroups) - actions.push(actionGroups[action].join(' '), action, 'break;'); - - var sym, terms = [], terms_ = {}; - each(symbols_, function (id, sym) { - if (!nonterminals[sym]) { - terms.push(sym); - terms_[id] = sym; - } - }); - - this.hasErrorRecovery = her; - - this.terminals = terms; - this.terminals_ = terms_; - this.symbols_ = symbols_; - - this.productions_ = productions_; - actions.push('}'); + var prods = typeof bnf[symbol] === 'string' ? + bnf[symbol].split(/\s*\|\s*/g) : + bnf[symbol].slice(0); - actions = actions.join("\n") - .replace(/YYABORT/g, 'return false') - .replace(/YYACCEPT/g, 'return true'); + prods.forEach(function(handle) { + var r, rhs, i; + if (handle.constructor === Array) { + rhs = typeof handle[0] === 'string' ? + handle[0].trim().split(' ') : + handle[0].slice(0); - var parameters = "yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */"; - if (this.parseParams) parameters += ', ' + this.parseParams.join(', '); - - this.performAction = "function anonymous(" + parameters + ") {\n" + actions + "\n}"; - - function buildProduction (handle) { - var r, rhs, i; - if (handle.constructor === Array) { - rhs = (typeof handle[0] === 'string') ? - handle[0].trim().split(' ') : - handle[0].slice(0); - - for (i=0; i don't care about aliases; strip them. - rhs = rhs.map(function(e,i) { return e.replace(/\[[a-zA-Z_][a-zA-Z0-9_-]*\]/g, '') }); - // only precedence specified - r = new Production(symbol, rhs, productions.length+1); - if (operators[handle[1].prec]) { - r.precedence = operators[handle[1].prec].precedence; - } - } - } else { - // no action -> don't care about aliases; strip them. - handle = handle.replace(/\[[a-zA-Z_][a-zA-Z0-9_-]*\]/g, ''); - rhs = handle.trim().split(' '); - for (i=0; i=0; i--) { - if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { - r.precedence = operators[r.handle[i]].precedence; + + if (r.precedence === 0) { + for (i = r.handle.length - 1; i >= 0; i--) { + if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { + r.precedence = operators[r.handle[i]].precedence; + break; + } } } - } - productions.push(r); - productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + productions.push(r); + productionTable.push([symbolMap[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); + nonterminals[symbol].productions.push(r); + }); } -}; - - - -generator.createParser = function createParser () { - throw new Error('Calling abstract method.'); -}; - -// noop. implemented in debug mixin -generator.trace = function trace () { }; - -generator.warn = function warn () { - var args = Array.prototype.slice.call(arguments,0); - Jison.print.call(null,args.join("")); -}; -generator.error = function error (msg) { - throw new Error(msg); -}; + for (var action in actionGroups) { + actions.push(actionGroups[action].join(' '), action, 'break;'); + } -// Generator debug mixin - -var generatorDebug = { - trace: function trace () { - Jison.print.apply(null, arguments); - }, - beforeprocessGrammar: function () { - this.trace("Processing grammar."); - }, - afteraugmentGrammar: function () { - var trace = this.trace; - each(this.symbols, function (sym, i) { - trace(sym+"("+i+")"); - }); + var terms = [], terms_ = {}; + for (var sym in symbolMap) { + id = symbolMap[sym]; + if (!nonterminals[sym]) { + terms.push(sym); + terms_[id] = sym; + } } -}; + this.terminals = terms; + this.terminals_ = terms_; + this.symbolMap = symbolMap; + this.productionTable = productionTable; + actions.push('}'); + var actionsCode = actions.join("\n") + .replace(/YYABORT/g, 'return false') + .replace(/YYACCEPT/g, 'return true'); -/* - * Mixin for common behaviors of lookahead parsers - * */ -var lookaheadMixin = {}; + var parameters = "yytext, yyleng, yylineno, yy, yystate, $$, _$"; + if (this.parseParams) { + parameters += ', ' + this.parseParams.join(', '); + } -lookaheadMixin.computeLookaheads = function computeLookaheads () { - if (this.DEBUG) this.mix(lookaheadDebug); // mixin debug methods + this.performAction = "function anonymous(" + parameters + ") {\n" + actionsCode + "\n}"; +}; - this.computeLookaheads = function () {}; - this.nullableSets(); - this.firstSets(); - this.followSets(); +// Lookahead computation +// Compute LALR(1) lookaheads using DeRemer-Pennello algorithm +LALRGenerator.prototype.computeLookaheads = function() { + this.computeLookaheads = function() {}; + this.computeNullableSets(); + this.computeFirstSets(); + this.computeFollowSets(); }; -// calculate follow sets typald on first and nullable -lookaheadMixin.followSets = function followSets () { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; +// Compute NULLABLE sets for all nonterminals (canonical: NULLABLE computation) +LALRGenerator.prototype.computeNullableSets = function() { + var nonterminals = this.nonterminals; + var self = this; + var cont = true; - // loop until no further changes have been made - while(cont) { + while (cont) { cont = false; - productions.forEach(function Follow_prod_forEach (production, k) { - //self.trace(production.symbol,nonterminals[production.symbol].follows); - // q is used in Simple LALR algorithm determine follows in context - var q; - var ctx = !!self.go_; - - var set = [],oldcount; - for (var i=0,t;t=production.handle[i];++i) { - if (!nonterminals[t]) continue; - - // for Simple LALR algorithm, self.go_ checks if - if (ctx) - q = self.go_(production.symbol, production.handle.slice(0, i)); - var bool = !ctx || q === parseInt(self.nterms_[t], 10); - - if (i === production.handle.length+1 && bool) { - set = nonterminals[production.symbol].follows; - } else { - var part = production.handle.slice(i+1); - - set = self.first(part); - if (self.nullable(part) && bool) { - set.push.apply(set, nonterminals[production.symbol].follows); - } + this.productions.forEach(function(production) { + if (!production.nullable) { + var n = 0; + for (var i = 0, t; t = production.handle[i]; ++i) { + if (self.isNullable(t)) n++; } - oldcount = nonterminals[t].follows.length; - Set.union(nonterminals[t].follows, set); - if (oldcount !== nonterminals[t].follows.length) { - cont = true; + if (n === i) { + production.nullable = cont = true; } } }); + + for (var symbol in nonterminals) { + if (!this.isNullable(symbol)) { + for (var i = 0, production; production = nonterminals[symbol].productions[i]; i++) { + if (production.nullable) { + nonterminals[symbol].nullable = cont = true; + break; + } + } + } + } } }; -// return the FIRST set of a symbol or series of symbols -lookaheadMixin.first = function first (symbol) { - // epsilon - if (symbol === '') { - return []; - // RHS - } else if (symbol instanceof Array) { - var firsts = []; - for (var i=0,t;t=symbol[i];++i) { - if (!this.nonterminals[t]) { - if (firsts.indexOf(t) === -1) - firsts.push(t); - } else { - Set.union(firsts, this.nonterminals[t].first); - } - if (!this.nullable(t)) - break; +// Check if a symbol or symbol sequence is nullable (canonical: NULLABLE predicate) +LALRGenerator.prototype.isNullable = function(symbol) { + if (symbol === '') return true; + if (symbol instanceof Array) { + for (var i = 0, t; t = symbol[i]; ++i) { + if (!this.isNullable(t)) return false; } - return firsts; - // terminal - } else if (!this.nonterminals[symbol]) { - return [symbol]; - // nonterminal - } else { - return this.nonterminals[symbol].first; + return true; } + return !this.nonterminals[symbol] ? false : this.nonterminals[symbol].nullable; }; -// fixed-point calculation of FIRST sets -lookaheadMixin.firstSets = function firstSets () { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol,firsts; +// Compute FIRST sets for all nonterminals (canonical: FIRST computation) +LALRGenerator.prototype.computeFirstSets = function() { + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; - // loop until no further changes have been made - while(cont) { + while (cont) { cont = false; - productions.forEach(function FirstSets_forEach (production, k) { + productions.forEach(function(production) { var firsts = self.first(production.handle); if (firsts.length !== production.first.length) { production.first = firsts; - cont=true; + cont = true; } }); - for (symbol in nonterminals) { - firsts = []; - nonterminals[symbol].productions.forEach(function (production) { - Set.union(firsts, production.first); + for (var symbol in nonterminals) { + var firsts = []; + nonterminals[symbol].productions.forEach(function(production) { + union(firsts, production.first); }); if (firsts.length !== nonterminals[symbol].first.length) { nonterminals[symbol].first = firsts; - cont=true; + cont = true; } } } }; -// fixed-point calculation of NULLABLE -lookaheadMixin.nullableSets = function nullableSets () { - var firsts = this.firsts = {}, - nonterminals = this.nonterminals, - self = this, - cont = true; - - // loop until no further changes have been made - while(cont) { - cont = false; - - // check if each production is nullable - this.productions.forEach(function (production, k) { - if (!production.nullable) { - for (var i=0,n=0,t;t=production.handle[i];++i) { - if (self.nullable(t)) n++; - } - if (n===i) { // production is nullable if all tokens are nullable - production.nullable = cont = true; - } - } - }); - - //check if each symbol is nullable - for (var symbol in nonterminals) { - if (!this.nullable(symbol)) { - for (var i=0,production;production=nonterminals[symbol].productions.item(i);i++) { - if (production.nullable) - nonterminals[symbol].nullable = cont = true; - } +// Get FIRST set for a symbol or symbol sequence +LALRGenerator.prototype.first = function(symbol) { + if (symbol === '') return []; + if (symbol instanceof Array) { + var firsts = []; + for (var i = 0, t; t = symbol[i]; ++i) { + if (!this.nonterminals[t]) { + if (firsts.indexOf(t) === -1) firsts.push(t); + } else { + union(firsts, this.nonterminals[t].first); } + if (!this.isNullable(t)) break; } + return firsts; } + return !this.nonterminals[symbol] ? [symbol] : this.nonterminals[symbol].first; }; -// check if a token or series of tokens is nullable -lookaheadMixin.nullable = function nullable (symbol) { - // epsilon - if (symbol === '') { - return true; - // RHS - } else if (symbol instanceof Array) { - for (var i=0,t;t=symbol[i];++i) { - if (!this.nullable(t)) - return false; - } - return true; - // terminal - } else if (!this.nonterminals[symbol]) { - return false; - // nonterminal - } else { - return this.nonterminals[symbol].nullable; - } -}; +// Compute FOLLOW sets for all nonterminals +LALRGenerator.prototype.computeFollowSets = function() { + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; + while (cont) { + cont = false; -// lookahead debug mixin -var lookaheadDebug = { - beforenullableSets: function () { - this.trace("Computing Nullable sets."); - }, - beforefirstSets: function () { - this.trace("Computing First sets."); - }, - beforefollowSets: function () { - this.trace("Computing Follow sets."); - }, - afterfollowSets: function () { - var trace = this.trace; - each(this.nonterminals, function (nt, t) { - trace(nt, '\n'); - }); - } -}; + productions.forEach(function(production) { + var q = !!self.go_; + var ctx = q; -/* - * Mixin for common LR parser behavior - * */ -var lrGeneratorMixin = {}; + for (var i = 0, t; t = production.handle[i]; ++i) { + if (!nonterminals[t]) continue; -lrGeneratorMixin.buildTable = function buildTable () { - if (this.DEBUG) this.mix(lrGeneratorDebug); // mixin debug methods + if (ctx) { + q = self.gotoEncoded(production.symbol, production.handle.slice(0, i)); + } + var bool = !ctx || q === parseInt(self.lookahead.nonterminalMap[t], 10); - this.states = this.canonicalCollection(); - this.table = this.parseTable(this.states); - this.defaultActions = findDefaults(this.table); -}; + var set; + if (i === production.handle.length - 1 && bool) { + set = nonterminals[production.symbol].follows; + } else { + var part = production.handle.slice(i + 1); + set = self.first(part); + if (self.isNullable(part) && bool) { + set.push.apply(set, nonterminals[production.symbol].follows); + } + } -lrGeneratorMixin.Item = typal.construct({ - constructor: function Item(production, dot, f, predecessor) { - this.production = production; - this.dotPosition = dot || 0; - this.follows = f || []; - this.predecessor = predecessor; - this.id = parseInt(production.id+'a'+this.dotPosition, 36); - this.markedSymbol = this.production.handle[this.dotPosition]; - }, - remainingHandle: function () { - return this.production.handle.slice(this.dotPosition+1); - }, - eq: function (e) { - return e.id === this.id; - }, - handleToString: function () { - var handle = this.production.handle.slice(0); - handle[this.dotPosition] = '.'+(handle[this.dotPosition]||''); - return handle.join(' '); - }, - toString: function () { - var temp = this.production.handle.slice(0); - temp[this.dotPosition] = '.'+(temp[this.dotPosition]||''); - return this.production.symbol+" -> "+temp.join(' ') + - (this.follows.length === 0 ? "" : " #lookaheads= "+this.follows.join(' ')); - } -}); - -lrGeneratorMixin.ItemSet = Set.prototype.construct({ - afterconstructor: function () { - this.reductions = []; - this.goes = {}; - this.edges = {}; - this.shifts = false; - this.inadequate = false; - this.hash_ = {}; - for (var i=this._items.length-1;i >=0;i--) { - this.hash_[this._items[i].id] = true; //i; - } - }, - concat: function concat (set) { - var a = set._items || set; - for (var i=a.length-1;i >=0;i--) { - this.hash_[a[i].id] = true; //i; - } - this._items.push.apply(this._items, a); - return this; - }, - push: function (item) { - this.hash_[item.id] = true; - return this._items.push(item); - }, - contains: function (item) { - return this.hash_[item.id]; - }, - valueOf: function toValue () { - var v = this._items.map(function (a) {return a.id;}).sort().join('|'); - this.valueOf = function toValue_inner() {return v;}; - return v; + var oldcount = nonterminals[t].follows.length; + union(nonterminals[t].follows, set); + if (oldcount !== nonterminals[t].follows.length) { + cont = true; + } + } + }); } -}); +}; -lrGeneratorMixin.closureOperation = function closureOperation (itemSet /*, closureSet*/) { - var closureSet = new this.ItemSet(); +// Compute closure of an item set (add all implied items) +LALRGenerator.prototype.closure = function(itemSet) { + var closureSet = new LRState(); var self = this; - - var set = itemSet, - itemQueue, syms = {}; + var set = itemSet; + var itemQueue, syms = {}; do { - itemQueue = new Set(); - closureSet.concat(set); - set.forEach(function CO_set_forEach (item) { - var symbol = item.markedSymbol; - - // if token is a non-terminal, recursively add closures - if (symbol && self.nonterminals[symbol]) { - if(!syms[symbol]) { - self.nonterminals[symbol].productions.forEach(function CO_nt_forEach (production) { - var newItem = new self.Item(production, 0); - if(!closureSet.contains(newItem)) - itemQueue.push(newItem); - }); - syms[symbol] = true; - } - } else if (!symbol) { - // reduction - closureSet.reductions.push(item); - closureSet.inadequate = closureSet.reductions.length > 1 || closureSet.shifts; - } else { - // shift - closureSet.shifts = true; - closureSet.inadequate = closureSet.reductions.length > 0; - } - }); + itemQueue = []; + closureSet.concat(set); - set = itemQueue; + (set.list || set).forEach(function(item) { + var symbol = item.nextSymbol; - } while (!itemQueue.isEmpty()); + if (symbol && self.nonterminals[symbol]) { + if (!syms[symbol]) { + self.nonterminals[symbol].productions.forEach(function(production) { + var newItem = new Item(production, 0); + if (!closureSet.contains(newItem)) { + itemQueue.push(newItem); + } + }); + syms[symbol] = true; + } + } else if (!symbol) { + closureSet.reductions.push(item); + closureSet.hasConflicts = closureSet.reductions.length > 1 || closureSet.hasShifts; + } else { + closureSet.hasShifts = true; + closureSet.hasConflicts = closureSet.reductions.length > 0; + } + }); + + set = itemQueue; + } while (itemQueue.length > 0); return closureSet; }; -lrGeneratorMixin.gotoOperation = function gotoOperation (itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; +// Compute goto operation (items after shifting a symbol) +LALRGenerator.prototype.goto = function(itemSet, symbol) { + var gotoSet = new LRState(); + var self = this; - itemSet.forEach(function goto_forEach(item, n) { - if (item.markedSymbol === symbol) { - gotoSet.push(new self.Item(item.production, item.dotPosition+1, item.follows, n)); + itemSet.list.forEach(function(item, n) { + if (item.nextSymbol === symbol) { + gotoSet.push(new Item(item.production, item.dot + 1, item.follows, n)); } }); - return gotoSet.isEmpty() ? gotoSet : this.closureOperation(gotoSet); + return gotoSet.length === 0 ? gotoSet : this.closure(gotoSet); }; -/* Create unique set of item sets - * */ -lrGeneratorMixin.canonicalCollection = function canonicalCollection () { - var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstState = this.closureOperation(new this.ItemSet(item1)), - states = new Set(firstState), - marked = 0, - self = this, - itemSet; +// Generate canonical collection of LR(0) item sets +LALRGenerator.prototype.buildLRAutomaton = function() { + var item1 = new Item(this.productions[0], 0, [this.EOF]); + var firstState = this.closure(new LRState(item1)); + var states = [firstState]; + var marked = 0; + var self = this; states.has = {}; states.has[firstState] = 0; - while (marked !== states.size()) { - itemSet = states.item(marked); marked++; - itemSet.forEach(function CC_itemSet_forEach (item) { - if (item.markedSymbol && item.markedSymbol !== self.EOF) - self.canonicalCollectionInsert(item.markedSymbol, itemSet, states, marked-1); + while (marked !== states.length) { + var itemSet = states[marked]; + marked++; + + itemSet.list.forEach(function(item) { + if (item.nextSymbol && item.nextSymbol !== self.EOF) { + self.insertLRState(item.nextSymbol, itemSet, states, marked - 1); + } }); } return states; }; -// Pushes a unique state into the que. Some parsing algorithms may perform additional operations -lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert (symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol); - if (!g.predecessors) - g.predecessors = {}; - // add g to que if not empty or duplicate - if (!g.isEmpty()) { - var gv = g.valueOf(), - i = states.has[gv]; +// Insert or merge item set into canonical collection +LALRGenerator.prototype.insertLRState = function(symbol, itemSet, states, stateNum) { + var g = this.goto(itemSet, symbol); + if (!g.predecessors) g.predecessors = {}; + + if (g.length > 0) { + var gv = g.valueOf(); + var i = states.has[gv]; if (i === -1 || typeof i === 'undefined') { - states.has[gv] = states.size(); - itemSet.edges[symbol] = states.size(); // store goto transition for table + states.has[gv] = states.length; + itemSet.transitions[symbol] = states.length; states.push(g); g.predecessors[symbol] = [stateNum]; } else { - itemSet.edges[symbol] = i; // store goto transition for table - states.item(i).predecessors[symbol].push(stateNum); + itemSet.transitions[symbol] = i; + states[i].predecessors[symbol].push(stateNum); } } }; -var NONASSOC = 0; -lrGeneratorMixin.parseTable = function parseTable (itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, // array of [state, token] tuples - self = this, - s = 1, // shift - r = 2, // reduce - a = 3; // accept - - // for each item set - itemSets.forEach(function (itemSet, k) { +// Parse table generation +// Generate LALR(1) parsing table from item sets +LALRGenerator.prototype.buildParseTable = function(itemSets) { + var states = []; + var nonterminals = this.nonterminals; + var operators = this.operators; + var conflictedStates = {}; + var self = this; + var s = 1, r = 2, a = 3; + var NONASSOC = 0; + + itemSets.forEach(function(itemSet, k) { var state = states[k] = {}; - var action, stackSymbol; - - // set shift and goto actions - for (stackSymbol in itemSet.edges) { - itemSet.forEach(function (item, j) { - // find shift and goto actions - if (item.markedSymbol == stackSymbol) { - var gotoState = itemSet.edges[stackSymbol]; + + // Set shift and goto actions + for (var stackSymbol in itemSet.transitions) { + itemSet.list.forEach(function(item) { + if (item.nextSymbol === stackSymbol) { + var gotoState = itemSet.transitions[stackSymbol]; if (nonterminals[stackSymbol]) { - // store state to go to after a reduce - //self.trace(k, stackSymbol, 'g'+gotoState); - state[self.symbols_[stackSymbol]] = gotoState; + state[self.symbolMap[stackSymbol]] = gotoState; } else { - //self.trace(k, stackSymbol, 's'+gotoState); - state[self.symbols_[stackSymbol]] = [s,gotoState]; + state[self.symbolMap[stackSymbol]] = [s, gotoState]; } } }); } - // set accept action - itemSet.forEach(function (item, j) { - if (item.markedSymbol == self.EOF) { - // accept - state[self.symbols_[self.EOF]] = [a]; - //self.trace(k, self.EOF, state[self.EOF]); + // Set accept action + itemSet.list.forEach(function(item) { + if (item.nextSymbol === self.EOF) { + state[self.symbolMap[self.EOF]] = [a]; } }); - var allterms = self.lookAheads ? false : self.terminals; + var allterms = self.getLookaheadSet ? false : self.terminals; - // set reductions and resolve potential conflicts - itemSet.reductions.forEach(function (item, j) { - // if parser uses lookahead, only enumerate those terminals - var terminals = allterms || self.lookAheads(itemSet, item); + // Set reductions + itemSet.reductions.forEach(function(item) { + var terminals = allterms || self.getLookaheadSet(itemSet, item); - terminals.forEach(function (stackSymbol) { - action = state[self.symbols_[stackSymbol]]; + terminals.forEach(function(stackSymbol) { + var action = state[self.symbolMap[stackSymbol]]; var op = operators[stackSymbol]; - // Reading a terminal and current position is at the end of a production, try to reduce - if (action || action && action.length) { - var sol = resolveConflict(item.production, op, [r,item.production.id], action[0] instanceof Array ? action[0] : action); - self.resolutions.push([k,stackSymbol,sol]); + if (action || (action && action.length)) { + var sol = self.resolveConflict(item.production, op, [r, item.production.id], + action[0] instanceof Array ? action[0] : action); + self.resolutions.push([k, stackSymbol, sol]); + if (sol.bydefault) { self.conflicts++; - if (!self.DEBUG) { - self.warn('Conflict in grammar: multiple actions possible when lookahead token is ',stackSymbol,' in state ',k, "\n- ", printAction(sol.r, self), "\n- ", printAction(sol.s, self)); - conflictedStates[k] = true; - } + conflictedStates[k] = true; if (self.options.noDefaultResolve) { - if (!(action[0] instanceof Array)) + if (!(action[0] instanceof Array)) { action = [action]; + } action.push(sol.r); } } else { action = sol.action; } } else { - action = [r,item.production.id]; + action = [r, item.production.id]; } + if (action && action.length) { - state[self.symbols_[stackSymbol]] = action; + state[self.symbolMap[stackSymbol]] = action; } else if (action === NONASSOC) { - state[self.symbols_[stackSymbol]] = undefined; + state[self.symbolMap[stackSymbol]] = undefined; } }); }); - }); - if (!self.DEBUG && self.conflicts > 0) { - self.warn("\nStates with conflicts:"); - each(conflictedStates, function (val, state) { - self.warn('State '+state); - self.warn(' ',itemSets.item(state).join("\n ")); - }); - } - return states; }; -// find states with only one action, a reduction -function findDefaults (states) { - var defaults = {}; - states.forEach(function (state, k) { - var i = 0; - for (var act in state) { - if ({}.hasOwnProperty.call(state, act)) i++; - } - - if (i === 1 && state[act][0] === 2) { - // only one action in state and it's a reduction - defaults[k] = state[act]; - } - }); - - return defaults; -} - -// resolves shift-reduce and reduce-reduce conflicts -function resolveConflict (production, op, reduce, shift) { - var sln = {production: production, operator: op, r: reduce, s: shift}, - s = 1, // shift - r = 2, // reduce - a = 3; // accept +// Resolve shift/reduce conflicts using operator precedence +LALRGenerator.prototype.resolveConflict = function(production, op, reduce, shift) { + var sln = { + production: production, + operator: op, + r: reduce, + s: shift + }; + var s = 1, r = 2, NONASSOC = 0; if (shift[0] === r) { - sln.msg = "Resolve R/R conflict (use first production declared in grammar.)"; sln.action = shift[1] < reduce[1] ? shift : reduce; if (shift[1] !== reduce[1]) sln.bydefault = true; return sln; } if (production.precedence === 0 || !op) { - sln.msg = "Resolve S/R conflict (shift by default.)"; sln.bydefault = true; sln.action = shift; - } else if (production.precedence < op.precedence ) { - sln.msg = "Resolve S/R conflict (shift for higher precedent operator.)"; + } else if (production.precedence < op.precedence) { sln.action = shift; } else if (production.precedence === op.precedence) { - if (op.assoc === "right" ) { - sln.msg = "Resolve S/R conflict (shift for right associative operator.)"; + if (op.assoc === "right") { sln.action = shift; - } else if (op.assoc === "left" ) { - sln.msg = "Resolve S/R conflict (reduce for left associative operator.)"; + } else if (op.assoc === "left") { sln.action = reduce; - } else if (op.assoc === "nonassoc" ) { - sln.msg = "Resolve S/R conflict (no action for non-associative operator.)"; + } else if (op.assoc === "nonassoc") { sln.action = NONASSOC; } } else { - sln.msg = "Resolve conflict (reduce for higher precedent production.)"; sln.action = reduce; } return sln; -} +}; + +// Find default actions for parser states to reduce table size +LALRGenerator.prototype.computeDefaultActions = function(states) { + var defaults = {}; + states.forEach(function(state, k) { + var i = 0, act; + for (act in state) { + if ({}.hasOwnProperty.call(state, act)) i++; + } + if (i === 1 && state[act][0] === 2) { + defaults[k] = state[act]; + } + }); + return defaults; +}; -lrGeneratorMixin.generate = function parser_generate (opt) { - opt = typal.mix.call({}, this.options, opt); - var code = ""; +// LALR-specific methods +// Get lookahead symbols for an item in a state +LALRGenerator.prototype.getLookaheadSet = function(state, item) { + return (!!this.onDemandLookahead && !state.hasConflicts) ? this.terminals : item.follows; +}; - // check for illegal identifier - if (!opt.moduleName || !opt.moduleName.match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) { - opt.moduleName = "parser"; +// Navigate through parser states following a symbol sequence +LALRGenerator.prototype.gotoState = function(startState, symbolSequence) { + var currentState = parseInt(startState, 10); + for (var i = 0; i < symbolSequence.length; i++) { + currentState = this.states[currentState].transitions[symbolSequence[i]] || currentState; } - switch (opt.moduleType) { - case "js": - code = this.generateModule(opt); - break; - case "amd": - code = this.generateAMDModule(opt); - break; - default: - code = this.generateCommonJSModule(opt); - break; + return currentState; +}; + +// Navigate through parser states and record the path taken +LALRGenerator.prototype.gotoStateWithPath = function(startState, symbolSequence) { + var currentState = parseInt(startState, 10); + var path = []; + for (var i = 0; i < symbolSequence.length; i++) { + var transition = symbolSequence[i] ? currentState + ":" + symbolSequence[i] : ''; + if (transition) this.lookahead.nonterminalMap[transition] = currentState; + path.push(transition); + currentState = this.states[currentState].transitions[symbolSequence[i]] || currentState; + this.terminalMap[transition] = symbolSequence[i]; } + return { path: path, endState: currentState }; +}; - return code; +// Build augmented grammar for lookahead computation +LALRGenerator.prototype.buildAugmentedGrammar = function() { + var self = this; + var newg = this.lookahead; + + this.states.forEach(function(state, i) { + state.list.forEach(function(item) { + if (item.dot === 0) { + var symbol = i + ":" + item.production.symbol; + self.terminalMap[symbol] = item.production.symbol; + newg.nonterminalMap[symbol] = i; + if (!newg.nonterminals[symbol]) { + newg.nonterminals[symbol] = new Nonterminal(symbol); + } + var pathInfo = self.gotoStateWithPath(i, item.production.handle); + var p = new Production(symbol, pathInfo.path, newg.productions.length); + newg.productions.push(p); + newg.nonterminals[symbol].productions.push(p); + + var handle = item.production.handle.join(' '); + var handleToSymbols = self.states[pathInfo.endState].handleToSymbols; + if (!handleToSymbols[handle]) { + handleToSymbols[handle] = []; + } + handleToSymbols[handle].push(symbol); + } + }); + if (state.hasConflicts) { + self.conflictStates.push(i); + } + }); }; -lrGeneratorMixin.generateAMDModule = function generateAMDModule(opt){ - opt = typal.mix.call({}, this.options, opt); - var module = this.generateModule_(); - var out = '\n\ndefine(function(require){\n' - + module.commonCode - + '\nvar parser = '+ module.moduleCode - + "\n"+this.moduleInclude - + (this.lexer && this.lexer.generateModule ? - '\n' + this.lexer.generateModule() + - '\nparser.lexer = lexer;' : '') - + '\nreturn parser;' - + '\n});' - return out; +// Propagate lookaheads from augmented grammar back to original states +LALRGenerator.prototype.unionLookaheads = function() { + var self = this; + var newg = this.lookahead; + var states = !!this.onDemandLookahead ? this.conflictStates : this.states; + + states.forEach(function(i) { + var state = typeof i === 'number' ? self.states[i] : i; + if (state.reductions.length) { + state.reductions.forEach(function(item) { + var follows = {}; + for (var k = 0; k < item.follows.length; k++) { + follows[item.follows[k]] = true; + } + state.handleToSymbols[item.production.handle.join(' ')].forEach(function(symbol) { + newg.nonterminals[symbol].follows.forEach(function(symbol) { + var terminal = self.terminalMap[symbol]; + if (!follows[terminal]) { + follows[terminal] = true; + item.follows.push(terminal); + } + }); + }); + }); + } + }); }; -lrGeneratorMixin.generateCommonJSModule = function generateCommonJSModule (opt) { - opt = typal.mix.call({}, this.options, opt); +// Code generation +// Generate parser code with specified options +LALRGenerator.prototype.generate = function(opt) { + opt = Object.assign({}, this.options, opt); var moduleName = opt.moduleName || "parser"; - var out = this.generateModule(opt) - + "\n\n\nif (typeof require !== 'undefined' && typeof exports !== 'undefined') {" - + "\nexports.parser = "+moduleName+";" - + "\nexports.Parser = "+moduleName+".Parser;" - + "\nexports.parse = function () { return "+moduleName+".parse.apply("+moduleName+", arguments); };" - + "\nexports.main = "+ String(opt.moduleMain || commonjsMain) + ";" - + "\nif (typeof module !== 'undefined' && require.main === module) {\n" - + " exports.main(process.argv.slice(1));\n}" - + "\n}"; + if (!moduleName.match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) { + moduleName = "parser"; + } + return this.generateCommonJSModule(opt); +}; +// Generate CommonJS module wrapper for parser +LALRGenerator.prototype.generateCommonJSModule = function(opt) { + opt = Object.assign({}, this.options, opt); + var moduleName = opt.moduleName || "parser"; + var out = this.generateModule(opt) + + "\n\n\nif (typeof require !== 'undefined' && typeof exports !== 'undefined') {" + + "\nexports.parser = " + moduleName + ";" + + "\nexports.Parser = " + moduleName + ".Parser;" + + "\nexports.parse = function () { return " + moduleName + ".parse.apply(" + moduleName + ", arguments); };" + + "\nexports.main = function() {};" + + "\nif (typeof module !== 'undefined' && require.main === module) {\n" + + " exports.main(process.argv.slice(1));\n}" + + "\n}"; return out; }; -lrGeneratorMixin.generateModule = function generateModule (opt) { - opt = typal.mix.call({}, this.options, opt); +// Generate module wrapper for parser +LALRGenerator.prototype.generateModule = function(opt) { + opt = Object.assign({}, this.options, opt); var moduleName = opt.moduleName || "parser"; - var out = "/* parser generated by jison " + version + " */\n" - + "/*\n" - + " Returns a Parser object of the following structure:\n" - + "\n" - + " Parser: {\n" - + " yy: {}\n" - + " }\n" - + "\n" - + " Parser.prototype: {\n" - + " yy: {},\n" - + " trace: function(),\n" - + " symbols_: {associative list: name ==> number},\n" - + " terminals_: {associative list: number ==> name},\n" - + " productions_: [...],\n" - + " performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n" - + " table: [...],\n" - + " defaultActions: {...},\n" - + " parseError: function(str, hash),\n" - + " parse: function(input),\n" - + "\n" - + " lexer: {\n" - + " EOF: 1,\n" - + " parseError: function(str, hash),\n" - + " setInput: function(input),\n" - + " input: function(),\n" - + " unput: function(str),\n" - + " more: function(),\n" - + " less: function(n),\n" - + " pastInput: function(),\n" - + " upcomingInput: function(),\n" - + " showPosition: function(),\n" - + " test_match: function(regex_match_array, rule_index),\n" - + " next: function(),\n" - + " lex: function(),\n" - + " begin: function(condition),\n" - + " popState: function(),\n" - + " _currentRules: function(),\n" - + " topState: function(),\n" - + " pushState: function(condition),\n" - + "\n" - + " options: {\n" - + " ranges: boolean (optional: true ==> token location info will include a .range[] member)\n" - + " flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n" - + " backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n" - + " },\n" - + "\n" - + " performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n" - + " rules: [...],\n" - + " conditions: {associative list: name ==> set},\n" - + " }\n" - + " }\n" - + "\n" - + "\n" - + " token location info (@$, _$, etc.): {\n" - + " first_line: n,\n" - + " last_line: n,\n" - + " first_column: n,\n" - + " last_column: n,\n" - + " range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n" - + " }\n" - + "\n" - + "\n" - + " the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n" - + " text: (matched text)\n" - + " token: (the produced terminal token, if any)\n" - + " line: (yylineno)\n" - + " }\n" - + " while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n" - + " loc: (yylloc)\n" - + " expected: (string describing the set of expected tokens)\n" - + " recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n" - + " }\n" - + "*/\n"; - out += (moduleName.match(/\./) ? moduleName : "var "+moduleName) + - " = " + this.generateModuleExpr(); - + var out = "/* parser generated by jison " + version + " */\n"; + out += (moduleName.match(/\./) ? moduleName : "var " + moduleName) + + " = " + this.generateModuleExpr(); return out; }; - -lrGeneratorMixin.generateModuleExpr = function generateModuleExpr () { - var out = ''; +// Generate self-executing module expression +LALRGenerator.prototype.generateModuleExpr = function() { var module = this.generateModule_(); - - out += "(function(){\n"; + var out = "(function(){\n"; out += module.commonCode; - out += "\nvar parser = "+module.moduleCode; - out += "\n"+this.moduleInclude; - if (this.lexer && this.lexer.generateModule) { - out += this.lexer.generateModule(); - out += "\nparser.lexer = lexer;"; - } - out += "\nfunction Parser () {\n this.yy = {};\n}\n" - + "Parser.prototype = parser;" - + "parser.Parser = Parser;" - + "\nreturn new Parser;\n})();"; - + out += "\nvar parser = " + module.moduleCode; + out += "\n" + this.moduleInclude; + out += "\nfunction Parser () {\n this.yy = {};\n}\n" + + "Parser.prototype = parser;" + + "parser.Parser = Parser;" + + "\nreturn new Parser;\n})();"; return out; }; -function addTokenStack (fn) { - var parseFn = fn; - try { - var ast = esprima.parse(parseFn); - var stackAst = esprima.parse(String(tokenStackLex)).body[0]; - stackAst.id.name = 'lex'; - - var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); - - labeled[0].body = stackAst; - - return escodegen.generate(ast).replace(/_token_stack:\s?/,"").replace(/\\\\n/g,"\\n"); - } catch (e) { - return parseFn; - } -} - -// lex function that supports token stacks -function tokenStackLex() { - var token; - token = tstack.pop() || lexer.lex() || EOF; - // if token isn't its numeric value, convert - if (typeof token !== 'number') { - if (token instanceof Array) { - tstack = token; - token = tstack.pop(); - } - token = self.symbols_[token] || token; - } - return token; -} - -// returns parse function without error recovery code -function removeErrorRecovery (fn) { - var parseFn = fn; - try { - var ast = esprima.parse(parseFn); - - var labeled = JSONSelect.match(':has(:root > .label > .name:val("_handle_error"))', ast); - var reduced_code = labeled[0].body.consequent.body[3].consequent.body; - reduced_code[0] = labeled[0].body.consequent.body[1]; // remove the line: error_rule_depth = locateNearestErrorRecoveryRule(state); - reduced_code[4].expression.arguments[1].properties.pop(); // remove the line: 'recoverable: error_rule_depth !== false' - labeled[0].body.consequent.body = reduced_code; - - return escodegen.generate(ast).replace(/_handle_error:\s?/,"").replace(/\\\\n/g,"\\n"); - } catch (e) { - return parseFn; - } -} - -// Generates the code of the parser module, which consists of two parts: -// - module.commonCode: initialization code that should be placed before the module -// - module.moduleCode: code that creates the module object -lrGeneratorMixin.generateModule_ = function generateModule_ () { - var parseFn = String(parser.parse); - if (!this.hasErrorRecovery) { - parseFn = removeErrorRecovery(parseFn); - } - - if (this.options['token-stack']) { - parseFn = addTokenStack(parseFn); - } - - // Generate code with fresh variable names - nextVariableId = 0; - var tableCode = this.generateTableCode(this.table); - - // Generate the initialization code - var commonCode = tableCode.commonCode; - - // Generate the module creation code +// Generate core parser module code +LALRGenerator.prototype.generateModule_ = function() { + var tableCode = this.generateTableCode(this.stateTable); var moduleCode = "{"; moduleCode += [ - "trace: " + String(this.trace || parser.trace), + "trace: function trace() {}", "yy: {}", - "symbols_: " + JSON.stringify(this.symbols_), - "terminals_: " + JSON.stringify(this.terminals_).replace(/"([0-9]+)":/g,"$1:"), - "productions_: " + JSON.stringify(this.productions_), + "symbolMap: " + JSON.stringify(this.symbolMap), + "terminals_: " + JSON.stringify(this.terminals_).replace(/"([0-9]+)":/g, "$1:"), + "productionTable: " + JSON.stringify(this.productionTable), + "stateTable: " + tableCode.moduleCode, + "defaultActions: " + JSON.stringify(this.defaultActions).replace(/"([0-9]+)":/g, "$1:"), "performAction: " + String(this.performAction), - "table: " + tableCode.moduleCode, - "defaultActions: " + JSON.stringify(this.defaultActions).replace(/"([0-9]+)":/g,"$1:"), - "parseError: " + String(this.parseError || (this.hasErrorRecovery ? traceParseError : parser.parseError)), - "parse: " + parseFn - ].join(",\n"); + "parseError: " + String(this.parseError), + "parse: " + String(this.parse) + ].join(",\n"); moduleCode += "};"; - return { commonCode: commonCode, moduleCode: moduleCode } + return { + commonCode: tableCode.commonCode, + moduleCode: moduleCode + }; }; -// Generate code that represents the specified parser table -lrGeneratorMixin.generateTableCode = function (table) { - var moduleCode = JSON.stringify(table); - var variables = [createObjectCode]; +// Generate optimized parsing table code +LALRGenerator.prototype.generateTableCode = function(stateTable) { + // Generate compact JSON without spaces and with unquoted numeric keys + var moduleCode = JSON.stringify(stateTable, null, 0); - // Don't surround numerical property name numbers in quotes + // Remove quotes around numeric object keys moduleCode = moduleCode.replace(/"([0-9]+)"(?=:)/g, "$1"); - // Replace objects with several identical values by function calls - // e.g., { 1: [6, 7]; 3: [6, 7], 4: [6, 7], 5: 8 } = o([1, 3, 4], [6, 7], { 5: 8 }) - moduleCode = moduleCode.replace(/\{\d+:[^\}]+,\d+:[^\}]+\}/g, function (object) { - // Find the value that occurs with the highest number of keys - var value, frequentValue, key, keys = {}, keyCount, maxKeyCount = 0, - keyValue, keyValues = [], keyValueMatcher = /(\d+):([^:]+)(?=,\d+:|\})/g; - - while ((keyValue = keyValueMatcher.exec(object))) { - // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2]; - keyCount = 1; - - if (!(value in keys)) { - keys[value] = [key]; - } else { - keyCount = keys[value].push(key); - } - // Remember this value if it is the most frequent one - if (keyCount > maxKeyCount) { - maxKeyCount = keyCount; - frequentValue = value; - } - } - // Construct the object with a function call if the most frequent value occurs multiple times - if (maxKeyCount > 1) { - // Collect all non-frequent values into a remainder object - for (value in keys) { - if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { - keyValues.push(k[i] + ':' + value); - } - } - } - keyValues = keyValues.length ? ',{' + keyValues.join(',') + '}' : ''; - // Create the function call `o(keys, value, remainder)` - object = 'o([' + keys[frequentValue].join(',') + '],' + frequentValue + keyValues + ')'; - } - return object; - }); - - // Count occurrences of number lists - var list; - var lists = {}; - var listMatcher = /\[[0-9,]+\]/g; - - while (list = listMatcher.exec(moduleCode)) { - lists[list] = (lists[list] || 0) + 1; - } - - // Replace frequently occurring number lists with variables - moduleCode = moduleCode.replace(listMatcher, function (list) { - var listId = lists[list]; - // If listId is a number, it represents the list's occurrence frequency - if (typeof listId === 'number') { - // If the list does not occur frequently, represent it by the list - if (listId === 1) { - lists[list] = listId = list; - // If the list occurs frequently, represent it by a newly assigned variable - } else { - lists[list] = listId = createVariable(); - variables.push(listId + '=' + list); - } - } - return listId; - }); - - // Return the variable initialization code and the table code return { - commonCode: 'var ' + variables.join(',') + ';', + commonCode: '', moduleCode: moduleCode }; }; -// Function that extends an object with the given value for all given keys -// e.g., o([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } -var createObjectCode = 'o=function(k,v,o,l){' + - 'for(o=o||{},l=k.length;l--;o[k[l]]=v);' + - 'return o}'; - -// Creates a variable with a unique name -function createVariable() { - var id = nextVariableId++; - var name = '$V'; - - do { - name += variableTokens[id % variableTokensLength]; - id = ~~(id / variableTokensLength); - } while (id !== 0); - - return name; -} - -var nextVariableId = 0; -var variableTokens = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'; -var variableTokensLength = variableTokens.length; - -// default main method for generated commonjs modules -function commonjsMain (args) { - if (!args[1]) { - console.log('Usage: '+args[0]+' FILE'); - process.exit(1); - } - var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - return exports.parser.parse(source); -} - -// debug mixin for LR parser generators - -function printAction (a, gen) { - var s = a[0] == 1 ? 'shift token (then go to state '+a[1]+')' : - a[0] == 2 ? 'reduce by rule: '+gen.productions[a[1]] : - 'accept' ; - - return s; -} - -var lrGeneratorDebug = { - beforeparseTable: function () { - this.trace("Building parse table."); - }, - afterparseTable: function () { - var self = this; - if (this.conflicts > 0) { - this.resolutions.forEach(function (r, i) { - if (r[2].bydefault) { - self.warn('Conflict at state: ',r[0], ', token: ',r[1], "\n ", printAction(r[2].r, self), "\n ", printAction(r[2].s, self)); - } - }); - this.trace("\n"+this.conflicts+" Conflict(s) found in grammar."); - } - this.trace("Done."); - }, - aftercanonicalCollection: function (states) { - var trace = this.trace; - trace("\nItem sets\n------"); - - states.forEach(function (state, i) { - trace("\nitem set",i,"\n"+state.join("\n"), '\ntransitions -> ', JSON.stringify(state.edges)); - }); - } -}; - -var parser = typal.beget(); - -lrGeneratorMixin.createParser = function createParser () { - - var p = eval(this.generateModuleExpr()); - - // for debugging - p.productions = this.productions; - - var self = this; - function bind(method) { - return function() { - self.lexer = p.lexer; - return self[method].apply(self, arguments); - }; - } - - // backwards compatability - p.lexer = this.lexer; - p.generate = bind('generate'); - p.generateAMDModule = bind('generateAMDModule'); - p.generateModule = bind('generateModule'); - p.generateCommonJSModule = bind('generateCommonJSModule'); - - return p; -}; - -parser.trace = generator.trace; -parser.warn = generator.warn; -parser.error = generator.error; - -function traceParseError (err, hash) { - this.trace(err); -} -function parseError (str, hash) { +// Handle parsing errors with context information +LALRGenerator.prototype.parseError = function(str, hash) { if (hash.recoverable) { this.trace(str); } else { @@ -1363,45 +1046,40 @@ function parseError (str, hash) { error.hash = hash; throw error; } -} - -parser.parseError = lrGeneratorMixin.parseError = parseError; - -parser.parse = function parse (input) { - var self = this, - stack = [0], - tstack = [], // token stack - vstack = [null], // semantic value stack - lstack = [], // location stack - table = this.table, - yytext = '', - yylineno = 0, - yyleng = 0, - recovering = 0, - TERROR = 2, - EOF = 1; - - var args = lstack.slice.call(arguments, 1); +}; - //this.reductionCount = this.shiftCount = 0; +// Parse input string using generated LALR(1) parser +LALRGenerator.prototype.parse = function(input) { + var self = this; + var stk = [0]; + var val = [null]; + var loc = []; + var stateTable = this.stateTable; + var yytext = ''; + var yylineno = 0; + var yyleng = 0; + var recovering = 0; + var TERROR = 2; + var EOF = 1; var lexer = Object.create(this.lexer); var sharedState = { yy: {} }; - // copy state + for (var k in this.yy) { - if (Object.prototype.hasOwnProperty.call(this.yy, k)) { - sharedState.yy[k] = this.yy[k]; - } + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } } lexer.setInput(input, sharedState.yy); sharedState.yy.lexer = lexer; sharedState.yy.parser = this; - if (typeof lexer.yylloc == 'undefined') { + + if (typeof lexer.yylloc === 'undefined') { lexer.yylloc = {}; } var yyloc = lexer.yylloc; - lstack.push(yyloc); + loc.push(yyloc); var ranges = lexer.options && lexer.options.ranges; @@ -1411,138 +1089,73 @@ parser.parse = function parse (input) { this.parseError = Object.getPrototypeOf(this).parseError; } - function popStack (n) { - stack.length = stack.length - 2 * n; - vstack.length = vstack.length - n; - lstack.length = lstack.length - n; - } - -_token_stack: - var lex = function () { - var token; - token = lexer.lex() || EOF; - // if token isn't its numeric value, convert + var lex = function() { + var token = lexer.lex() || EOF; if (typeof token !== 'number') { - token = self.symbols_[token] || token; + token = self.symbolMap[token] || token; } return token; - } + }; + + var symbol, preErrorSymbol, state, action, r, yyval = {}; + var p, len, newState, expected; - var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; while (true) { - // retreive state number from top of stack - state = stack[stack.length - 1]; + var stkLen = stk.length; + state = stk[stkLen - 1]; - // use default actions if available if (this.defaultActions[state]) { action = this.defaultActions[state]; } else { - if (symbol === null || typeof symbol == 'undefined') { + if (symbol === null || typeof symbol === 'undefined') { symbol = lex(); } - // read action for current state and first input - action = table[state] && table[state][symbol]; + action = stateTable[state] && stateTable[state][symbol]; } -_handle_error: - // handle parse error if (typeof action === 'undefined' || !action.length || !action[0]) { - var error_rule_depth; var errStr = ''; - // Return the rule stack depth where the nearest error rule can be found. - // Return FALSE when no error recovery rule was found. - function locateNearestErrorRecoveryRule(state) { - var stack_probe = stack.length - 1; - var depth = 0; - - // try to recover from error - for(;;) { - // check for error recovery rule in this state - if ((TERROR.toString()) in table[state]) { - return depth; - } - if (state === 0 || stack_probe < 2) { - return false; // No suitable error recovery rule available. - } - stack_probe -= 2; // popStack(1): [symbol, action] - state = stack[stack_probe]; - ++depth; - } - } - if (!recovering) { - // first see if there's any chance at hitting an error recovery rule: - error_rule_depth = locateNearestErrorRecoveryRule(state); - - // Report error expected = []; - for (p in table[state]) { if (this.terminals_[p] && p > TERROR) { - expected.push("'"+this.terminals_[p]+"'"); + expected.push("'" + this.terminals_[p] + "'"); + for (p in stateTable[state]) { } } if (lexer.showPosition) { - errStr = 'Parse error on line '+(yylineno+1)+":\n"+lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + (this.terminals_[symbol] || symbol)+ "'"; + errStr = 'Parse error on line ' + (yylineno + 1) + ":\n" + + lexer.showPosition() + "\nExpecting " + expected.join(', ') + + ", got '" + (this.terminals_[symbol] || symbol) + "'"; } else { - errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " + - (symbol == EOF ? "end of input" : - ("'"+(this.terminals_[symbol] || symbol)+"'")); + errStr = 'Parse error on line ' + (yylineno + 1) + ": Unexpected " + + (symbol === EOF ? "end of input" : + ("'" + (this.terminals_[symbol] || symbol) + "'")); } this.parseError(errStr, { text: lexer.match, token: this.terminals_[symbol] || symbol, line: lexer.yylineno, loc: yyloc, - expected: expected, - recoverable: (error_rule_depth !== false) + expected: expected }); - } else if (preErrorSymbol !== EOF) { - error_rule_depth = locateNearestErrorRecoveryRule(state); - } - - // just recovered from another error - if (recovering == 3) { - if (symbol === EOF || preErrorSymbol === EOF) { - throw new Error(errStr || 'Parsing halted while starting to recover from another error.'); - } - - // discard current lookahead and grab another - yyleng = lexer.yyleng; - yytext = lexer.yytext; - yylineno = lexer.yylineno; - yyloc = lexer.yylloc; - symbol = lex(); - } - - // try to recover from error - if (error_rule_depth === false) { - throw new Error(errStr || 'Parsing halted. No suitable error recovery rule available.'); } - popStack(error_rule_depth); - preErrorSymbol = (symbol == TERROR ? null : symbol); // save the lookahead token - symbol = TERROR; // insert generic error symbol as new lookahead - state = stack[stack.length-1]; - action = table[state] && table[state][TERROR]; - recovering = 3; // allow 3 real symbols to be shifted before reporting a new error + throw new Error(errStr); } - // this shouldn't happen, unless resolve defaults are off if (action[0] instanceof Array && action.length > 1) { - throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol); + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); } switch (action[0]) { case 1: // shift - //this.shiftCount++; - - stack.push(symbol); - vstack.push(lexer.yytext); - lstack.push(lexer.yylloc); - stack.push(action[1]); // push state + stk.push(symbol); + val.push(lexer.yytext); + loc.push(lexer.yylloc); + stk.push(action[1]); symbol = null; - if (!preErrorSymbol) { // normal execution/no error + if (!preErrorSymbol) { yyleng = lexer.yyleng; yytext = lexer.yytext; yylineno = lexer.yylineno; @@ -1551,365 +1164,92 @@ _handle_error: recovering--; } } else { - // error just occurred, resume old lookahead f/ before error symbol = preErrorSymbol; preErrorSymbol = null; } break; - case 2: - // reduce - //this.reductionCount++; - - len = this.productions_[action[1]][1]; - - // perform semantic action - yyval.$ = vstack[vstack.length-len]; // default to $$ = $1 - // default location, uses first token for firsts, last for lasts + case 2: // reduce + len = this.productionTable[action[1]][1]; + var valLen = val.length; + var locLen = loc.length; + yyval.$ = val[valLen - len]; + var locFirst = loc[locLen - (len || 1)]; + var locLast = loc[locLen - 1]; yyval._$ = { - first_line: lstack[lstack.length-(len||1)].first_line, - last_line: lstack[lstack.length-1].last_line, - first_column: lstack[lstack.length-(len||1)].first_column, - last_column: lstack[lstack.length-1].last_column + first_line: locFirst.first_line, + last_line: locLast.last_line, + first_column: locFirst.first_column, + last_column: locLast.last_column }; if (ranges) { - yyval._$.range = [lstack[lstack.length-(len||1)].range[0], lstack[lstack.length-1].range[1]]; + yyval._$.range = [locFirst.range[0], locLast.range[1]]; } - r = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args)); + r = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, + action[1], val, loc]); if (typeof r !== 'undefined') { return r; } - // pop off stack if (len) { - stack = stack.slice(0,-1*len*2); - vstack = vstack.slice(0, -1*len); - lstack = lstack.slice(0, -1*len); + stk.length = stk.length - (len * 2); + val.length = val.length - len; + loc.length = loc.length - len; } - stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce) - vstack.push(yyval.$); - lstack.push(yyval._$); - // goto new state = table[STATE][NONTERMINAL] - newState = table[stack[stack.length-2]][stack[stack.length-1]]; - stack.push(newState); + stk.push(this.productionTable[action[1]][0]); + val.push(yyval.$); + loc.push(yyval._$); + stkLen = stk.length; + newState = stateTable[stk[stkLen - 2]][stk[stkLen - 1]]; + stk.push(newState); break; - case 3: - // accept + case 3: // accept return true; } - } - - return true; }; -parser.init = function parser_init (dict) { - this.table = dict.table; - this.defaultActions = dict.defaultActions; - this.performAction = dict.performAction; - this.productions_ = dict.productions_; - this.symbols_ = dict.symbols_; - this.terminals_ = dict.terminals_; -}; +// Debug tracing function (no-op by default) +LALRGenerator.prototype.trace = function() {}; -/* - * LR(0) Parser - * */ +// Create executable parser instance from generated code +LALRGenerator.prototype.createParser = function() { + var p = eval(this.generateModuleExpr()); + p.productions = this.productions; -var lr0 = generator.beget(lookaheadMixin, lrGeneratorMixin, { - type: "LR(0)", - afterconstructor: function lr0_afterconstructor () { - this.buildTable(); + var self = this; + function bind(method) { + return function() { + self.lexer = p.lexer; + return self[method].apply(self, arguments); + }; } -}); -var LR0Generator = exports.LR0Generator = lr0.construct(); - -/* - * Simple LALR(1) - * */ - -var lalr = generator.beget(lookaheadMixin, lrGeneratorMixin, { - type: "LALR(1)", - - afterconstructor: function (grammar, options) { - if (this.DEBUG) this.mix(lrGeneratorDebug, lalrGeneratorDebug); // mixin debug methods - - options = options || {}; - this.states = this.canonicalCollection(); - this.terms_ = {}; + p.lexer = this.lexer; + p.generate = bind('generate'); + p.generateModule = bind('generateModule'); + p.generateCommonJSModule = bind('generateCommonJSModule'); - var newg = this.newg = typal.beget(lookaheadMixin,{ - oldg: this, - trace: this.trace, - nterms_: {}, - DEBUG: false, - go_: function (r, B) { - r = r.split(":")[0]; // grab state # - B = B.map(function (b) { return b.slice(b.indexOf(":")+1); }); - return this.oldg.go(r, B); - } - }); - newg.nonterminals = {}; - newg.productions = []; - - this.inadequateStates = []; - - // if true, only lookaheads in inadequate states are computed (faster, larger table) - // if false, lookaheads for all reductions will be computed (slower, smaller table) - this.onDemandLookahead = options.onDemandLookahead || false; - - this.buildNewGrammar(); - newg.computeLookaheads(); - this.unionLookaheads(); - - this.table = this.parseTable(this.states); - this.defaultActions = findDefaults(this.table); - }, - - lookAheads: function LALR_lookaheads (state, item) { - return (!!this.onDemandLookahead && !state.inadequate) ? this.terminals : item.follows; - }, - go: function LALR_go (p, w) { - var q = parseInt(p, 10); - for (var i=0;i (http://zaa.ch)", + "contributors": [ + { + "name": "Steve Shreeve", + "email": "steve.shreeve@gmail.com" + } + ], "name": "jison", "description": "A parser generator with Bison's API", - "version": "0.4.18", + "version": "0.5.0", "license": "MIT", "keywords": [ "jison", @@ -30,17 +36,8 @@ "node": ">=0.4" }, "dependencies": { - "JSONSelect": "0.4.0", - "esprima": "1.1.x", - "escodegen": "1.3.x", - "jison-lex": "0.3.x", - "ebnf-parser": "0.1.10", - "lex-parser": "~0.1.3", - "nomnom": "1.5.2", - "cjson": "0.3.0" }, "devDependencies": { - "test": "0.6.x", "jison": "0.4.x", "uglify-js": "~2.4.0", "browserify": "2.x.x" From 30ea7210d048539bfb291f6d1ff19510908f89cd Mon Sep 17 00:00:00 2001 From: Steve Shreeve Date: Wed, 16 Jul 2025 09:44:42 -0600 Subject: [PATCH 3/4] Not needed for this --- examples/README | 2 - examples/ansic.jison | 418 --------------------- examples/basic.jison | 11 - examples/basic2.jison | 10 - examples/basic2_lex.jison | 18 - examples/basic_lex.jison | 20 -- examples/calculator.jison | 73 ---- examples/calculator.json | 51 --- examples/classy.jison | 84 ----- examples/classy.jisonlex | 39 -- examples/classy_ast.jison | 124 ------- examples/classy_test.src | 7 - examples/dism.jison | 39 -- examples/dism_lr0.jison | 35 -- examples/inherited.y | 35 -- examples/jscore.jison | 599 ------------------------------- examples/json.js | 78 ---- examples/json_ast.js | 79 ---- examples/lambdacalc.jison | 54 --- examples/nv_classy_ast.jison | 126 ------- examples/phraser.jison | 46 --- examples/precedence.jison | 32 -- examples/reduce_conflict.jison | 23 -- examples/semwhitespace.jison | 67 ---- examples/semwhitespace_ex.src | 12 - examples/semwhitespace_lex.jison | 55 --- examples/tikiwikiparser.jison | 211 ----------- 27 files changed, 2348 deletions(-) delete mode 100644 examples/README delete mode 100644 examples/ansic.jison delete mode 100644 examples/basic.jison delete mode 100644 examples/basic2.jison delete mode 100644 examples/basic2_lex.jison delete mode 100644 examples/basic_lex.jison delete mode 100644 examples/calculator.jison delete mode 100644 examples/calculator.json delete mode 100644 examples/classy.jison delete mode 100644 examples/classy.jisonlex delete mode 100644 examples/classy_ast.jison delete mode 100644 examples/classy_test.src delete mode 100644 examples/dism.jison delete mode 100644 examples/dism_lr0.jison delete mode 100644 examples/inherited.y delete mode 100644 examples/jscore.jison delete mode 100644 examples/json.js delete mode 100644 examples/json_ast.js delete mode 100644 examples/lambdacalc.jison delete mode 100644 examples/nv_classy_ast.jison delete mode 100644 examples/phraser.jison delete mode 100644 examples/precedence.jison delete mode 100644 examples/reduce_conflict.jison delete mode 100644 examples/semwhitespace.jison delete mode 100644 examples/semwhitespace_ex.src delete mode 100644 examples/semwhitespace_lex.jison delete mode 100755 examples/tikiwikiparser.jison diff --git a/examples/README b/examples/README deleted file mode 100644 index a31ac7183..000000000 --- a/examples/README +++ /dev/null @@ -1,2 +0,0 @@ -Use Jison to generate parsers from an example, e.g.: - $ node ../lib/cli.js basic_lex.jison diff --git a/examples/ansic.jison b/examples/ansic.jison deleted file mode 100644 index c8eccd064..000000000 --- a/examples/ansic.jison +++ /dev/null @@ -1,418 +0,0 @@ -%token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF -%token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP -%token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN -%token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN -%token XOR_ASSIGN OR_ASSIGN TYPE_NAME - -%token TYPEDEF EXTERN STATIC AUTO REGISTER -%token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID -%token STRUCT UNION ENUM ELLIPSIS - -%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN - -%nonassoc IF_WITHOUT_ELSE -%nonassoc ELSE - -%start translation_unit -%% - -primary_expression - : IDENTIFIER - | CONSTANT - | STRING_LITERAL - | '(' expression ')' - ; - -postfix_expression - : primary_expression - | postfix_expression '[' expression ']' - | postfix_expression '(' ')' - | postfix_expression '(' argument_expression_list ')' - | postfix_expression '.' IDENTIFIER - | postfix_expression PTR_OP IDENTIFIER - | postfix_expression INC_OP - | postfix_expression DEC_OP - ; - -argument_expression_list - : assignment_expression - | argument_expression_list ',' assignment_expression - ; - -unary_expression - : postfix_expression - | INC_OP unary_expression - | DEC_OP unary_expression - | unary_operator cast_expression - | SIZEOF unary_expression - | SIZEOF '(' type_name ')' - ; - -unary_operator - : '&' - | '*' - | '+' - | '-' - | '~' - | '!' - ; - -cast_expression - : unary_expression - | '(' type_name ')' cast_expression - ; - -multiplicative_expression - : cast_expression - | multiplicative_expression '*' cast_expression - | multiplicative_expression '/' cast_expression - | multiplicative_expression '%' cast_expression - ; - -additive_expression - : multiplicative_expression - | additive_expression '+' multiplicative_expression - | additive_expression '-' multiplicative_expression - ; - -shift_expression - : additive_expression - | shift_expression LEFT_OP additive_expression - | shift_expression RIGHT_OP additive_expression - ; - -relational_expression - : shift_expression - | relational_expression '<' shift_expression - | relational_expression '>' shift_expression - | relational_expression LE_OP shift_expression - | relational_expression GE_OP shift_expression - ; - -equality_expression - : relational_expression - | equality_expression EQ_OP relational_expression - | equality_expression NE_OP relational_expression - ; - -and_expression - : equality_expression - | and_expression '&' equality_expression - ; - -exclusive_or_expression - : and_expression - | exclusive_or_expression '^' and_expression - ; - -inclusive_or_expression - : exclusive_or_expression - | inclusive_or_expression '|' exclusive_or_expression - ; - -logical_and_expression - : inclusive_or_expression - | logical_and_expression AND_OP inclusive_or_expression - ; - -logical_or_expression - : logical_and_expression - | logical_or_expression OR_OP logical_and_expression - ; - -conditional_expression - : logical_or_expression - | logical_or_expression '?' expression ':' conditional_expression - ; - -assignment_expression - : conditional_expression - | unary_expression assignment_operator assignment_expression - ; - -assignment_operator - : '=' - | MUL_ASSIGN - | DIV_ASSIGN - | MOD_ASSIGN - | ADD_ASSIGN - | SUB_ASSIGN - | LEFT_ASSIGN - | RIGHT_ASSIGN - | AND_ASSIGN - | XOR_ASSIGN - | OR_ASSIGN - ; - -expression - : assignment_expression - | expression ',' assignment_expression - ; - -constant_expression - : conditional_expression - ; - -declaration - : declaration_specifiers ';' - | declaration_specifiers init_declarator_list ';' - ; - -declaration_specifiers - : storage_class_specifier - | storage_class_specifier declaration_specifiers - | type_specifier - | type_specifier declaration_specifiers - | type_qualifier - | type_qualifier declaration_specifiers - ; - -init_declarator_list - : init_declarator - | init_declarator_list ',' init_declarator - ; - -init_declarator - : declarator - | declarator '=' initializer - ; - -storage_class_specifier - : TYPEDEF - | EXTERN - | STATIC - | AUTO - | REGISTER - ; - -type_specifier - : VOID - | CHAR - | SHORT - | INT - | LONG - | FLOAT - | DOUBLE - | SIGNED - | UNSIGNED - | struct_or_union_specifier - | enum_specifier - | TYPE_NAME - ; - -struct_or_union_specifier - : struct_or_union IDENTIFIER '{' struct_declaration_list '}' - | struct_or_union '{' struct_declaration_list '}' - | struct_or_union IDENTIFIER - ; - -struct_or_union - : STRUCT - | UNION - ; - -struct_declaration_list - : struct_declaration - | struct_declaration_list struct_declaration - ; - -struct_declaration - : specifier_qualifier_list struct_declarator_list ';' - ; - -specifier_qualifier_list - : type_specifier specifier_qualifier_list - | type_specifier - | type_qualifier specifier_qualifier_list - | type_qualifier - ; - -struct_declarator_list - : struct_declarator - | struct_declarator_list ',' struct_declarator - ; - -struct_declarator - : declarator - | ':' constant_expression - | declarator ':' constant_expression - ; - -enum_specifier - : ENUM '{' enumerator_list '}' - | ENUM IDENTIFIER '{' enumerator_list '}' - | ENUM IDENTIFIER - ; - -enumerator_list - : enumerator - | enumerator_list ',' enumerator - ; - -enumerator - : IDENTIFIER - | IDENTIFIER '=' constant_expression - ; - -type_qualifier - : CONST - | VOLATILE - ; - -declarator - : pointer direct_declarator - | direct_declarator - ; - -direct_declarator - : IDENTIFIER - | '(' declarator ')' - | direct_declarator '[' constant_expression ']' - | direct_declarator '[' ']' - | direct_declarator '(' parameter_type_list ')' - | direct_declarator '(' identifier_list ')' - | direct_declarator '(' ')' - ; - -pointer - : '*' - | '*' type_qualifier_list - | '*' pointer - | '*' type_qualifier_list pointer - ; - -type_qualifier_list - : type_qualifier - | type_qualifier_list type_qualifier - ; - - -parameter_type_list - : parameter_list - | parameter_list ',' ELLIPSIS - ; - -parameter_list - : parameter_declaration - | parameter_list ',' parameter_declaration - ; - -parameter_declaration - : declaration_specifiers declarator - | declaration_specifiers abstract_declarator - | declaration_specifiers - ; - -identifier_list - : IDENTIFIER - | identifier_list ',' IDENTIFIER - ; - -type_name - : specifier_qualifier_list - | specifier_qualifier_list abstract_declarator - ; - -abstract_declarator - : pointer - | direct_abstract_declarator - | pointer direct_abstract_declarator - ; - -direct_abstract_declarator - : '(' abstract_declarator ')' - | '[' ']' - | '[' constant_expression ']' - | direct_abstract_declarator '[' ']' - | direct_abstract_declarator '[' constant_expression ']' - | '(' ')' - | '(' parameter_type_list ')' - | direct_abstract_declarator '(' ')' - | direct_abstract_declarator '(' parameter_type_list ')' - ; - -initializer - : assignment_expression - | '{' initializer_list '}' - | '{' initializer_list ',' '}' - ; - -initializer_list - : initializer - | initializer_list ',' initializer - ; - -statement - : labeled_statement - | compound_statement - | expression_statement - | selection_statement - | iteration_statement - | jump_statement - ; - -labeled_statement - : IDENTIFIER ':' statement - | CASE constant_expression ':' statement - | DEFAULT ':' statement - ; - -compound_statement - : '{' '}' - | '{' statement_list '}' - | '{' declaration_list '}' - | '{' declaration_list statement_list '}' - ; - -declaration_list - : declaration - | declaration_list declaration - ; - -statement_list - : statement - | statement_list statement - ; - -expression_statement - : ';' - | expression ';' - ; - -selection_statement - : IF '(' expression ')' statement %prec IF_WITHOUT_ELSE - | IF '(' expression ')' statement ELSE statement - | SWITCH '(' expression ')' statement - ; - -iteration_statement - : WHILE '(' expression ')' statement - | DO statement WHILE '(' expression ')' ';' - | FOR '(' expression_statement expression_statement ')' statement - | FOR '(' expression_statement expression_statement expression ')' statement - ; - -jump_statement - : GOTO IDENTIFIER ';' - | CONTINUE ';' - | BREAK ';' - | RETURN ';' - | RETURN expression ';' - ; - -translation_unit - : external_declaration - | translation_unit external_declaration - ; - -external_declaration - : function_definition - | declaration - ; - -function_definition - : declaration_specifiers declarator declaration_list compound_statement - | declaration_specifiers declarator compound_statement - | declarator declaration_list compound_statement - | declarator compound_statement - ; diff --git a/examples/basic.jison b/examples/basic.jison deleted file mode 100644 index c23c801e0..000000000 --- a/examples/basic.jison +++ /dev/null @@ -1,11 +0,0 @@ -%% - -E - : E PLUS T - | T - ; - -T - : ZERO - ; - diff --git a/examples/basic2.jison b/examples/basic2.jison deleted file mode 100644 index f47e179e9..000000000 --- a/examples/basic2.jison +++ /dev/null @@ -1,10 +0,0 @@ - -/* description: Basic grammar that contains a nullable A nonterminal. */ - -%% - -A - : A x - | - ; - diff --git a/examples/basic2_lex.jison b/examples/basic2_lex.jison deleted file mode 100644 index acb0c6365..000000000 --- a/examples/basic2_lex.jison +++ /dev/null @@ -1,18 +0,0 @@ - -/* description: Basic grammar that contains a nullable A nonterminal. */ - -%lex -%% - -\s+ {/* skip whitespace */} -"x" {return 'x';} - -/lex - -%% - -A - : A x - | - ; - diff --git a/examples/basic_lex.jison b/examples/basic_lex.jison deleted file mode 100644 index ed3d31076..000000000 --- a/examples/basic_lex.jison +++ /dev/null @@ -1,20 +0,0 @@ -%lex - -%% -\s+ {/* skip whitespace */} -[0-9]+ {return 'NAT';} -"+" {return '+';} - -/lex - -%% - -E - : E '+' T - | T - ; - -T - : NAT - ; - diff --git a/examples/calculator.jison b/examples/calculator.jison deleted file mode 100644 index 2ad240fe2..000000000 --- a/examples/calculator.jison +++ /dev/null @@ -1,73 +0,0 @@ - -/* description: Parses and executes mathematical expressions. */ - -/* lexical grammar */ -%lex -%% - -\s+ /* skip whitespace */ -[0-9]+("."[0-9]+)?\b return 'NUMBER' -"*" return '*' -"/" return '/' -"-" return '-' -"+" return '+' -"^" return '^' -"!" return '!' -"%" return '%' -"(" return '(' -")" return ')' -"PI" return 'PI' -"E" return 'E' -<> return 'EOF' -. return 'INVALID' - -/lex - -/* operator associations and precedence */ - -%left '+' '-' -%left '*' '/' -%left '^' -%right '!' -%right '%' -%left UMINUS - -%start expressions - -%% /* language grammar */ - -expressions - : e EOF - { typeof console !== 'undefined' ? console.log($1) : print($1); - return $1; } - ; - -e - : e '+' e - {$$ = $1+$3;} - | e '-' e - {$$ = $1-$3;} - | e '*' e - {$$ = $1*$3;} - | e '/' e - {$$ = $1/$3;} - | e '^' e - {$$ = Math.pow($1, $3);} - | e '!' - {{ - $$ = (function fact (n) { return n==0 ? 1 : fact(n-1) * n })($1); - }} - | e '%' - {$$ = $1/100;} - | '-' e %prec UMINUS - {$$ = -$2;} - | '(' e ')' - {$$ = $2;} - | NUMBER - {$$ = Number(yytext);} - | E - {$$ = Math.E;} - | PI - {$$ = Math.PI;} - ; - diff --git a/examples/calculator.json b/examples/calculator.json deleted file mode 100644 index bc09aa7c1..000000000 --- a/examples/calculator.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "comment": "JSON Math Parser", - // JavaScript comments also work - - "lex": { - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["[0-9]+(?:\\.[0-9]+)?\\b", "return 'NUMBER'"], - ["\\*", "return '*'"], - ["\\/", "return '/'"], - ["-", "return '-'"], - ["\\+", "return '+'"], - ["\\^", "return '^'"], - ["!", "return '!'"], - ["%", "return '%'"], - ["\\(", "return '('"], - ["\\)", "return ')'"], - ["PI\\b", "return 'PI'"], - ["E\\b", "return 'E'"], - ["$", "return 'EOF'"] - ] - }, - - "operators": [ - ["left", "+", "-"], - ["left", "*", "/"], - ["left", "^"], - ["right", "!"], - ["right", "%"], - ["left", "UMINUS"] - ], - - "bnf": { - "expressions": [["e EOF", "return $1"]], - - "e" :[ - ["e + e", "$$ = $1+$3"], - ["e - e", "$$ = $1-$3"], - ["e * e", "$$ = $1*$3"], - ["e / e", "$$ = $1/$3"], - ["e ^ e", "$$ = Math.pow($1, $3)"], - ["e !", "$$ = (function(n) {if(n==0) return 1; return arguments.callee(n-1) * n})($1)"], - ["e %", "$$ = $1/100"], - ["- e", "$$ = -$2", {"prec": "UMINUS"}], - ["( e )", "$$ = $2"], - ["NUMBER", "$$ = Number(yytext)"], - ["E", "$$ = Math.E"], - ["PI", "$$ = Math.PI"] - ] - } -} diff --git a/examples/classy.jison b/examples/classy.jison deleted file mode 100644 index 295bfe6d9..000000000 --- a/examples/classy.jison +++ /dev/null @@ -1,84 +0,0 @@ - -/* description: ClassyLang grammar. Very classy. */ -/* - To build parser: - - $ ./bin/jison examples/classy.jison examples/classy.jisonlex - -*/ - - -/* author: Zach Carter */ - -%right ASSIGN -%left OR -%nonassoc EQUALITY GREATER -%left PLUS MINUS -%left TIMES -%right NOT -%left DOT - -%% - -pgm - : cdl MAIN LBRACE vdl el RBRACE ENDOFFILE - ; - -cdl - : c cdl - | - ; - -c - : CLASS id EXTENDS id LBRACE vdl mdl RBRACE - ; - -vdl - : VAR t id SEMICOLON vdl - | - ; - -mdl - : t id LPAREN t id RPAREN LBRACE vdl el RBRACE mdl - | - ; - -t - : NATTYPE - | id - ; - -id - : ID - ; - -el - : e SEMICOLON el - | e SEMICOLON - ; - -e - : NATLITERAL - | NUL - | id - | NEW id - | THIS - | IF LPAREN e RPAREN LBRACE el RBRACE ELSE LBRACE el RBRACE - | FOR LPAREN e SEMICOLON e SEMICOLON e RPAREN LBRACE el RBRACE - | READNAT LPAREN RPAREN - | PRINTNAT LPAREN e RPAREN - | e PLUS e - | e MINUS e - | e TIMES e - | e EQUALITY e - | e GREATER e - | NOT e - | e OR e - | e DOT id - | id ASSIGN e - | e DOT id ASSIGN e - | id LPAREN e RPAREN - | e DOT id LPAREN e RPAREN - | LPAREN e RPAREN - ; - diff --git a/examples/classy.jisonlex b/examples/classy.jisonlex deleted file mode 100644 index e0e7edf6d..000000000 --- a/examples/classy.jisonlex +++ /dev/null @@ -1,39 +0,0 @@ -digit [0-9] -id [a-zA-Z][a-zA-Z0-9]* - -%% -"//".* /* ignore comment */ -"main" return 'MAIN'; -"class" return 'CLASS'; -"extends" return 'EXTENDS'; -"nat" return 'NATTYPE'; -"if" return 'IF'; -"else" return 'ELSE'; -"for" return 'FOR'; -"printNat" return 'PRINTNAT'; -"readNat" return 'READNAT'; -"this" return 'THIS'; -"new" return 'NEW'; -"var" return 'VAR'; -"null" return 'NUL'; -{digit}+ return 'NATLITERAL'; -{id} return 'ID'; -"==" return 'EQUALITY'; -"=" return 'ASSIGN'; -"+" return 'PLUS'; -"-" return 'MINUS'; -"*" return 'TIMES'; -">" return 'GREATER'; -"||" return 'OR'; -"!" return 'NOT'; -"." return 'DOT'; -"{" return 'LBRACE'; -"}" return 'RBRACE'; -"(" return 'LPAREN'; -")" return 'RPAREN'; -";" return 'SEMICOLON'; -\s+ /* skip whitespace */ -"." throw 'Illegal character'; -<> return 'ENDOFFILE'; - - diff --git a/examples/classy_ast.jison b/examples/classy_ast.jison deleted file mode 100644 index eab423981..000000000 --- a/examples/classy_ast.jison +++ /dev/null @@ -1,124 +0,0 @@ -/* description: ClassyLang grammar with AST-building actions. Very classy. */ -/* - To build parser: - - $ ./bin/jison examples/classy_ast.jison examples/classy.jisonlex - -*/ - -/* author: Zach Carter */ - -%{ - function prependChild(node, child){ - node.splice(2,0,child); - return node; - } -%} - -%right ASSIGN -%left OR -%nonassoc EQUALITY GREATER -%left PLUS MINUS -%left TIMES -%right NOT -%left DOT - -%% - -pgm - : cdl MAIN LBRACE vdl el RBRACE ENDOFFILE - {{$$ = ['PROGRAM',{},$1,$4,$5]; return $$;}} - ; - -cdl - : c cdl - {$$ = prependChild($2, $1);} - | - {{$$ = ['CLASS_DECL_LIST',{}];}} - ; - -c - : CLASS id EXTENDS id LBRACE vdl mdl RBRACE - {{$$ = ['CLASS_DECL',{},$2,$4,$6,$7];}} - ; - -vdl - : VAR t id SEMICOLON vdl - {{$$ = prependChild($5, ['VAR_DECL',{},$2,$3]);}} - | - {{$$ = ['VAR_DECL_LIST',{}];}} - ; - -mdl - : t id LPAREN t id RPAREN LBRACE vdl el RBRACE mdl - {{$$ = prependChild($11, ['METHOD_DECL',{},$1,$2,$4,$5,$8,$9]);}} - | - {{$$ = ['METHOD_DECL_LIST',{}];}} - ; - -t - : NATTYPE - {{$$ = ['NAT_TYPE',{}];}} - | id - {$$ = $1} - ; - -id - : ID - {{$$ = ['AST_ID',{val:yytext}]}} - ; - -el - : e SEMICOLON el - {$$ = prependChild($3, $1);} - | e SEMICOLON - {{$$ = ['EXPR_LIST',{},$1];}} - ; - -e - : NATLITERAL - {{$$ = ['NAT_LITERAL_EXPR',{val:parseInt(yytext)}];}} - | NUL - {{$$ = ['NULL_EXPR',{}];}} - | id - {{$$ = ['ID_EXPR',{},$1];}} - | NEW id - {{$$ = ['NEW_EXPR',{},$2];}} - | THIS - {{$$ = ['THIS_EXPR',{}];}} - | IF LPAREN e RPAREN LBRACE el RBRACE ELSE LBRACE el RBRACE - {{$$ = ['IF_THEN_ELSE_EXPR',{},$3,$6,$10];}} - | FOR LPAREN e SEMICOLON e SEMICOLON e RPAREN LBRACE el RBRACE - {{$$ = ['FOR_EXPR',{},$3,$5,$7,$10];}} - | READNAT LPAREN RPAREN - {{$$ = ['READ_EXPR',{}];}} - | PRINTNAT LPAREN e RPAREN - {{$$ = ['PRINT_EXPR',{},$3];}} - | e PLUS e - {{$$ = ['PLUS_EXPR',{},$1,$3];}} - | e MINUS e - {{$$ = ['MINUS_EXPR',{},$1,$3];}} - | e TIMES e - {{$$ = ['TIMES_EXPR',{},$1,$3];}} - | e EQUALITY e - {{$$ = ['EQUALITY_EXPR',{},$1,$3];}} - | e GREATER e - {{$$ = ['GREATER_THAN_EXPR',{},$1,$3];}} - | NOT e - {{$$ = ['NOT_EXPR',{},$2];}} - | e OR e - {{$$ = ['OR_EXPR',{},$1,$3];}} - | e DOT id - {{$$ = ['DOT_ID_EXPR',{},$1,$3];}} - | id ASSIGN e - {{$$ = ['ASSIGN_EXPR',{},$1,$3];}} - | e DOT id ASSIGN e - {{$$ = ['DOT_ASSIGN_EXPR',{},$1,$3,$5];}} - | id LPAREN e RPAREN - {{$$ = ['METHOD_CALL_EXPR',{},$1,$3];}} - | e DOT id LPAREN e RPAREN - {{$$ = ['DOT_METHOD_CALL_EXPR',{},$1,$3,$5];}} - | LPAREN e RPAREN - {$$ = $2;} - ; - diff --git a/examples/classy_test.src b/examples/classy_test.src deleted file mode 100644 index cbbac5c26..000000000 --- a/examples/classy_test.src +++ /dev/null @@ -1,7 +0,0 @@ -class Chris extends Person { -} - -main { - var string cool; - printnat(cool); -} diff --git a/examples/dism.jison b/examples/dism.jison deleted file mode 100644 index e6c913195..000000000 --- a/examples/dism.jison +++ /dev/null @@ -1,39 +0,0 @@ - -/* author: Jay Ligatti */ - -%% - -pgm - : instlist - ; - -instlist - : label COLON inst instlist - | inst instlist - | - ; - -inst - : ADD intt intt intt - | SUB intt intt intt - | MUL intt intt intt - | MOV intt intt - | LOD intt intt intt - | STR intt intt intt - | JMP intt intt intt - | BEQ intt intt intt - | BLT intt intt intt - | RDN intt - | PTN intt - | HLT intt - ; - -label - : LABEL - ; - -intt - : INT - | label - ; - diff --git a/examples/dism_lr0.jison b/examples/dism_lr0.jison deleted file mode 100644 index 74cbe5dbd..000000000 --- a/examples/dism_lr0.jison +++ /dev/null @@ -1,35 +0,0 @@ - -/* author: Jay Ligatti */ - -%% - -instlist - : instlist label COLON inst - | instlist inst - | inst - ; - -inst - : ADD intt intt intt - | SUB intt intt intt - | MUL intt intt intt - | MOV intt intt - | LOD intt intt intt - | STR intt intt intt - | JMP intt intt intt - | BEQ intt intt intt - | BLT intt intt intt - | RDN intt - | PTN intt - | HLT intt - ; - -label - : LABEL - ; - -intt - : INT - | label - ; - diff --git a/examples/inherited.y b/examples/inherited.y deleted file mode 100644 index c40a5ae05..000000000 --- a/examples/inherited.y +++ /dev/null @@ -1,35 +0,0 @@ -%lex -%% -\s+ {} -(global|local|integer|float) { return yytext; } -[a-zA-Z_]\w* { return 'id'; } -. { return yytext; } -/lex -%% -D - : C T L - ; - -C - : global - | local - ; - -T - : integer - | float - ; - -L - : L ',' id { - console.log("L -> L ',' id ("+yytext+")"); - console.log($id + ' is of type ' + $0); - console.log($1 + ' is of class ' + $-1); - } - | id { - console.log("L -> id ("+yytext+")"); - console.log($id + ' is of type ' + $0); - console.log($1 + ' is of class ' + $-1); - } - ; -%% diff --git a/examples/jscore.jison b/examples/jscore.jison deleted file mode 100644 index 3d2eb5e46..000000000 --- a/examples/jscore.jison +++ /dev/null @@ -1,599 +0,0 @@ -/* http://www.opensource.apple.com/source/JavaScriptCore/ */ - -%start Program - -%nonassoc IF_WITHOUT_ELSE -%nonassoc ELSE - -%% - -Literal - : NULLTOKEN - | TRUETOKEN - | FALSETOKEN - | NUMBER - | STRING - | '/' - | DIVEQUAL - ; - -Property - : IDENT ':' AssignmentExpr - | STRING ':' AssignmentExpr - | NUMBER ':' AssignmentExpr - | IDENT IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE - | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE - ; - -PropertyList - : Property - | PropertyList ',' Property - ; - -PrimaryExpr - : PrimaryExprNoBrace - | OPENBRACE CLOSEBRACE - | OPENBRACE PropertyList CLOSEBRACE - | OPENBRACE PropertyList ',' CLOSEBRACE - ; - -PrimaryExprNoBrace - : THISTOKEN - | Literal - | ArrayLiteral - | IDENT - | '(' Expr ')' - ; - -ArrayLiteral - : '[' ElisionOpt ']' - | '[' ElementList ']' - | '[' ElementList ',' ElisionOpt ']' - ; - -ElementList - : ElisionOpt AssignmentExpr - | ElementList ',' ElisionOpt AssignmentExpr - ; - -ElisionOpt - : - | Elision - ; - -Elision - : ',' - | Elision ',' - ; - -MemberExpr - : PrimaryExpr - | FunctionExpr - | MemberExpr '[' Expr ']' - | MemberExpr '.' IDENT - | NEW MemberExpr Arguments - ; - -MemberExprNoBF - : PrimaryExprNoBrace - | MemberExprNoBF '[' Expr ']' - | MemberExprNoBF '.' IDENT - | NEW MemberExpr Arguments - ; - -NewExpr - : MemberExpr - | NEW NewExpr - ; - -NewExprNoBF - : MemberExprNoBF - | NEW NewExpr - ; - -CallExpr - : MemberExpr Arguments - | CallExpr Arguments - | CallExpr '[' Expr ']' - | CallExpr '.' IDENT - ; - -CallExprNoBF - : MemberExprNoBF Arguments - | CallExprNoBF Arguments - | CallExprNoBF '[' Expr ']' - | CallExprNoBF '.' IDENT - ; - -Arguments - : '(' ')' - | '(' ArgumentList ')' - ; - -ArgumentList - : AssignmentExpr - | ArgumentList ',' AssignmentExpr - ; - -LeftHandSideExpr - : NewExpr - | CallExpr - ; - -LeftHandSideExprNoBF - : NewExprNoBF - | CallExprNoBF - ; - -PostfixExpr - : LeftHandSideExpr - | LeftHandSideExpr PLUSPLUS - | LeftHandSideExpr MINUSMINUS - ; - -PostfixExprNoBF - : LeftHandSideExprNoBF - | LeftHandSideExprNoBF PLUSPLUS - | LeftHandSideExprNoBF MINUSMINUS - ; - -UnaryExprCommon - : DELETETOKEN UnaryExpr - | VOIDTOKEN UnaryExpr - | TYPEOF UnaryExpr - | PLUSPLUS UnaryExpr - | AUTOPLUSPLUS UnaryExpr - | MINUSMINUS UnaryExpr - | AUTOMINUSMINUS UnaryExpr - | '+' UnaryExpr - | '-' UnaryExpr - | '~' UnaryExpr - | '!' UnaryExpr - ; - -UnaryExpr - : PostfixExpr - | UnaryExprCommon - ; - -UnaryExprNoBF - : PostfixExprNoBF - | UnaryExprCommon - ; - -MultiplicativeExpr - : UnaryExpr - | MultiplicativeExpr '*' UnaryExpr - | MultiplicativeExpr '/' UnaryExpr - | MultiplicativeExpr '%' UnaryExpr - ; - -MultiplicativeExprNoBF - : UnaryExprNoBF - | MultiplicativeExprNoBF '*' UnaryExpr - | MultiplicativeExprNoBF '/' UnaryExpr - | MultiplicativeExprNoBF '%' UnaryExpr - ; - -AdditiveExpr - : MultiplicativeExpr - | AdditiveExpr '+' MultiplicativeExpr - | AdditiveExpr '-' MultiplicativeExpr - ; - -AdditiveExprNoBF - : MultiplicativeExprNoBF - | AdditiveExprNoBF '+' MultiplicativeExpr - | AdditiveExprNoBF '-' MultiplicativeExpr - ; - -ShiftExpr - : AdditiveExpr - | ShiftExpr LSHIFT AdditiveExpr - | ShiftExpr RSHIFT AdditiveExpr - | ShiftExpr URSHIFT AdditiveExpr - ; - -ShiftExprNoBF - : AdditiveExprNoBF - | ShiftExprNoBF LSHIFT AdditiveExpr - | ShiftExprNoBF RSHIFT AdditiveExpr - | ShiftExprNoBF URSHIFT AdditiveExpr - ; - -RelationalExpr - : ShiftExpr - | RelationalExpr '<' ShiftExpr - | RelationalExpr '>' ShiftExpr - | RelationalExpr LE ShiftExpr - | RelationalExpr GE ShiftExpr - | RelationalExpr INSTANCEOF ShiftExpr - | RelationalExpr INTOKEN ShiftExpr - ; - -RelationalExprNoIn - : ShiftExpr - | RelationalExprNoIn '<' ShiftExpr - | RelationalExprNoIn '>' ShiftExpr - | RelationalExprNoIn LE ShiftExpr - | RelationalExprNoIn GE ShiftExpr - | RelationalExprNoIn INSTANCEOF ShiftExpr - ; - -RelationalExprNoBF - : ShiftExprNoBF - | RelationalExprNoBF '<' ShiftExpr - | RelationalExprNoBF '>' ShiftExpr - | RelationalExprNoBF LE ShiftExpr - | RelationalExprNoBF GE ShiftExpr - | RelationalExprNoBF INSTANCEOF ShiftExpr - | RelationalExprNoBF INTOKEN ShiftExpr - ; - -EqualityExpr - : RelationalExpr - | EqualityExpr EQEQ RelationalExpr - | EqualityExpr NE RelationalExpr - | EqualityExpr STREQ RelationalExpr - | EqualityExpr STRNEQ RelationalExpr - ; - -EqualityExprNoIn - : RelationalExprNoIn - | EqualityExprNoIn EQEQ RelationalExprNoIn - | EqualityExprNoIn NE RelationalExprNoIn - | EqualityExprNoIn STREQ RelationalExprNoIn - | EqualityExprNoIn STRNEQ RelationalExprNoIn - ; - -EqualityExprNoBF - : RelationalExprNoBF - | EqualityExprNoBF EQEQ RelationalExpr - | EqualityExprNoBF NE RelationalExpr - | EqualityExprNoBF STREQ RelationalExpr - | EqualityExprNoBF STRNEQ RelationalExpr - ; - -BitwiseANDExpr - : EqualityExpr - | BitwiseANDExpr '&' EqualityExpr - ; - -BitwiseANDExprNoIn - : EqualityExprNoIn - | BitwiseANDExprNoIn '&' EqualityExprNoIn - ; - -BitwiseANDExprNoBF - : EqualityExprNoBF - | BitwiseANDExprNoBF '&' EqualityExpr - ; - -BitwiseXORExpr - : BitwiseANDExpr - | BitwiseXORExpr '^' BitwiseANDExpr - ; - -BitwiseXORExprNoIn - : BitwiseANDExprNoIn - | BitwiseXORExprNoIn '^' BitwiseANDExprNoIn - ; - -BitwiseXORExprNoBF - : BitwiseANDExprNoBF - | BitwiseXORExprNoBF '^' BitwiseANDExpr - ; - -BitwiseORExpr - : BitwiseXORExpr - | BitwiseORExpr '|' BitwiseXORExpr - ; - -BitwiseORExprNoIn - : BitwiseXORExprNoIn - | BitwiseORExprNoIn '|' BitwiseXORExprNoIn - ; - -BitwiseORExprNoBF - : BitwiseXORExprNoBF - | BitwiseORExprNoBF '|' BitwiseXORExpr - ; - -LogicalANDExpr - : BitwiseORExpr - | LogicalANDExpr AND BitwiseORExpr - ; - -LogicalANDExprNoIn - : BitwiseORExprNoIn - | LogicalANDExprNoIn AND BitwiseORExprNoIn - ; - -LogicalANDExprNoBF - : BitwiseORExprNoBF - | LogicalANDExprNoBF AND BitwiseORExpr - ; - -LogicalORExpr - : LogicalANDExpr - | LogicalORExpr OR LogicalANDExpr - ; - -LogicalORExprNoIn - : LogicalANDExprNoIn - | LogicalORExprNoIn OR LogicalANDExprNoIn - ; - -LogicalORExprNoBF - : LogicalANDExprNoBF - | LogicalORExprNoBF OR LogicalANDExpr - ; - -ConditionalExpr - : LogicalORExpr - | LogicalORExpr '?' AssignmentExpr ':' AssignmentExpr - ; - -ConditionalExprNoIn - : LogicalORExprNoIn - | LogicalORExprNoIn '?' AssignmentExprNoIn ':' AssignmentExprNoIn - ; - -ConditionalExprNoBF - : LogicalORExprNoBF - | LogicalORExprNoBF '?' AssignmentExpr ':' AssignmentExpr - ; - -AssignmentExpr - : ConditionalExpr - | LeftHandSideExpr AssignmentOperator AssignmentExpr - ; - -AssignmentExprNoIn - : ConditionalExprNoIn - | LeftHandSideExpr AssignmentOperator AssignmentExprNoIn - ; - -AssignmentExprNoBF - : ConditionalExprNoBF - | LeftHandSideExprNoBF AssignmentOperator AssignmentExpr - ; - -AssignmentOperator - : '=' - | PLUSEQUAL - | MINUSEQUAL - | MULTEQUAL - | DIVEQUAL - | LSHIFTEQUAL - | RSHIFTEQUAL - | URSHIFTEQUAL - | ANDEQUAL - | XOREQUAL - | OREQUAL - | MODEQUAL - ; - -Expr - : AssignmentExpr - | Expr ',' AssignmentExpr - ; - -ExprNoIn - : AssignmentExprNoIn - | ExprNoIn ',' AssignmentExprNoIn - ; - -ExprNoBF - : AssignmentExprNoBF - | ExprNoBF ',' AssignmentExpr - ; - -Statement - : Block - | VariableStatement - | ConstStatement - | FunctionDeclaration - | EmptyStatement - | ExprStatement - | IfStatement - | IterationStatement - | ContinueStatement - | BreakStatement - | ReturnStatement - | WithStatement - | SwitchStatement - | LabelledStatement - | ThrowStatement - | TryStatement - | DebuggerStatement - ; - -Block - : OPENBRACE CLOSEBRACE - | OPENBRACE SourceElements CLOSEBRACE - ; - -VariableStatement - : VAR VariableDeclarationList ';' - | VAR VariableDeclarationList error - ; - -VariableDeclarationList - : IDENT - | IDENT Initializer - | VariableDeclarationList ',' IDENT - | VariableDeclarationList ',' IDENT Initializer - ; - -VariableDeclarationListNoIn - : IDENT - | IDENT InitializerNoIn - | VariableDeclarationListNoIn ',' IDENT - | VariableDeclarationListNoIn ',' IDENT InitializerNoIn - ; - -ConstStatement - : CONSTTOKEN ConstDeclarationList ';' - | CONSTTOKEN ConstDeclarationList error - ; - -ConstDeclarationList - : ConstDeclaration - | ConstDeclarationList ',' ConstDeclaration - ; - -ConstDeclaration - : IDENT - | IDENT Initializer - ; - -Initializer - : '=' AssignmentExpr - ; - -InitializerNoIn - : '=' AssignmentExprNoIn - ; - -EmptyStatement - : ';' - ; - -ExprStatement - : ExprNoBF ';' - | ExprNoBF error - ; - -IfStatement - : IF '(' Expr ')' Statement %prec IF_WITHOUT_ELSE - | IF '(' Expr ')' Statement ELSE Statement - ; - -IterationStatement - : DO Statement WHILE '(' Expr ')' ';' - | DO Statement WHILE '(' Expr ')' error - | WHILE '(' Expr ')' Statement - | FOR '(' ExprNoInOpt ';' ExprOpt ';' ExprOpt ')' Statement - | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement - | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement - | FOR '(' VAR IDENT INTOKEN Expr ')' Statement - | FOR '(' VAR IDENT InitializerNoIn INTOKEN Expr ')' Statement - ; - -ExprOpt - : - | Expr - ; - -ExprNoInOpt - : - | ExprNoIn - ; - -ContinueStatement - : CONTINUE ';' - | CONTINUE error - | CONTINUE IDENT ';' - | CONTINUE IDENT error - ; - -BreakStatement - : BREAK ';' - | BREAK error - | BREAK IDENT ';' - | BREAK IDENT error - ; - -ReturnStatement - : RETURN ';' - | RETURN error - | RETURN Expr ';' - | RETURN Expr error - ; - -WithStatement - : WITH '(' Expr ')' Statement - ; - -SwitchStatement - : SWITCH '(' Expr ')' CaseBlock - ; - -CaseBlock - : OPENBRACE CaseClausesOpt CLOSEBRACE - | OPENBRACE CaseClausesOpt DefaultClause CaseClausesOpt CLOSEBRACE - ; - -CaseClausesOpt - : - | CaseClauses - ; - -CaseClauses - : CaseClause - | CaseClauses CaseClause - ; - -CaseClause - : CASE Expr ':' - | CASE Expr ':' SourceElements - ; - -DefaultClause - : DEFAULT ':' - | DEFAULT ':' SourceElements - ; - -LabelledStatement - : IDENT ':' Statement - ; - -ThrowStatement - : THROW Expr ';' - | THROW Expr error - ; - -TryStatement - : TRY Block FINALLY Block - | TRY Block CATCH '(' IDENT ')' Block - | TRY Block CATCH '(' IDENT ')' Block FINALLY Block - ; - -DebuggerStatement - : DEBUGGER ';' - | DEBUGGER error - ; - -FunctionDeclaration - : FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE - | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE - ; - -FunctionExpr - : FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE - | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE - | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE - | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE - ; - -FormalParameterList - : IDENT - | FormalParameterList ',' IDENT - ; - -FunctionBody - : - | SourceElements - ; - -Program - : - | SourceElements - ; - -SourceElements - : Statement - | SourceElements Statement - ; - diff --git a/examples/json.js b/examples/json.js deleted file mode 100644 index a206db28d..000000000 --- a/examples/json.js +++ /dev/null @@ -1,78 +0,0 @@ -var Generator = require("../lib/jison").Generator; - -exports.grammar = { - "comment": "ECMA-262 5th Edition, 15.12.1 The JSON Grammar.", - "author": "Zach Carter", - - "lex": { - "macros": { - "digit": "[0-9]", - "esc": "\\\\", - "int": "-?(?:[0-9]|[1-9][0-9]+)", - "exp": "(?:[eE][-+]?[0-9]+)", - "frac": "(?:\\.[0-9]+)" - }, - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["{int}{frac}?{exp}?\\b", "return 'NUMBER';"], - ["\"(?:{esc}[\"bfnrt/{esc}]|{esc}u[a-fA-F0-9]{4}|[^\"{esc}])*\"", "yytext = yytext.substr(1,yyleng-2); return 'STRING';"], - ["\\{", "return '{'"], - ["\\}", "return '}'"], - ["\\[", "return '['"], - ["\\]", "return ']'"], - [",", "return ','"], - [":", "return ':'"], - ["true\\b", "return 'TRUE'"], - ["false\\b", "return 'FALSE'"], - ["null\\b", "return 'NULL'"] - ] - }, - - "tokens": "STRING NUMBER { } [ ] , : TRUE FALSE NULL", - "start": "JSONText", - - "bnf": { - "JSONString": [ "STRING" ], - - "JSONNullLiteral": [ "NULL" ], - - "JSONNumber": [ "NUMBER" ], - - "JSONBooleanLiteral": [ "TRUE", "FALSE" ], - - - "JSONText": [ "JSONValue" ], - - "JSONValue": [ "JSONNullLiteral", - "JSONBooleanLiteral", - "JSONString", - "JSONNumber", - "JSONObject", - "JSONArray" ], - - "JSONObject": [ "{ }", - "{ JSONMemberList }" ], - - "JSONMember": [ "JSONString : JSONValue" ], - - "JSONMemberList": [ "JSONMember", - "JSONMemberList , JSONMember" ], - - "JSONArray": [ "[ ]", - "[ JSONElementList ]" ], - - "JSONElementList": [ "JSONValue", - "JSONElementList , JSONValue" ] - } -}; - -var options = {type: "slr", moduleType: "commonjs", moduleName: "jsoncheck"}; - -exports.main = function main () { - var code = new Generator(exports.grammar, options).generate(); - console.log(code); -}; - -if (require.main === module) - exports.main(); - diff --git a/examples/json_ast.js b/examples/json_ast.js deleted file mode 100644 index 8a817e15a..000000000 --- a/examples/json_ast.js +++ /dev/null @@ -1,79 +0,0 @@ -var Generator = require("../lib/jison").Generator; - -exports.grammar = { - "comment": "ECMA-262 5th Edition, 15.12.1 The JSON Grammar. Parses JSON strings into objects.", - "author": "Zach Carter", - - "lex": { - "macros": { - "digit": "[0-9]", - "esc": "\\\\", - "int": "-?(?:[0-9]|[1-9][0-9]+)", - "exp": "(?:[eE][-+]?[0-9]+)", - "frac": "(?:\\.[0-9]+)" - }, - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["{int}{frac}?{exp}?\\b", "return 'NUMBER';"], - ["\"(?:{esc}[\"bfnrt/{esc}]|{esc}u[a-fA-F0-9]{4}|[^\"{esc}])*\"", "yytext = yytext.substr(1,yyleng-2); return 'STRING';"], - ["\\{", "return '{'"], - ["\\}", "return '}'"], - ["\\[", "return '['"], - ["\\]", "return ']'"], - [",", "return ','"], - [":", "return ':'"], - ["true\\b", "return 'TRUE'"], - ["false\\b", "return 'FALSE'"], - ["null\\b", "return 'NULL'"] - ] - }, - - "tokens": "STRING NUMBER { } [ ] , : TRUE FALSE NULL", - "start": "JSONText", - - "bnf": { - "JSONString": [[ "STRING", "$$ = yytext;" ]], - - "JSONNumber": [[ "NUMBER", "$$ = Number(yytext);" ]], - - "JSONNullLiteral": [[ "NULL", "$$ = null;" ]], - - "JSONBooleanLiteral": [[ "TRUE", "$$ = true;" ], - [ "FALSE", "$$ = false;" ]], - - - "JSONText": [[ "JSONValue", "return $$ = $1;" ]], - - "JSONValue": [[ "JSONNullLiteral", "$$ = $1;" ], - [ "JSONBooleanLiteral", "$$ = $1;" ], - [ "JSONString", "$$ = $1;" ], - [ "JSONNumber", "$$ = $1;" ], - [ "JSONObject", "$$ = $1;" ], - [ "JSONArray", "$$ = $1;" ]], - - "JSONObject": [[ "{ }", "$$ = {};" ], - [ "{ JSONMemberList }", "$$ = $2;" ]], - - "JSONMember": [[ "JSONString : JSONValue", "$$ = [$1, $3];" ]], - - "JSONMemberList": [[ "JSONMember", "$$ = {}; $$[$1[0]] = $1[1];" ], - [ "JSONMemberList , JSONMember", "$$ = $1; $1[$3[0]] = $3[1];" ]], - - "JSONArray": [[ "[ ]", "$$ = [];" ], - [ "[ JSONElementList ]", "$$ = $2;" ]], - - "JSONElementList": [[ "JSONValue", "$$ = [$1];" ], - [ "JSONElementList , JSONValue", "$$ = $1; $1.push($3);" ]] - } -}; - -var options = {type: "slr", moduleType: "commonjs", moduleName: "jsonparse"}; - -exports.main = function main (args) { - var code = new Generator(exports.grammar, options).generate(); - console.log(code); -}; - -if (require.main === module) - exports.main(); - diff --git a/examples/lambdacalc.jison b/examples/lambdacalc.jison deleted file mode 100644 index f929c700f..000000000 --- a/examples/lambdacalc.jison +++ /dev/null @@ -1,54 +0,0 @@ -/* Lambda calculus grammar by Zach Carter */ - -%lex -%% - -\s*\n\s* {/* ignore */} -"(" { return '('; } -")" { return ')'; } -"^"|"λ" { return 'LAMBDA'; } -"."\s? { return '.'; } -[a-zA-Z] { return 'VAR'; } -\s+ { return 'SEP'; } -<> { return 'EOF'; } -/lex - - -%right LAMBDA -%left SEP - -%% - -file - : expr EOF - { return $expr; } - ; - -expr - : LAMBDA var_list '.' expr - %{ - var temp = ["LambdaExpr", $var_list.shift(), $expr]; - $var_list.forEach(function (v) { - temp = ["LambdaExpr", v, temp]; - }); - $$ = temp; - %} - | expr SEP expr - { $$ = ["ApplyExpr", $expr1, $expr2]; } - | var - { $$ = ["VarExpr", $var]; } - | '(' expr ')' - { $$ = $expr; } - ; - -var_list - : var_list var - { $$ = $var_list; $$.unshift($var); } - | var - { $$ = [$var]; } - ; - -var - : VAR - { $$ = yytext; } - ; diff --git a/examples/nv_classy_ast.jison b/examples/nv_classy_ast.jison deleted file mode 100644 index 057a81630..000000000 --- a/examples/nv_classy_ast.jison +++ /dev/null @@ -1,126 +0,0 @@ -/* description: ClassyLang grammar with AST-building actions. Very classy. */ -/* - To build parser: - - $ ./bin/jison examples/classy_ast.jison examples/classy.jisonlex - -*/ - -/* author: Zach Carter */ - -%{ - function prependChild(node, child){ - node.splice(2,0,child); - return node; - } -%} - -%ebnf - -%right ASSIGN -%left OR -%nonassoc EQUALITY GREATER -%left PLUS MINUS -%left TIMES -%right NOT -%left DOT - -%% - -pgm - : cdl MAIN LBRACE vdl el RBRACE ENDOFFILE - {{$$ = ['PROGRAM',{},$1,$4,$5]; console.log(JSON.stringify($$, null, 4)); return $$; }} - ; - -cdl - : c cdl - {$$ = prependChild($2, $1);} - | - {{$$ = ['CLASS_DECL_LIST',{}];}} - ; - -c - : CLASS id[class_name] EXTENDS id[base_class] LBRACE vdl mdl RBRACE - {{$$ = ['CLASS_DECL',{},$class_name,$base_class,$vdl,$mdl];}} - ; - -vdl - : VAR t id SEMICOLON vdl - {{$$ = prependChild($5, ['VAR_DECL',{},$2,$3]);}} - | - {{$$ = ['VAR_DECL_LIST',{}];}} - ; - -mdl - : t id LPAREN t id RPAREN LBRACE vdl el RBRACE mdl - {{$$ = prependChild($11, ['METHOD_DECL',{},$1,$2,$4,$5,$8,$9]);}} - | - {{$$ = ['METHOD_DECL_LIST',{}];}} - ; - -t - : NATTYPE - {{$$ = ['NAT_TYPE',{}];}} - | id - {$$ = $1} - ; - -id - : ID - {{$$ = ['AST_ID',{val:yytext}]}} - ; - -el - : e SEMICOLON el - {$$ = prependChild($3, $1);} - | e SEMICOLON - {{$$ = ['EXPR_LIST',{},$1];}} - ; - -e - : NATLITERAL - {{$$ = ['NAT_LITERAL_EXPR',{val:parseInt(yytext)}];}} - | NUL - {{$$ = ['NULL_EXPR',{}];}} - | id - {{$$ = ['ID_EXPR',{},$1];}} - | NEW id - {{$$ = ['NEW_EXPR',{},$2];}} - | THIS - {{$$ = ['THIS_EXPR',{}];}} - | IF LPAREN e RPAREN LBRACE el RBRACE ELSE LBRACE el RBRACE - {{$$ = ['IF_THEN_ELSE_EXPR',{},$3,$6,$10];}} - | FOR LPAREN e SEMICOLON e SEMICOLON e RPAREN LBRACE el RBRACE - {{$$ = ['FOR_EXPR',{},$3,$5,$7,$10];}} - | READNAT LPAREN RPAREN - {{$$ = ['READ_EXPR',{}];}} - | PRINTNAT LPAREN e RPAREN - {{$$ = ['PRINT_EXPR',{},$3];}} - | e PLUS e - {{$$ = ['PLUS_EXPR',{},$1,$3];}} - | e MINUS e - {{$$ = ['MINUS_EXPR',{},$1,$3];}} - | e TIMES e - {{$$ = ['TIMES_EXPR',{},$1,$3];}} - | e EQUALITY e - {{$$ = ['EQUALITY_EXPR',{},$1,$3];}} - | e GREATER e - {{$$ = ['GREATER_THAN_EXPR',{},$1,$3];}} - | NOT e - {{$$ = ['NOT_EXPR',{},$2];}} - | e OR e - {{$$ = ['OR_EXPR',{},$1,$3];}} - | e DOT id - {{$$ = ['DOT_ID_EXPR',{},$1,$3];}} - | id ASSIGN e - {{$$ = ['ASSIGN_EXPR',{},$1,$3];}} - | e DOT id ASSIGN e - {{$$ = ['DOT_ASSIGN_EXPR',{},$1,$3,$5];}} - | id LPAREN e RPAREN - {{$$ = ['METHOD_CALL_EXPR',{},$1,$3];}} - | e DOT id LPAREN e RPAREN - {{$$ = ['DOT_METHOD_CALL_EXPR',{},$1,$3,$5];}} - | LPAREN e RPAREN - {$$ = $2;} - ; - diff --git a/examples/phraser.jison b/examples/phraser.jison deleted file mode 100644 index 3c96e4d13..000000000 --- a/examples/phraser.jison +++ /dev/null @@ -1,46 +0,0 @@ -/* description: Parses words out of html, ignoring html in the parse, but returning it in the end */ - -/* lexical grammar */ -%lex -%% -"<"(.|\n)*?">" return 'TAG' -[a-zA-Z0-9]+ return 'WORD' -(.|\n) return 'CHAR' -<> return 'EOF' - - -/lex - -%start html - -%% /* language grammar */ - -html - : contents EOF - {return $1;} - ; - -contents - : content - {$$ = $1;} - | contents content - {$$ = $1 + $2;} - ; - -content - : TAG - { - if (!yy.lexer.tagHandler) yy.lexer.tagHandler = function(tag) {return tag;}; - $$ = yy.lexer.tagHandler(yytext); - } - | WORD - { - if (!yy.lexer.wordHandler) yy.lexer.wordHandler = function(word) {return word;}; - $$ = yy.lexer.wordHandler(yytext); - } - | CHAR - { - if (!yy.lexer.charHandler) yy.lexer.charHandler = function(char) {return char;}; - $$ = yy.lexer.charHandler(yytext); - } - ; diff --git a/examples/precedence.jison b/examples/precedence.jison deleted file mode 100644 index ba1e4887c..000000000 --- a/examples/precedence.jison +++ /dev/null @@ -1,32 +0,0 @@ - -/* description: Grammar showing precedence operators and semantic actions. */ - -%lex -%% -\s+ {/* skip whitespace */} -[0-9]+ {return 'NAT';} -"+" {return '+';} -"*" {return '*';} -<> {return 'EOF';} - -/lex - -%left '+' -%left '*' - -%% - -S - : e EOF - {return $1;} - ; - -e - : e '+' e - {$$ = [$1,'+', $3];} - | e '*' e - {$$ = [$1, '*', $3];} - | NAT - {$$ = parseInt(yytext);} - ; - diff --git a/examples/reduce_conflict.jison b/examples/reduce_conflict.jison deleted file mode 100644 index baed52b34..000000000 --- a/examples/reduce_conflict.jison +++ /dev/null @@ -1,23 +0,0 @@ - -/* description: Produces a reduce-reduce conflict unless using LR(1). */ - - -%start S - -%% - -S - : a A c - | a B d - | b A d - | b B c - ; - -A - : z - ; - -B - : z - ; - diff --git a/examples/semwhitespace.jison b/examples/semwhitespace.jison deleted file mode 100644 index 4878838aa..000000000 --- a/examples/semwhitespace.jison +++ /dev/null @@ -1,67 +0,0 @@ -/* Demonstrates use of semantic whitespace pseudo-tokens. */ - -%start prog - -%ebnf - -%options token-stack - -%% /* language grammar */ - -prog - : proglist ENDOFFILE - { console.log("AST: %j", $proglist); } - ; - -proglist - : proglist stmt - { $proglist.push($stmt); $$ = $proglist; } - | stmt - { $$ = [$stmt]; } - ; - -if_stmt - : IF LPAREN expr RPAREN COLON stmt_block - { $$ = [ "if", $expr, $stmt_block ]; } - | IF LPAREN expr RPAREN COLON stmt_block ELSE COLON stmt_block - { $$ = [ "if", $expr, $6, $9 ]; } - ; - -print_stmt - : PRINT STRING - { $$ = ["print", $2]; } - ; - -stmt - : if_stmt - | print_stmt - ; - -stmt_list - : stmt - { $$ = ["stmt_list", $stmt]; } - | stmt_list stmt - { $stmt_list.push($stmt); $$ = $stmt_list; } - ; - -stmt_block - : INDENT stmt_list DEDENT - { $$ = $stmt_list; } - ; - -atom - : ID - { $$ = ["id", $1]; } - | NATLITERAL - { $$ = ["natlit", $1]; } - | LPAREN expr RPAREN - { $$ = ["expr", $2]; } - ; - -expr - : atom - | expr PLUS atom - { $expr.push(["plus", $atom]); $$ = $expr; } - | expr MINUS atom - { $expr.push(["minus", $atom]); $$ = $expr; } - ; diff --git a/examples/semwhitespace_ex.src b/examples/semwhitespace_ex.src deleted file mode 100644 index 4d70d0feb..000000000 --- a/examples/semwhitespace_ex.src +++ /dev/null @@ -1,12 +0,0 @@ -if (a+b): - print "this line has trailing spaces" - if (123-b): - print "this one does not" - else: - print "will error until indentation corrected" - print "correctly indented" - print "another line, a couple trailing tabs" - print "unexpected indent" - -print "end of program" - diff --git a/examples/semwhitespace_lex.jison b/examples/semwhitespace_lex.jison deleted file mode 100644 index 72526dbd0..000000000 --- a/examples/semwhitespace_lex.jison +++ /dev/null @@ -1,55 +0,0 @@ -/* Demonstrates semantic whitespace pseudo-tokens, INDENT/DEDENT. */ - -id [a-zA-Z][a-zA-Z0-9]* -spc [\t \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000] - -%s EXPR - -%% -"if" return 'IF'; -"else" return 'ELSE'; -"print" return 'PRINT'; -":" return 'COLON'; -"(" this.begin('EXPR'); return 'LPAREN'; -")" this.popState(); return 'RPAREN'; -\"[^\"]*\"|\'[^\']*\' yytext = yytext.substr(1,yyleng-2); return 'STRING'; -"+" return 'PLUS'; -"-" return 'MINUS'; -{id} return 'ID'; -\d+ return 'NATLITERAL'; -<> return "ENDOFFILE"; -\s*<> %{ - // remaining DEDENTs implied by EOF, regardless of tabs/spaces - var tokens = []; - - while (0 < _iemitstack[0]) { - this.popState(); - tokens.unshift("DEDENT"); - _iemitstack.shift(); - } - - if (tokens.length) return tokens; - %} -[\n\r]+{spc}*/![^\n\r] /* eat blank lines */ -[\n\r]{spc}* %{ - var indentation = yytext.length - yytext.search(/\s/) - 1; - if (indentation > _iemitstack[0]) { - _iemitstack.unshift(indentation); - return 'INDENT'; - } - - var tokens = []; - - while (indentation < _iemitstack[0]) { - this.popState(); - tokens.unshift("DEDENT"); - _iemitstack.shift(); - } - if (tokens.length) return tokens; - %} -{spc}+ /* ignore all other whitespace */ - -%% -/* initialize the pseudo-token stack with 0 indents */ -_iemitstack = [0]; - diff --git a/examples/tikiwikiparser.jison b/examples/tikiwikiparser.jison deleted file mode 100755 index 8d79e4992..000000000 --- a/examples/tikiwikiparser.jison +++ /dev/null @@ -1,211 +0,0 @@ -%lex - -PLUGIN_ID [A-Z]+ -INLINE_PLUGIN_ID [a-z]+ -SMILE [a-z]+ - -%s bold box center colortext italic header6 header5 header4 header3 header2 header1 link strikethrough table titlebar underscore wikilink - -%% - -"{"{INLINE_PLUGIN_ID}.*?"}" - %{ - yytext = parserlib.inlinePlugin(yytext); - return 'INLINE_PLUGIN'; - %} - -"{"{PLUGIN_ID}"(".*?")}" - %{ - yy.pluginStack = parserlib.stackPlugin(yytext, yy.pluginStack); - - if (parserlib.size(yy.pluginStack) == 1) { - return 'PLUGIN_START'; - } else { - return 'CONTENT'; - } - %} - -"{"{PLUGIN_ID}"}" - %{ - if (yy.pluginStack) { - if ( - parserlib.size(yy.pluginStack) > 0 && - parserlib.substring(yytext, 1, -1) == yy.pluginStack[parserlib.size(yy.pluginStack) - 1].name - ) { - if (parserlib.size(yy.pluginStack) == 1) { - yytext = yy.pluginStack[parserlib.size(yy.pluginStack) - 1]; - yy.pluginStack = parserlib.pop(yy.pluginStack); - return 'PLUGIN_END'; - } else { - yy.pluginStack = parserlib.pop(yy.pluginStack); - return 'CONTENT'; - } - } - } - return 'CONTENT'; - %} - -("~np~") - %{ - yy.npStack = parserlib.push(yy.npStack, true); - this.yy.npOn = true; - - return 'NP_START'; - %} - -("~/np~") - %{ - this.yy.npStack = parserlib.pop(yy.npStack); - if (parserlib.size(yy.npStack) < 1) yy.npOn = false; - return 'NP_END'; - %} - -"---" - %{ - yytext = parserlib.hr(); - return 'HORIZONTAL_BAR'; - %} - -"(:"{SMILE}":)" - %{ - yytext = parserlib.substring(yytext, 2, -2); - yytext = parserlib.smile(yytext); - return 'SMILE'; - %} - -"[[".*? - %{ - yytext = parserlib.substring(yytext, 2, -1); - return 'CONTENT'; - %} - -[_][_] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'BOLD_END'); %} -[_][_] %{ this.begin('bold'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'BOLD_START'); %} -[\^] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'BOX_END'); %} -[\^] %{ this.begin('box'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'BOX_START'); %} -
[:][:] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'CENTER_END'); %} -[:][:] %{ this.begin('center'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'CENTER_START'); %} -[\~][\~] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'COLORTEXT_END'); %} -[\~][\~][#] %{ this.begin('colortext'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'COLORTEXT_START'); %} -[\n] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER6_END'); %} -[\n]("!!!!!!") %{ this.begin('header6'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER6_START'); %} -[\n] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER5_END'); %} -[\n]("!!!!!") %{ this.begin('header5'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER5_START'); %} -[\n] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER4_END'); %} -[\n]("!!!!") %{ this.begin('header4'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER4_START'); %} -[\n] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER3_END'); %} -[\n]("!!!") %{ this.begin('header3'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER3_START'); %} -[\n] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER2_END'); %} -[\n]("!!") %{ this.begin('header2'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER2_START'); %} -[\n] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER1_END'); %} -[\n]("!") %{ this.begin('header1'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'HEADER1_START'); %} -[']['] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'ITALIC_END'); %} -[']['] %{ this.begin('italic'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'ITALIC_START'); %} -("]") %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'LINK_END'); %} -("[") %{ this.begin('link'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'LINK_START'); %} -[-][-] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'STRIKETHROUGH_END'); %} -[-][-] %{ this.begin('strikethrough'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'STRIKETHROUGH_START'); %} -[|][|] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'TABLE_END'); %} -[|][|] %{ this.begin('table'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'TABLE_START'); %} -[=][-] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'TITLEBAR_END'); %} -[-][=] %{ this.begin('titlebar'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'TITLEBAR_START'); %} -[=][=][=] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'UNDERSCORE_END'); %} -[=][=][=] %{ this.begin('underscore'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'UNDERSCORE_START'); %} -[)][)] %{ this.popState(); return parserlib.npState(this.yy.npOn, 'CONTENT', 'WIKILINK_END'); %} -[(][(] %{ this.begin('wikilink'); return parserlib.npState(this.yy.npOn, 'CONTENT', 'WIKILINK_START'); %} - -"<"(.|\n)*?">" return 'HTML' -(.) return 'CONTENT' -(\n) - %{ - if (parserlib.npState(this.yy.npOn, false, true) == true) { - yytext = parserlib.formatContent(yytext); - } - - return 'CONTENT'; - %} - -<> return 'EOF' - -/lex - -%% - -wiki - : wiki_contents EOF - {return $1;} - ; - -wiki_contents - : - | contents - {$$ = $1;} - | wiki_contents plugin - {$$ = parserlib.join($1, $2);} - | wiki_contents plugin contents - {$$ = parserlib.join($1, $2, $3);} - ; - -plugin - : INLINE_PLUGIN - {$$ = parserlib.plugin($1);} - | PLUGIN_START wiki_contents PLUGIN_END - { - $3.body = $2; - $$ = parserlib.plugin($3); - } - ; - -contents - : content - {$$ = $1;} - | contents content - {$$ = parserlib.join($1, $2);} - ; - -content - : CONTENT - {$$ = $1;} - | HTML - {$$ = parserlib.html($1);} - | HORIZONTAL_BAR - {$$ = $1;} - | SMILE - {$$ = $1;} - | BOLD_START wiki_contents BOLD_END - {$$ = parserlib.bold($2);} - | BOX_START wiki_contents BOX_END - {$$ = parserlib.box($2);} - | CENTER_START wiki_contents CENTER_END - {$$ = parserlib.center($2);} - | COLORTEXT_START wiki_contents COLORTEXT_END - {$$ = parserlib.colortext($2);} - | ITALIC_START wiki_contents ITALIC_END - {$$ = parserlib.italics($2);} - | HEADER6_START wiki_contents HEADER6_END - {$$ = parserlib.header6($2);} - | HEADER5_START wiki_contents HEADER5_END - {$$ = parserlib.header5($2);} - | HEADER4_START wiki_contents HEADER4_END - {$$ = parserlib.header4($2);} - | HEADER3_START wiki_contents HEADER3_END - {$$ = parserlib.header3($2);} - | HEADER2_START wiki_contents HEADER2_END - {$$ = parserlib.header2($2);} - | HEADER1_START wiki_contents HEADER1_END - {$$ = parserlib.header1($2);} - | LINK_START wiki_contents LINK_END - {$$ = parserlib.link($2);} - | NP_START wiki_contents NP_END - {$$ = $2;} - | STRIKETHROUGH_START wiki_contents STRIKETHROUGH_END - {$$ = parserlib.strikethrough($2);} - | TABLE_START wiki_contents TABLE_END - {$$ = parserlib.table($2);} - | TITLEBAR_START wiki_contents TITLEBAR_END - {$$ = parserlib.titlebar($2);} - | UNDERSCORE_START wiki_contents UNDERSCORE_END - {$$ = parserlib.underscore($2);} - | WIKILINK_START wiki_contents WIKILINK_END - {$$ = parserlib.wikilink($2);} - ; From ec31b46fe333a6aaf97f7f83aa0aaa3a4a6e5ea3 Mon Sep 17 00:00:00 2001 From: Steve Shreeve Date: Sat, 19 Jul 2025 00:40:03 -0600 Subject: [PATCH 4/4] Major revisions and optimizations This used to process CoffeeScript's grammar file in 12.5 seconds and now does it in 0.95 seconds (13.2x speedup). --- lib/jison.js | 629 +++++++++++++++++++-------------------------------- package.json | 2 +- 2 files changed, 229 insertions(+), 402 deletions(-) mode change 100755 => 100644 lib/jison.js diff --git a/lib/jison.js b/lib/jison.js old mode 100755 new mode 100644 index 93ba24bc0..a57a373e1 --- a/lib/jison.js +++ b/lib/jison.js @@ -1,262 +1,100 @@ -// LALR(1) Parser Generator - DeRemer-Pennello Algorithm Implementation -// -// This implementation uses canonical naming conventions from established literature to -// serve as a reference implementation for computer science education and research. -// Canonical naming conventions based on established literature: -// -// - "Compilers: Principles, Techniques, and Tools" (Dragon Book) -// - "Efficient Computation of LALR(1) Look-Ahead Sets" (DeRemer & Pennello, 1982) -// - "LR Parsing: Theory and Practice" (Knuth, 1965) -// -// Function Reference: -// -// Utility Functions: -// - union(a, b) - Merge array b into array a, avoiding duplicates -// -// Constructor Functions: -// - Nonterminal(symbol) - Represents a nonterminal symbol in the grammar -// - Production(symbol, handle, id) - Represents a production rule in the grammar -// - Item(production, dot, lookaheadSet, predecessor) - Represents an LR(0) item [A → α•β] with lookahead -// - LRState() - Represents a set of LR items (parser state) -// - LALRGenerator(grammar, options) - Unified LALR(1) parser generator class -// -// LRState Methods: -// - concat(set) - Merge another LRState or array into this LRState -// - push(item) - Add an item to this LRState -// - contains(item) - Check if this LRState contains a specific item -// - valueOf() - Generate unique string representation for ItemSet comparison -// -// LALRGenerator Core Methods: -// - gotoEncoded(stateId, symbolSequence) - Specialized GOTO method for lookahead computation -// - processGrammar(grammar) - Process and validate the input grammar specification -// - processOperators(ops) - Process operator precedence and associativity declarations -// - augmentGrammar(grammar) - Add augmented start production for parser generation -// - buildProductions(bnf, productions, nonterminals, symbols, operators) - Build production rules from BNF grammar -// -// Lookahead Computation: -// - computeLookaheads() - Compute LALR(1) lookaheads using DeRemer-Pennello algorithm -// - computeNullableSets() - Compute NULLABLE sets for all nonterminals -// - isNullable(symbol) - Check if a symbol or symbol sequence is nullable -// - computeFirstSets() - Compute FIRST sets for all nonterminals -// - first(symbol) - Get FIRST set for a symbol or symbol sequence -// - computeFollowSets() - Compute FOLLOW sets for all nonterminals -// -// LR Automaton Construction: -// - closure(itemSet) - Compute closure of an item set (add all implied items) -// - goto(itemSet, symbol) - Compute goto operation (items after shifting a symbol) -// - buildLRAutomaton() - Generate canonical collection of LR(0) item sets -// - insertLRState(symbol, itemSet, states, stateNum) - Insert or merge item set into canonical collection -// -// Parse Table Generation: -// - buildParseTable(itemSets) - Generate LALR(1) parsing table from item sets -// - resolveConflict(production, op, reduce, shift) - Resolve shift/reduce conflicts using operator precedence -// - computeDefaultActions(states) - Find default actions for parser states to reduce table size -// - getLookaheadSet(state, item) - Get lookahead symbols for an item in a state -// -// Navigation and State Management: -// - gotoState(startState, symbolSequence) - Navigate through parser states following a symbol sequence -// - gotoStateWithPath(startState, symbolSequence) - Navigate through parser states and record the path taken -// - buildAugmentedGrammar() - Build augmented grammar for lookahead computation -// - unionLookaheads() - Propagate lookaheads from augmented grammar back to original states -// -// Code Generation: -// - generate(opt) - Generate parser code with specified options -// - generateCommonJSModule(opt) - Generate CommonJS module wrapper for parser -// - generateModule(opt) - Generate module wrapper for parser -// - generateModuleExpr() - Generate self-executing module expression -// - generateModule_() - Generate core parser module code -// - generateTableCode(table) - Generate optimized parsing table code -// -// Parser Runtime: -// - parseError(str, hash) - Handle parsing errors with context information -// - parse(input) - Parse input string using generated LALR(1) parser -// - trace() - Debug tracing function (no-op by default) -// - createParser() - Create executable parser instance from generated code -// -// Export Functions: -// - Jison.Parser(grammar, options) - Create parser from grammar -// - Jison.Generator(g, options) - Create generator instance -// - Parser(g, options) - Main parser factory function +// LALR(1) Parser Generator // // Original implementation by Jison team // https://github.com/zaach/jison/blob/master/lib/jison.js +// +// Updates and optimization by Steve Shreeve +// https://github.com/shreeve/jison var Jison = exports.Jison = exports; var version = require('../package.json').version; -// Merge array b into array a, avoiding duplicates -function union(a, b) { - var s = Object.create(null); - var i, len; - for (i = 0, len = a.length; i < len; i++) { - s[a[i]] = 1; - } - for (i = 0, len = b.length; i < len; i++) { - if (!s[b[i]]) { - a.push(b[i]); - } - } - return a; -} - -// Represents a nonterminal symbol in the grammar +// Nonterminal symbol function Nonterminal(symbol) { - this.symbol = symbol; + this.symbol = symbol; this.productions = []; - this.first = []; - this.follows = []; - this.nullable = false; + this.nullable = false; + this.first = new Set(); + this.follows = new Set(); } -// Represents a production rule in the grammar +// Production rule: A → α function Production(symbol, handle, id) { - this.symbol = symbol; - this.handle = handle; - this.id = id; - this.nullable = false; - this.first = []; + this.symbol = symbol; + this.handle = handle; + this.id = id; + this.nullable = false; + this.first = new Set(); this.precedence = 0; } -// Represents an LR(0) item [A → α•β] with lookahead (canonical: LR item) -function Item(production, dot, lookaheadSet, predecessor) { +// LR(0) item: [A → α•β] with LALR(1) lookahead +function Item(production, dot, follows) { this.production = production; - this.dot = dot || 0; // Position of • in production - this.follows = lookaheadSet || []; // LALR(1) lookahead symbols - this.predecessor = predecessor; - this.nextSymbol = this.production.handle[this.dot]; // Symbol after • - this.id = parseInt(production.id + 'a' + this.dot, 36); + this.dot = dot || 0; + this.follows = follows || []; + this.nextSymbol = this.production.handle[this.dot]; + this.id = parseInt(production.id + 'a' + dot, 36); } -// Represents a set of LR items (parser state) - canonical: LR state +// LR parser state (set of items) function LRState() { - this.list = []; - this.length = 0; - this.reductions = []; // Reductions in this state - this.handleToSymbols = {}; // Maps production handles to generating symbols - this.transitions = {}; // State transitions - this.hasShifts = false; // Has shift actions - this.hasConflicts = false; // Has SR/RR conflicts - this.keys = {}; - - if (arguments.length) { - this.list = Array.prototype.slice.call(arguments); - this.length = this.list.length; - for (var i = this.length - 1; i >= 0; i--) { - this.keys[this.list[i].id] = true; - } - } + this.items = new Set(arguments.length ? Array.prototype.slice.call(arguments) : []); + this.reductions = []; + this.transitions = {}; + this.hasShifts = false; + this.hasConflicts = false; + this.id = null; } -// Merge another LRState or array into this LRState -LRState.prototype.concat = function(set) { - var a = set.list || set; - for (var i = a.length - 1; i >= 0; i--) { - this.keys[a[i].id] = true; - } - this.list.push.apply(this.list, a); - this.length = this.list.length; - return this; -}; - -// Add an item to this LRState -LRState.prototype.push = function(item) { - this.keys[item.id] = true; - this.list.push(item); - this.length = this.list.length; - return this.length; -}; - -// Check if this LRState contains a specific item -LRState.prototype.contains = function(item) { - return this.keys[item.id]; -}; - // Generate unique string representation for ItemSet comparison LRState.prototype.valueOf = function() { - var v = this.list.map(function(a) { return a.id; }).sort().join('|'); + var v = Array.from(this.items).map(function(a) { return a.id; }).sort().join('|'); this.valueOf = function() { return v; }; return v; }; -// Unified LALR(1) parser generator class (canonical: LALRGenerator) +// LALR(1) Parser Generator function LALRGenerator(grammar, options) { - options = Object.assign({}, grammar.options, options); - this.terminals = {}; // Terminal symbols - this.operators = {}; - this.productions = []; - this.conflicts = 0; - this.resolutions = []; - this.options = options; + // Configuration + this.options = Object.assign({}, grammar.options, options); this.parseParams = grammar.parseParams; this.yy = {}; + // Grammar structures + this.terminals = {}; + this.operators = {}; + this.productions = []; + this.conflicts = 0; + this.resolutions = []; + + // Code generation setup + this._setupCodeGeneration(grammar); + this._buildParser(grammar); +} + +// Setup code generation includes and module wrapper +LALRGenerator.prototype._setupCodeGeneration = function(grammar) { if (grammar.actionInclude) { if (typeof grammar.actionInclude === 'function') { - grammar.actionInclude = String(grammar.actionInclude) + this.actionInclude = String(grammar.actionInclude) .replace(/^\s*function \(\) \{/, '') .replace(/\}\s*$/, ''); + } else { + this.actionInclude = grammar.actionInclude; } - this.actionInclude = grammar.actionInclude; } this.moduleInclude = grammar.moduleInclude || ''; +}; - console.time('processGrammar'); +// Build parser by processing grammar and computing parse table +LALRGenerator.prototype._buildParser = function(grammar) { this.processGrammar(grammar); - console.timeEnd('processGrammar'); - - console.time('buildLRAutomaton'); - this.states = this.buildLRAutomaton(); - console.timeEnd('buildLRAutomaton'); - - this.terminalMap = {}; // Maps symbols to terminal representations - - // Initialize lookahead state (replaces newg creation) - this.lookahead = { - nonterminalMap: {}, // Maps nonterminals to states - nonterminals: {}, - productions: [] - }; - - this.conflictStates = []; // States with conflicts - this.onDemandLookahead = options.onDemandLookahead || false; - - console.time('buildAugmentedGrammar'); - this.buildAugmentedGrammar(); - console.timeEnd('buildAugmentedGrammar'); - - // Compute lookaheads in lookahead context (replaces newg.computeLookaheads()) - var savedNonterminals = this.nonterminals; - var savedProductions = this.productions; - - this.nonterminals = this.lookahead.nonterminals; - this.productions = this.lookahead.productions; - - console.time('computeLookaheads'); + this.buildLRAutomaton(); this.computeLookaheads(); - console.timeEnd('computeLookaheads'); - - this.nonterminals = savedNonterminals; - this.productions = savedProductions; - - console.time('unionLookaheads'); - this.unionLookaheads(); - console.timeEnd('unionLookaheads'); - - console.time('buildParseTable'); - this.stateTable = this.buildParseTable(this.states); - console.timeEnd('buildParseTable'); - - console.time('computeDefaultActions'); - this.defaultActions = this.computeDefaultActions(this.stateTable); - console.timeEnd('computeDefaultActions'); -} - -// Specialized GOTO method for lookahead computation (DeRemer-Pennello algorithm) -LALRGenerator.prototype.gotoEncoded = function(stateId, symbolSequence) { - stateId = stateId.split(":")[0]; - symbolSequence = symbolSequence.map(function(s) { return s.slice(s.indexOf(":") + 1); }); - return this.gotoState(stateId, symbolSequence); + this.assignItemLookaheads(); + this.buildParseTable(this.states); + this.computeDefaultActions(this.stateTable); }; // Process and validate the input grammar specification @@ -266,7 +104,7 @@ LALRGenerator.prototype.processGrammar = function(grammar) { var nonterminals = this.nonterminals = {}; var productions = this.productions; var symbols = this.symbols = []; - var operators = this.operators = this.processOperators(grammar.operators); + var operators = this.operators = this._processOperators(grammar.operators); if (tokens) { tokens = typeof tokens === 'string' ? tokens.trim().split(' ') : tokens.slice(0); @@ -278,11 +116,11 @@ LALRGenerator.prototype.processGrammar = function(grammar) { this.trace("Warning: declared tokens differ from tokens found in rules."); } - this.augmentGrammar(grammar); + this._augmentGrammar(grammar); }; // Process operator precedence and associativity declarations -LALRGenerator.prototype.processOperators = function(ops) { +LALRGenerator.prototype._processOperators = function(ops) { if (!ops) return {}; var operators = {}; for (var i = 0, prec; prec = ops[i]; i++) { @@ -297,7 +135,7 @@ LALRGenerator.prototype.processOperators = function(ops) { }; // Add augmented start production for parser generation -LALRGenerator.prototype.augmentGrammar = function(grammar) { +LALRGenerator.prototype._augmentGrammar = function(grammar) { if (this.productions.length === 0) { throw new Error("Grammar error: must have at least one rule."); } @@ -317,7 +155,7 @@ LALRGenerator.prototype.augmentGrammar = function(grammar) { this.nonterminals.$accept = new Nonterminal("$accept"); this.nonterminals.$accept.productions.push(acceptProduction); - this.nonterminals[this.startSymbol].follows.push(this.EOF); + this.nonterminals[this.startSymbol].follows.add(this.EOF); }; // Build production rules from BNF grammar specification @@ -333,6 +171,7 @@ LALRGenerator.prototype.buildProductions = function(bnf, productions, nontermina var symbolId = 1; var symbolMap = {}; + // Add symbol to symbol table if not already present function addSymbol(s) { if (s && !symbolMap[s]) { symbolMap[s] = ++symbolId; @@ -485,146 +324,191 @@ LALRGenerator.prototype.buildProductions = function(bnf, productions, nontermina }; // Lookahead computation -// Compute LALR(1) lookaheads using DeRemer-Pennello algorithm LALRGenerator.prototype.computeLookaheads = function() { - this.computeLookaheads = function() {}; - this.computeNullableSets(); - this.computeFirstSets(); - this.computeFollowSets(); + this.computeLookaheads = function() {}; // Prevent re-computation + this._computeNullableSets(); + this._computeFirstSets(); + this._computeFollowSets(); }; -// Compute NULLABLE sets for all nonterminals (canonical: NULLABLE computation) -LALRGenerator.prototype.computeNullableSets = function() { - var nonterminals = this.nonterminals; +// Assign FOLLOW sets to reduction items for LALR(1) +LALRGenerator.prototype.assignItemLookaheads = function() { + var self = this; + this.states.forEach(function(state) { + state.reductions.forEach(function(item) { + var follows = self.nonterminals[item.production.symbol] && self.nonterminals[item.production.symbol].follows; + if (follows) { + item.follows.length = 0; + follows.forEach(function(terminal) { + item.follows.push(terminal); + }); + } + }); + }); +}; + +// Initialize FIRST and FOLLOW sets as Sets for O(1) operations +LALRGenerator.prototype.initializeSets = function() { + // Note: this.productions and this.nonterminals refer to the lookahead context here + // Initialize production.first as Set + for (var i = 0; i < this.productions.length; i++) { + this.productions[i].first = new Set(); + } + + // Initialize nonterminal.first and nonterminal.follows as Sets + for (var symbol in this.nonterminals) { + this.nonterminals[symbol].first = new Set(); + this.nonterminals[symbol].follows = new Set(); + } +}; + +// Determine nullable symbols (can derive ε) +LALRGenerator.prototype._computeNullableSets = function() { + var changed = true; var self = this; - var cont = true; - while (cont) { - cont = false; + while (changed) { + changed = false; + // Mark productions nullable if all handle symbols are nullable this.productions.forEach(function(production) { if (!production.nullable) { - var n = 0; - for (var i = 0, t; t = production.handle[i]; ++i) { - if (self.isNullable(t)) n++; - } - if (n === i) { - production.nullable = cont = true; + var allNullable = production.handle.every(function(symbol) { + return self.isNullable(symbol); + }); + if (allNullable) { + production.nullable = changed = true; } } }); - for (var symbol in nonterminals) { + // Propagate to nonterminals + for (var symbol in this.nonterminals) { if (!this.isNullable(symbol)) { - for (var i = 0, production; production = nonterminals[symbol].productions[i]; i++) { - if (production.nullable) { - nonterminals[symbol].nullable = cont = true; - break; - } + var hasNullableProduction = this.nonterminals[symbol].productions.some(function(production) { + return production.nullable; + }); + if (hasNullableProduction) { + this.nonterminals[symbol].nullable = changed = true; } } } } }; -// Check if a symbol or symbol sequence is nullable (canonical: NULLABLE predicate) +// Check if symbol or symbol sequence can derive empty string LALRGenerator.prototype.isNullable = function(symbol) { if (symbol === '') return true; - if (symbol instanceof Array) { - for (var i = 0, t; t = symbol[i]; ++i) { - if (!this.isNullable(t)) return false; - } - return true; + if (Array.isArray(symbol)) { + var self = this; + return symbol.every(function(s) { return self.isNullable(s); }); } - return !this.nonterminals[symbol] ? false : this.nonterminals[symbol].nullable; + return this.nonterminals[symbol] ? this.nonterminals[symbol].nullable : false; }; -// Compute FIRST sets for all nonterminals (canonical: FIRST computation) -LALRGenerator.prototype.computeFirstSets = function() { - var productions = this.productions; - var nonterminals = this.nonterminals; +// Compute FIRST sets (terminals that can begin derivations) +LALRGenerator.prototype._computeFirstSets = function() { + var changed = true; var self = this; - var cont = true; - while (cont) { - cont = false; + while (changed) { + changed = false; - productions.forEach(function(production) { + this.productions.forEach(function(production) { var firsts = self.first(production.handle); - if (firsts.length !== production.first.length) { - production.first = firsts; - cont = true; + var oldSize = production.first.size; + production.first.clear(); + for (var i = 0; i < firsts.length; i++) { + production.first.add(firsts[i]); + } + if (production.first.size > oldSize) { + changed = true; } }); - for (var symbol in nonterminals) { - var firsts = []; - nonterminals[symbol].productions.forEach(function(production) { - union(firsts, production.first); + for (var symbol in this.nonterminals) { + var nonterminal = this.nonterminals[symbol]; + var oldSize = nonterminal.first.size; + nonterminal.first.clear(); + nonterminal.productions.forEach(function(production) { + production.first.forEach(function(s) { + nonterminal.first.add(s); + }); }); - if (firsts.length !== nonterminals[symbol].first.length) { - nonterminals[symbol].first = firsts; - cont = true; + if (nonterminal.first.size > oldSize) { + changed = true; } } } }; -// Get FIRST set for a symbol or symbol sequence -LALRGenerator.prototype.first = function(symbol) { - if (symbol === '') return []; - if (symbol instanceof Array) { - var firsts = []; - for (var i = 0, t; t = symbol[i]; ++i) { - if (!this.nonterminals[t]) { - if (firsts.indexOf(t) === -1) firsts.push(t); - } else { - union(firsts, this.nonterminals[t].first); - } - if (!this.isNullable(t)) break; +// Get FIRST set for symbol or symbol sequence +LALRGenerator.prototype.first = function(symbols) { + if (symbols === '') return []; + if (Array.isArray(symbols)) return this._firstOfSequence(symbols); + if (!this.nonterminals[symbols]) return [symbols]; + return Array.from(this.nonterminals[symbols].first); +}; + +// Compute FIRST set for a sequence of symbols +LALRGenerator.prototype._firstOfSequence = function(symbols) { + var firsts = new Set(); + var self = this; + for (var i = 0; i < symbols.length; i++) { + var symbol = symbols[i]; + if (this.nonterminals[symbol]) { + this.nonterminals[symbol].first.forEach(function(s) { + firsts.add(s); + }); + } else { + firsts.add(symbol); } - return firsts; + if (!this.isNullable(symbol)) break; } - return !this.nonterminals[symbol] ? [symbol] : this.nonterminals[symbol].first; + return Array.from(firsts); }; // Compute FOLLOW sets for all nonterminals -LALRGenerator.prototype.computeFollowSets = function() { - var productions = this.productions; - var nonterminals = this.nonterminals; +// Compute FOLLOW sets (terminals that can follow nonterminals) +LALRGenerator.prototype._computeFollowSets = function() { + var changed = true; var self = this; - var cont = true; - - while (cont) { - cont = false; - productions.forEach(function(production) { - var q = !!self.go_; - var ctx = q; + while (changed) { + changed = false; - for (var i = 0, t; t = production.handle[i]; ++i) { - if (!nonterminals[t]) continue; + this.productions.forEach(function(production) { + for (var i = 0; i < production.handle.length; i++) { + var symbol = production.handle[i]; + if (!self.nonterminals[symbol]) continue; - if (ctx) { - q = self.gotoEncoded(production.symbol, production.handle.slice(0, i)); - } - var bool = !ctx || q === parseInt(self.lookahead.nonterminalMap[t], 10); + var oldSize = self.nonterminals[symbol].follows.size; - var set; - if (i === production.handle.length - 1 && bool) { - set = nonterminals[production.symbol].follows; + if (i === production.handle.length - 1) { + // Symbol at end: add FOLLOW(LHS) + self.nonterminals[production.symbol].follows.forEach(function(item) { + self.nonterminals[symbol].follows.add(item); + }); } else { - var part = production.handle.slice(i + 1); - set = self.first(part); - if (self.isNullable(part) && bool) { - set.push.apply(set, nonterminals[production.symbol].follows); + // Add FIRST(β) where β follows symbol + var beta = production.handle.slice(i + 1); + var firstSet = self.first(beta); + + // Add first set items + for (var j = 0; j < firstSet.length; j++) { + self.nonterminals[symbol].follows.add(firstSet[j]); + } + + // If β is nullable, also add FOLLOW(LHS) + if (self.isNullable(beta)) { + self.nonterminals[production.symbol].follows.forEach(function(item) { + self.nonterminals[symbol].follows.add(item); + }); } } - var oldcount = nonterminals[t].follows.length; - union(nonterminals[t].follows, set); - if (oldcount !== nonterminals[t].follows.length) { - cont = true; + if (self.nonterminals[symbol].follows.size > oldSize) { + changed = true; } } }); @@ -632,7 +516,7 @@ LALRGenerator.prototype.computeFollowSets = function() { }; // Compute closure of an item set (add all implied items) -LALRGenerator.prototype.closure = function(itemSet) { +LALRGenerator.prototype._closure = function(itemSet) { var closureSet = new LRState(); var self = this; var set = itemSet; @@ -640,16 +524,19 @@ LALRGenerator.prototype.closure = function(itemSet) { do { itemQueue = []; - closureSet.concat(set); + // Add all items from set to closureSet + (set.items ? Array.from(set.items) : set).forEach(function(item) { + closureSet.items.add(item); + }); - (set.list || set).forEach(function(item) { + (set.items ? Array.from(set.items) : set).forEach(function(item) { var symbol = item.nextSymbol; if (symbol && self.nonterminals[symbol]) { if (!syms[symbol]) { self.nonterminals[symbol].productions.forEach(function(production) { var newItem = new Item(production, 0); - if (!closureSet.contains(newItem)) { + if (!closureSet.items.has(newItem)) { itemQueue.push(newItem); } }); @@ -671,23 +558,23 @@ LALRGenerator.prototype.closure = function(itemSet) { }; // Compute goto operation (items after shifting a symbol) -LALRGenerator.prototype.goto = function(itemSet, symbol) { +LALRGenerator.prototype._goto = function(itemSet, symbol) { var gotoSet = new LRState(); var self = this; - itemSet.list.forEach(function(item, n) { + itemSet.items.forEach(function(item) { if (item.nextSymbol === symbol) { - gotoSet.push(new Item(item.production, item.dot + 1, item.follows, n)); + gotoSet.items.add(new Item(item.production, item.dot + 1, item.follows)); } }); - return gotoSet.length === 0 ? gotoSet : this.closure(gotoSet); + return gotoSet.items.size === 0 ? gotoSet : this._closure(gotoSet); }; // Generate canonical collection of LR(0) item sets LALRGenerator.prototype.buildLRAutomaton = function() { var item1 = new Item(this.productions[0], 0, [this.EOF]); - var firstState = this.closure(new LRState(item1)); + var firstState = this._closure(new LRState(item1)); var states = [firstState]; var marked = 0; var self = this; @@ -696,25 +583,23 @@ LALRGenerator.prototype.buildLRAutomaton = function() { states.has[firstState] = 0; while (marked !== states.length) { - var itemSet = states[marked]; - marked++; - - itemSet.list.forEach(function(item) { + var itemSet = states[marked++]; + itemSet.items.forEach(function(item) { if (item.nextSymbol && item.nextSymbol !== self.EOF) { - self.insertLRState(item.nextSymbol, itemSet, states, marked - 1); + self._insertLRState(item.nextSymbol, itemSet, states, marked - 1); } }); } - return states; + this.states = states; }; // Insert or merge item set into canonical collection -LALRGenerator.prototype.insertLRState = function(symbol, itemSet, states, stateNum) { - var g = this.goto(itemSet, symbol); +LALRGenerator.prototype._insertLRState = function(symbol, itemSet, states, stateNum) { + var g = this._goto(itemSet, symbol); if (!g.predecessors) g.predecessors = {}; - if (g.length > 0) { + if (g.items.size > 0) { var gv = g.valueOf(); var i = states.has[gv]; if (i === -1 || typeof i === 'undefined') { @@ -737,30 +622,29 @@ LALRGenerator.prototype.buildParseTable = function(itemSets) { var operators = this.operators; var conflictedStates = {}; var self = this; - var s = 1, r = 2, a = 3; - var NONASSOC = 0; + var NONASSOC = 0, SHIFT = 1, REDUCE = 2, ACCEPT = 3; itemSets.forEach(function(itemSet, k) { var state = states[k] = {}; // Set shift and goto actions for (var stackSymbol in itemSet.transitions) { - itemSet.list.forEach(function(item) { + itemSet.items.forEach(function(item) { if (item.nextSymbol === stackSymbol) { var gotoState = itemSet.transitions[stackSymbol]; if (nonterminals[stackSymbol]) { state[self.symbolMap[stackSymbol]] = gotoState; } else { - state[self.symbolMap[stackSymbol]] = [s, gotoState]; + state[self.symbolMap[stackSymbol]] = [SHIFT, gotoState]; } } }); } // Set accept action - itemSet.list.forEach(function(item) { + itemSet.items.forEach(function(item) { if (item.nextSymbol === self.EOF) { - state[self.symbolMap[self.EOF]] = [a]; + state[self.symbolMap[self.EOF]] = [ACCEPT]; } }); @@ -775,7 +659,7 @@ LALRGenerator.prototype.buildParseTable = function(itemSets) { var op = operators[stackSymbol]; if (action || (action && action.length)) { - var sol = self.resolveConflict(item.production, op, [r, item.production.id], + var sol = self.resolveConflict(item.production, op, [REDUCE, item.production.id], action[0] instanceof Array ? action[0] : action); self.resolutions.push([k, stackSymbol, sol]); @@ -792,7 +676,7 @@ LALRGenerator.prototype.buildParseTable = function(itemSets) { action = sol.action; } } else { - action = [r, item.production.id]; + action = [REDUCE, item.production.id]; } if (action && action.length) { @@ -804,7 +688,7 @@ LALRGenerator.prototype.buildParseTable = function(itemSets) { }); }); - return states; + this.stateTable = states; }; // Resolve shift/reduce conflicts using operator precedence @@ -855,7 +739,7 @@ LALRGenerator.prototype.computeDefaultActions = function(states) { defaults[k] = state[act]; } }); - return defaults; + this.defaultActions = defaults; }; // LALR-specific methods @@ -887,67 +771,6 @@ LALRGenerator.prototype.gotoStateWithPath = function(startState, symbolSequence) return { path: path, endState: currentState }; }; -// Build augmented grammar for lookahead computation -LALRGenerator.prototype.buildAugmentedGrammar = function() { - var self = this; - var newg = this.lookahead; - - this.states.forEach(function(state, i) { - state.list.forEach(function(item) { - if (item.dot === 0) { - var symbol = i + ":" + item.production.symbol; - self.terminalMap[symbol] = item.production.symbol; - newg.nonterminalMap[symbol] = i; - if (!newg.nonterminals[symbol]) { - newg.nonterminals[symbol] = new Nonterminal(symbol); - } - var pathInfo = self.gotoStateWithPath(i, item.production.handle); - var p = new Production(symbol, pathInfo.path, newg.productions.length); - newg.productions.push(p); - newg.nonterminals[symbol].productions.push(p); - - var handle = item.production.handle.join(' '); - var handleToSymbols = self.states[pathInfo.endState].handleToSymbols; - if (!handleToSymbols[handle]) { - handleToSymbols[handle] = []; - } - handleToSymbols[handle].push(symbol); - } - }); - if (state.hasConflicts) { - self.conflictStates.push(i); - } - }); -}; - -// Propagate lookaheads from augmented grammar back to original states -LALRGenerator.prototype.unionLookaheads = function() { - var self = this; - var newg = this.lookahead; - var states = !!this.onDemandLookahead ? this.conflictStates : this.states; - - states.forEach(function(i) { - var state = typeof i === 'number' ? self.states[i] : i; - if (state.reductions.length) { - state.reductions.forEach(function(item) { - var follows = {}; - for (var k = 0; k < item.follows.length; k++) { - follows[item.follows[k]] = true; - } - state.handleToSymbols[item.production.handle.join(' ')].forEach(function(symbol) { - newg.nonterminals[symbol].follows.forEach(function(symbol) { - var terminal = self.terminalMap[symbol]; - if (!follows[terminal]) { - follows[terminal] = true; - item.follows.push(terminal); - } - }); - }); - }); - } - }); -}; - // Code generation // Generate parser code with specified options LALRGenerator.prototype.generate = function(opt) { @@ -1237,6 +1060,8 @@ LALRGenerator.prototype.createParser = function() { }; // Exports + +// Create parser directly from grammar Jison.Parser = function(grammar, options) { var gen = new LALRGenerator(grammar, options); return gen.createParser(); @@ -1244,11 +1069,13 @@ Jison.Parser = function(grammar, options) { exports.LALRGenerator = LALRGenerator; +// Create generator instance from grammar Jison.Generator = function(g, options) { var opt = Object.assign({}, g.options, options); return new LALRGenerator(g, opt); }; +// Main parser factory function return function Parser(g, options) { var gen = Jison.Generator(g, options); return gen.createParser(); diff --git a/package.json b/package.json index 0152e975a..e02748fee 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ ], "name": "jison", "description": "A parser generator with Bison's API", - "version": "0.5.0", + "version": "0.6.0", "license": "MIT", "keywords": [ "jison",

&a(Zh-Vl+J0E(Pb-%r_gOk4b+X}|o$My3iGiG$sdZx|~WA0j|8C;iF zR5-sy4!o=H_@pH7q=nsy$ zs&lK~c0g?}@S=OS%^hajM!g&QS8>(85 zQjhyIEqS&Ft$gW&D^d%0#B2yR5__Jb|0=beh?Af7?!1A=OwHjdhn*kjR+SxixV?P8 zMPb9uspd}YNgrnKERy5Et!MZIhc@P_cRNxHrd`%7U3}u`BddAYu3>izTIv^e1w8Sp zZGHlu|8o7g(4?0`K=G6CLsN$$ z&`tbXq8%BFSLEs_=Sb>az8k>^IB33RlTk*}x4lEJP7Y^n+EKSprDxO2w-ve?eUsLc z7&<^OiO z`hWa(2v9J9r#15JkkL&A81wP}U7O0EwEagb{=f2D5t#PD7f4bigte2qD?XVozaiY% zbg;(hl$@zh#Kq%t{EbZRJH>gcT$jI^dA#U_;bxO46>IsMms7E&mnjmAz4@h#gR!&7 z*t(-z9X`IVTJGS(=Nuj=&<~}CHRl*Etr24O2^N)!|l zRy9p~fIU#_`n+M_dsy^O|O2yBCXN_v=T0d**Sa-n>h+&=R;3waBSWEC@ znt>B{9N-0j7KU2SE*FNilx4tz8$I=b-=-lFmy9QX-|Z13z2yGr{nyBrXpxn+I>VlyZzff|@v+&yN_a=WuwmHeBcY`#WDyKH{agzS7b!TeY(457fbHUhPaT zQm$a6bWhIQ{H0t~U8x*j*ixVo*Yvt6`f_bv%tr&eS6$nRb+?;aeO}n?P%ZOn2DIm( zrdx&iZ7us8nG@$ug|95XSAQO5)i*t4=Go6MW>qegHTZhkg+<*{DOA?X+rDqU<@c%7 zd&1pwuxEi2OBYyqZGx4T^3NXsfG5jO+RQ{-Rsw1ktTJxg0G?A)KbbG!KN_d3dY&@g zp-!WBdq36M*ZywL>`4`kM=JE}^&V<8a4gn6gyZi|XaGG4AKw7SUxIxs2hj*Pf%)DZ>DOO(*4ZQGg74++H7hp-nYd2mbFjl8-Z|J4^DBE|=3O2s zek5^a@3j}Tj)T`@E*uK%emQxmiTWAM;GBbzI!lDLM6QPJT12#0HT-G4VD-$kw5p8UR!p{pIBw)v9hscP%uH+#Y>Arjai_xx977>X$XDt{-KG`snWrQ}L+lGEZ%9l%&XX zS>Jv!vqv)}>D@ciIF~Qf$~(QDyT!e) - - - - - \ No newline at end of file diff --git a/ports/csharp/Jison/Jison/csharp.js b/ports/csharp/Jison/Jison/csharp.js deleted file mode 100644 index 48ad1b498..000000000 --- a/ports/csharp/Jison/Jison/csharp.js +++ /dev/null @@ -1,274 +0,0 @@ -var fs = require('fs'), - util = require('util'), - execFile = require('child_process').execFile, - path = require('path'); - -GLOBAL.convertToSyntax = function (types, body) { - if (types['cs'] || types['CS'] || types['c#'] || types['C#'] || types['csharp'] || types['CSharp']) { - return body; - } - return ''; -}; - -function puts(error, stdout, stderr) { - util.puts(stdout); -} - -console.log("Executing: " + "jison " + process.argv[2]); - -execFile("jison", [process.argv[2]], function (error) { - if (error) { - console.log(error); - return; - } - - String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');}; - - var fileName = process.argv[2].replace(/(.jison|.json)/, '') - comments = require(path.resolve(__dirname, '../../../comments.js')), - requirePath = fileName + '.js'; - - console.log("Opening newly created jison js file: " + fileName + '.js'); - - var Parser = require(requirePath), - symbols = Parser.parser.symbols_, - terminals = Parser.parser.terminals_, - productions = Parser.parser.productions_, - table = Parser.parser.table, - defaultActions = Parser.parser.defaultActions, - //turn regex into string - rules = []; - - for (var i = 0; i < Parser.parser.lexer.rules.length; i++) { - rules.push(Parser.parser.lexer.rules[i].toString()); - } - - var conditions = Parser.parser.lexer.conditions, - options = Parser.parser.lexer.options, - parserPerformAction = Parser.parser.performAction.toString(), - lexerPerformAction = Parser.parser.lexer.performAction.toString(); - - function jsFnBody(str) { - str = str.split('{'); - str.shift(); - str = str.join('{'); - - str = str.split('}'); - str.pop(); - str = str.join('}'); - - return str; - } - - function jsPerformActionToCs(str, isLex) { - str = jsFnBody(str); - str = str.replace("var $0 = $$.length - 1;", ''); - str = str.replace("var YYSTATE=YY_START", ''); - str = str.replace(new RegExp('[$]0', 'g'), 'so'); - str = str.replace(new RegExp('[$][$]', 'g'), 'ss'); - str = str.replace(new RegExp('default[:][;]', 'g'), ''); - str = str.replace(new RegExp('this[.][$]', 'g'), 'thisS'); - str = str.replace(new RegExp('[.]yytext', 'g'), '.yytext'); - str = str.replace(new RegExp('[$]accept', 'g'), 'accept'); - str = str.replace(new RegExp('[$]end', 'g'), 'end'); - str = str.replace(new RegExp('console[.]log'), ''); - str = str.replace(new RegExp('[$]avoiding_name_collisions'), 'avoidingNameCollisions'); - if (isLex) { - str = str - .replace(/(return[ ]+)(['"])([a-zA-Z0-9]+)(['"][;])/g, function() { - var symbol = symbols[arguments[3]]; - if (symbol) { - return arguments[1] + symbol + ';'; - } - return arguments[1] + '"' + arguments[3] + '";'; - }); - } - str = comments.parse(str); - - str = str.replace(/(\d)\n/g, function () { - return arguments[1] + ';\n'; - }); - - return str; - } - - var FileName = fileName.charAt(0).toUpperCase() + fileName.slice(1); - var ClassName = FileName.replace(/^.*[\\\/]/, '').charAt(0).toUpperCase() + FileName.replace(/^.*[\\\/]/, '').slice(1); - var option = { - 'using': '', - 'namespace': 'Jison', - 'class': ClassName, - 'fileName': FileName + '.cs', - 'parserValue': '' - }; - - - if (fileName.search(/jison/) !== -1) { - var parserDefinition = fs.readFileSync(fileName + '.jison', "utf8"); - parserDefinition = parserDefinition.split(/\n/g); - for (var i = 0; i < parserDefinition.length; i++) { - if (parserDefinition[i].match('//option')) { - parserDefinition[i] = parserDefinition[i].replace('//option ', '').trim(); - parserDefinition[i] = parserDefinition[i].split(':'); - option[parserDefinition[i][0]] = parserDefinition[i][1]; - } - } - } - - console.log(option); - - var parserRaw = fs.readFileSync(__dirname + "/Template.cs", "utf8"); - - function parserInject() { - var result = '\n'; - this.symbols = []; - this.symbolsByIndex = []; - this.tableInstantiation = []; - this.tableDefinition = []; - this.tableSetActions = []; - this.table = []; - this.terminals = []; - this.defaultActions = []; - this.productions = []; - - var actions = [ - 'None', - 'Shift', - 'Reduce', - 'Accept' - ]; - - for (var i in symbols) { - this.symbolsByIndex[symbols[i] * 1] = { - name: i.replace('$', ''), - index: symbols[i] - }; - } - - for (var i in this.symbolsByIndex) { - var symbol = this.symbolsByIndex[i]; - result += '\t\t\tvar symbol' + symbol.index + ' = new ParserSymbol("' + symbol.name + '", ' + symbol.index + ');\n'; - this.symbols.push('\t\t\tSymbols.Add(symbol' + symbol.index + ')'); - - } - - result += '\n\n\t\t\tSymbols = new ParserSymbols();\n'; - result += this.symbols.join(';\n') + ';\n\n'; - - for (var i in terminals) { - this.terminals.push('\t\t\t\t\t{' + i + ', symbol' + i + '}'); - } - - result += '\t\t\tTerminals = new Dictionary\n\t\t\t\t{\n' + this.terminals.join(',\n') + '\n\t\t\t\t};\n\n'; - - for (var i in table) { - var items = []; - for (var j in table[i]) { - var item = table[i][j], - action = 0, - state = 0; - if (item.join) { //is array - if (item.length == 1) { - action = item[0]; - items.push('\t\t\t\t\t{' + j + ', new ParserAction(' + actions[action] + ')}'); - } else { - action = item[0]; - state = item[1]; - items.push('\t\t\t\t\t{' + j + ', new ParserAction(' + actions[action] + ', ref table' + state + ')}'); - } - } else { - state = item; - items.push('\t\t\t\t\t{' + j + ', new ParserAction(' + actions[action] + ', ref table' + state + ')}'); - } - } - - this.tableInstantiation.push('\t\t\tvar table' + i + ' = new ParserState(' + i + ')'); - this.tableDefinition.push('\t\t\tvar tableDefinition' + i + ' = new Dictionary\n\t\t\t\t{\n' + items.join(',\n') + '\n\t\t\t\t}'); - this.tableSetActions.push('\t\t\ttable' + i + '.SetActions(ref tableDefinition' + i + ')'); - this.table.push('\t\t\t\t\t{' + i + ', table' + i + '}'); - } - - result += this.tableInstantiation.join(';\n') + ';\n\n'; - result += this.tableDefinition.join(';\n\n') + ';\n\n'; - result += this.tableSetActions.join(';\n') + ';\n\n'; - result += '\t\t\tTable = new Dictionary\n\t\t\t\t{\n' + this.table.join(',\n') + '\n\t\t\t\t};\n\n'; - - for (var i in defaultActions) { - var action = defaultActions[i][0]; - var state = defaultActions[i][1]; - this.defaultActions.push('\t\t\t\t\t{' + i + ', new ParserAction(' + actions[action] +', ref table' + state + ')}'); - } - - result += '\t\t\tDefaultActions = new Dictionary\n\t\t\t\t{\n' + this.defaultActions.join(',\n') + '\n\t\t\t\t};\n\n'; - - for (var i in productions) { - var production = productions[i]; - if (production.join) { - var symbol = production[0], - len = production[1]; - this.productions.push('\t\t\t\t\t{' + i + ', new ParserProduction(symbol' + this.symbolsByIndex[symbol].index + ',' + len + ')}'); - } else { - var symbol = production; - this.productions.push('\t\t\t\t\t{' + i + ', new ParserProduction(symbol' + this.symbolsByIndex[symbol].index + ')}'); - } - } - - result += '\t\t\tProductions = new Dictionary\n\t\t\t\t{\t\t\t\t\n' + this.productions.join(',\n') + '\n\t\t\t\t};\n\n\n'; - - return result; - } - - function lexerInject() { - var result = '\n'; - this.rules = [], - this.conditions = []; - - for (var i in rules) { - this.rules.push('\t\t\t\t\t{' + i + ', new Regex(@"' + rules[i].substring(1, rules[i].length - 1).replace(/"/g, '""') + '")}'); - } - - result += '\t\t\tRules = new Dictionary\n\t\t\t\t{\n' + this.rules.join(',\n') + '\n\t\t\t\t};\n\n'; - - for (var i in conditions) { - this.conditions.push('\t\t\t\t\t{"' + i + '", new LexerConditions(new List { ' + conditions[i].rules.join(',') + ' }, ' + conditions[i].inclusive + ')}'); - } - - result += '\t\t\tConditions = new Dictionary\n\t\t\t\t{\n' + this.conditions.join(',\n') + '\n\t\t\t\t};\n\n'; - - return result; - } - - parserRaw = parserRaw - .replace(new RegExp('//@@USING_INJECT@@', 'g'),(option.using ? 'using ' + option.using.split(',').join(';\nusing ') + ';' : '')) - .replace(new RegExp('[/][*][*][/]namespace Jison[/][*][*][/]', 'g'), 'namespace ' + option.namespace) - .replace(new RegExp('[/][*][*][/]class Parser[/][*][*][/]', 'g'), 'class ' + option.class) - .replace(new RegExp('[/][*][*][/]public Parser[/][*][*][/]', 'g'), 'public ' + option.class) - .replace(new RegExp('[/][*][*][/]ParserValue[/][*][*][/]', 'g'), (option.parserValue || 'ParserValue')) - .replace('new Parser(', 'new ' + option.class + '(') - - .replace('//@@PARSER_INJECT@@', - parserInject() - ) - - .replace('//@@LEXER_INJECT@@', - lexerInject() - ) - - .replace('//@@ParserPerformActionInjection@@', - jsPerformActionToCs(parserPerformAction) - ) - - .replace('//@@LexerPerformActionInjection@@', - jsPerformActionToCs(lexerPerformAction, true) - ); - - fs.writeFile(option.fileName, parserRaw, function (err) { - if (err) { - console.log("Something went bad"); - console.log(err); - } else { - console.log("Success writing new parser files " + fileName + ".js" + " & " + option.fileName); - console.log("Please Note: The csharp version of the jison parser is only an ATTEMPTED conversion"); - } - }); -}); \ No newline at end of file diff --git a/ports/php/php.js b/ports/php/php.js deleted file mode 100644 index 892dfa62f..000000000 --- a/ports/php/php.js +++ /dev/null @@ -1,268 +0,0 @@ -var fs = require('fs'), - util = require('util'), - execFile = require('child_process').execFile, - path = require('path'); - -global.convertToSyntax = function (types, body) { - if (types['php'] || types['PHP']) { - return body; - } - return ''; -}; - -function puts(error, stdout, stderr) { - util.puts(stdout); -} - -console.log("Executing: " + "jison " + process.argv[2]); - -execFile("jison", [process.argv[2]], function (error) { - if (error) { - console.log(error); - return; - } - - String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');}; - - var fileName = process.argv[2].replace('.jison', ''), - comments = require(path.resolve(__dirname, '../comments.js')), - requirePath = path.resolve(process.argv[2]).replace('.jison', '') + '.js'; - - console.log("Opening newly created jison js file: " + fileName + '.js'); - - var Parser = require(requirePath), - symbols = Parser.parser.symbols_, - terminals = Parser.parser.terminals_, - productions = Parser.parser.productions_, - table = Parser.parser.table, - defaultActions = Parser.parser.defaultActions, - //turn regex into string - rules = []; - - for (var i = 0; i < Parser.parser.lexer.rules.length; i++) { - rules.push(Parser.parser.lexer.rules[i].toString()); - } - - var conditions = Parser.parser.lexer.conditions, - options = Parser.parser.lexer.options, - parserPerformAction = Parser.parser.performAction.toString(), - lexerPerformAction = Parser.parser.lexer.performAction.toString(); - - function jsFnBody(str) { - str = str.split('{'); - str.shift(); - str = str.join('{'); - - str = str.split('}'); - str.pop(); - str = str.join('}'); - - return str; - } - - function jsPerformActionToPhp(str) { - str = jsFnBody(str); - str = str.replace("var $0 = $$.length - 1;", ''); - str = str.replace("var YYSTATE=YY_START", ''); - str = str.replace(new RegExp('[$]0', 'g'), '$o'); - str = str.replace(new RegExp('[$][$]', 'g'), '$s'); - str = str.replace(new RegExp('default[:][;]', 'g'), ''); - str = str.replace(new RegExp('this[.][$]', 'g'), '$thisS'); - str = str.replace(new RegExp('this[-][>]', 'g'), '$this->'); - str = str.replace(new RegExp('yystate', 'g'), '$yystate'); - //str = str.replace(new RegExp('yytext', 'g'), 'yy->text'); - str = str.replace(new RegExp('[$]yy[_][.]', 'g'), '$this->yy->'); - str = str.replace(new RegExp('[$]this[-][>]yy[-][>]yy', 'g'), '$this->yy->'); - str = str.replace(new RegExp('[.]yytext', 'g'), '->text'); - str = str.replace(new RegExp('yy[.]', 'g'), 'yy->'); - str = str.replace(new RegExp('yy_[.][$]', 'g'), '$this->yy->'); - str = str.replace(new RegExp('[$]accept', 'g'), 'accept'); - str = str.replace(new RegExp('[$]end', 'g'), 'end'); - str = str.replace(new RegExp('console[.]log'), ''); - str = str.replace(new RegExp('[$]avoiding_name_collisions'), '$avoidingNameCollisions'); - - str = comments.parse(str); - - str = str.replace(/(\d)\n/g, function () { - return arguments[1] + ';\n'; - }); - - return str; - } - - - var option = { - 'namespace': 'Jison', - 'class': fileName, - 'fileName': fileName + '.php', - 'extends': '', - 'use': '', - 'parserValue': '' - }; - - var parserDefinition = fs.readFileSync(fileName + '.jison', "utf8"); - parserDefinition = parserDefinition.split(/\n/g); - for(var i = 0; i < parserDefinition.length; i++) { - if (parserDefinition[i].match('//option')) { - parserDefinition[i] = parserDefinition[i].replace('//option ', ''); - parserDefinition[i] = parserDefinition[i].split(':'); - option[parserDefinition[i][0]] = parserDefinition[i][1]; - } - } - - console.log(option); - - var parserRaw = fs.readFileSync(__dirname + "/template.php", "utf8"); - - function parserInject() { - var result = '\n'; - this.symbols = []; - this.symbolsByIndex = []; - this.tableInstantiation = []; - this.tableDefinition = []; - this.tableSetActions = []; - this.table = []; - this.terminals = []; - this.defaultActions = []; - this.productions = []; - - var actions = [ - 'none', - 'shift', - 'reduce', - 'accept' - ]; - - for (var i in symbols) { - this.symbolsByIndex[symbols[i] * 1] = { - name: i.replace('$', ''), - index: symbols[i] - }; - } - - console.log(this.symbolsByIndex); - - for (var i in this.symbolsByIndex) { - var symbol = this.symbolsByIndex[i]; - result += '\t\t\t$symbol' + symbol.index + ' = new ParserSymbol("' + symbol.name + '", ' + symbol.index + ');\n'; - this.symbols.push('\t\t\t$this->symbols[' + symbol.index + '] = $symbol' + symbol.index + ''); - this.symbols.push('\t\t\t$this->symbols["' + symbol.name + '"] = $symbol' + symbol.index + ''); - - } - - result += this.symbols.join(';\n') + ';\n\n'; - - for (var i in terminals) { - this.terminals.push('\t\t\t\t\t' + i + '=>&$symbol' + i + ''); - } - - result += '\t\t\t$this->terminals = array(\n' + this.terminals.join(',\n') + '\n\t\t\t\t);\n\n'; - - for (var i in table) { - var items = []; - for (var j in table[i]) { - var item = table[i][j], - action = 0, - state = 0; - if (item.join) { //is array - if (item.length == 1) { - action = item[0]; - items.push('\t\t\t\t\t' + j + '=>new ParserAction($this->' + actions[action] + ')'); - } else { - action = item[0]; - state = item[1]; - items.push('\t\t\t\t\t' + j + '=>new ParserAction($this->' + actions[action] + ', $table' + state + ')'); - } - } else { - state = item; - items.push('\t\t\t\t\t' + j + '=>new ParserAction($this->' + actions[action] + ', $table' + state + ')'); - } - } - - this.tableInstantiation.push('\t\t\t$table' + i + ' = new ParserState(' + i + ')'); - this.tableDefinition.push('\t\t\t$tableDefinition' + i + ' = array(\n\t\t\t\t\n' + items.join(',\n') + '\n\t\t\t\t)'); - this.tableSetActions.push('\t\t\t$table' + i + '->setActions($tableDefinition' + i + ')'); - this.table.push('\t\t\t\t\t' + i + '=>$table' + i + ''); - } - - result += this.tableInstantiation.join(';\n') + ';\n\n'; - result += this.tableDefinition.join(';\n\n') + ';\n\n'; - result += this.tableSetActions.join(';\n') + ';\n\n'; - result += '\t\t\t$this->table = array(\n\t\t\t\t\n' + this.table.join(',\n') + '\n\t\t\t\t);\n\n'; - - for (var i in defaultActions) { - var action = defaultActions[i][0]; - var state = defaultActions[i][1]; - this.defaultActions.push('\t\t\t\t\t' + i + '=>new ParserAction($this->' + actions[action] +', $table' + state + ')'); - } - - result += '\t\t\t$this->defaultActions = array(\n\t\t\t\t\n' + this.defaultActions.join(',\n') + '\n\t\t\t\t);\n\n'; - - for (var i in productions) { - var production = productions[i]; - if (production.join) { - var symbol = production[0], - len = production[1]; - this.productions.push('\t\t\t\t\t' + i + '=>new ParserProduction($symbol' + this.symbolsByIndex[symbol].index + ',' + len + ')'); - } else { - var symbol = production; - this.productions.push('\t\t\t\t\t' + i + '=>new ParserProduction($symbol' + this.symbolsByIndex[symbol].index + ')'); - } - } - - result += '\t\t\t$this->productions = array(\n\t\t\t\t\n' + this.productions.join(',\n') + '\n\t\t\t\t);\n\n\n'; - - return result; - } - - function lexerInject() { - var result = '\n'; - this.rules = [], - this.conditions = []; - - for (var i in rules) { - this.rules.push('\t\t\t\t\t' + i + '=>"/' + rules[i].substring(1, rules[i].length - 1).replace(/"/g, '\\"') + '/"'); - } - - result += '\t\t\t$this->rules = array(\n\t\t\t\t\n' + this.rules.join(',\n') + '\n\t\t\t\t);\n\n'; - - for (var i in conditions) { - this.conditions.push('\t\t\t\t\t"' + i + '"=>new LexerConditions(array( ' + conditions[i].rules.join(',') + '), ' + conditions[i].inclusive + ')'); - } - - result += '\t\t\t$this->conditions = array(\n\t\t\t\t\n' + this.conditions.join(',\n') + '\n\t\t\t\t);\n\n'; - - return result; - } - - parserRaw = parserRaw - .replace('/**/namespace Jison;/**/', (option.namespace ? 'namespace ' + option.namespace + ';\nuse Exception;\n' : '')) - .replace('/**/class Parser/**/', 'class ' + option.class + (option.extends ? ' extends ' + option.extends : '')) - .replace('/**use**/', (option.use ? 'use ' + option.use : '')) - .replace(/[/][*][*][/]ParserValue[/][*][*][/]/g, (option.parserValue ? option.parserValue : 'ParserValue')) - - .replace('//@@PARSER_INJECT@@', - parserInject() - ) - - .replace('//@@LEXER_INJECT@@', - lexerInject() - ) - - .replace('//@@ParserPerformActionInjection@@', - jsPerformActionToPhp(parserPerformAction) - ) - - .replace('//@@LexerPerformActionInjection@@', - jsPerformActionToPhp(lexerPerformAction, true) - ); - - fs.writeFile(option.fileName, parserRaw, function(err) { - if (err) { - console.log("Something went bad"); - } else { - console.log("Success writing new parser files " + fileName + ".js" + " & " + option.fileName); - console.log("Please Note: The php version of the jison parser is only an ATTEMPTED conversion"); - } - }); -}); \ No newline at end of file diff --git a/ports/php/readme b/ports/php/readme deleted file mode 100644 index 4f7c84d34..000000000 --- a/ports/php/readme +++ /dev/null @@ -1,43 +0,0 @@ -Name: Jison Parser Php Port -Written By: Robert Plummer, RobertLeePlummerJr@gmail.com -Description: A jison wrapper that first processes a jison file and then injects a php template with the variables from a .js file. - -DIRECTIONS: -1. After you've downloaded jison & node.js, navigate in command line interface to the folder that contains the ".jison" file that you want to process -2. Process the ".jison" file like this "nodejs /location_of_jison/ports/php/php.js my_jison_file.jison" - -CONFIGURATION: -Configuration takes advantage of the commenting in javascript so as not to conflict with. -*In your ".jison" file -**A that has a "//js" comment BEFORE the javascript line starts a javascript area of the parser section. Which will be removed from the php. -**A line that simply has "//" ends whatever commenting is currently active. -**A that has a "//php" comment ON the line of php it starts a php area of the parser section. In Javascript this is just a comment, in php though, the comment is removed so that it can be called. -**A that has no comment, is left alone. -*Comments in the ".jison" file that start with "//option" can be used to configure the output of the php file. -**//option optionName:value -**Current Options: -*** "namespace" - default is "Jison" -*** "class" - default is your ".jison" file without the file extension -*** "fileName" - default is your ".jison" file without the file extension followed by ".php" - -EXAMPLE: -contents - : content - {$$ = $1;} //<--this is left alone - | contents content - { - //js - $$ = join($1, $2); //<--this is stripped in the php parser, no action taken in the javascript parser - - //php $$ = $SomeClass->someMethod($1, $2); //<-- this is uncommented from the php parser, no action taken in the javascript parser - - /*php - $$ = $SomeClass->someMethod($1, $2); //<-- this is uncommented from the php parser, no action taken in the javascript parser - */ - - /* If you'd like to just strip out the javascript and do nothing else, you can do the following: */ - //js - $$ = join($1, $2); //<--this is stripped in the php parser, no action taken in the javascript parser - // - } - ; diff --git a/ports/php/template.php b/ports/php/template.php deleted file mode 100644 index 44f0d0a9e..000000000 --- a/ports/php/template.php +++ /dev/null @@ -1,615 +0,0 @@ -lexerLex(); // $end = 1 - - if (isset($token)) { - return $token; - } - - return $this->symbols["end"]; - } - - function parseError($str = "", ParserError $hash = null) - { - throw new Exception($str); - } - - function lexerError($str = "", LexerError $hash = null) - { - throw new Exception($str); - } - - function parse($input) - { - if (empty($this->table)) { - throw new Exception("Empty Table"); - } - $this->eof = new ParserSymbol("Eof", 1); - $firstAction = new ParserAction(0, $this->table[0]); - $firstCachedAction = new ParserCachedAction($firstAction); - $stack = array($firstCachedAction); - $stackCount = 1; - $vstack = array(null); - $vstackCount = 1; - $yy = null; - $_yy = null; - $recovering = 0; - $symbol = null; - $action = null; - $errStr = ""; - $preErrorSymbol = null; - $state = null; - - $this->setInput($input); - - while (true) { - // retrieve state number from top of stack - $state = $stack[$stackCount - 1]->action->state; - // use default actions if available - if ($state != null && isset($this->defaultActions[$state->index])) { - $action = $this->defaultActions[$state->index]; - } else { - if (empty($symbol) == true) { - $symbol = $this->parserLex(); - } - // read action for current state and first input - if (isset($state) && isset($state->actions[$symbol->index])) { - //$action = $this->table[$state][$symbol]; - $action = $state->actions[$symbol->index]; - } else { - $action = null; - } - } - - if ($action == null) { - if ($recovering == 0) { - // Report error - $expected = array(); - foreach($this->table[$state->index]->actions as $p => $item) { - if (!empty($this->terminals[$p]) && $p > 2) { - $expected[] = $this->terminals[$p]->name; - } - } - - $errStr = "Parse error on line " . ($this->yy->lineNo + 1) . ":\n" . $this->showPosition() . "\nExpecting " . implode(", ", $expected) . ", got '" . (isset($this->terminals[$symbol->index]) ? $this->terminals[$symbol->index]->name : 'NOTHING') . "'"; - - $this->parseError($errStr, new ParserError($this->match, $state, $symbol, $this->yy->lineNo, $this->yy->loc, $expected)); - } - } - - if ($state === null || $action === null) { - break; - } - - switch ($action->action) { - case 1: - // shift - //$this->shiftCount++; - $stack[] = new ParserCachedAction($action, $symbol); - $stackCount++; - - $vstack[] = clone($this->yy); - $vstackCount++; - - $symbol = ""; - if ($preErrorSymbol == null) { // normal execution/no error - $yy = clone($this->yy); - if ($recovering > 0) $recovering--; - } else { // error just occurred, resume old look ahead f/ before error - $symbol = $preErrorSymbol; - $preErrorSymbol = null; - } - break; - - case 2: - // reduce - $len = $this->productions[$action->state->index]->len; - // perform semantic action - $_yy = $vstack[$vstackCount - $len];// default to $S = $1 - // default location, uses first token for firsts, last for lasts - - if (isset($this->ranges)) { - //TODO: add ranges - } - - $r = $this->parserPerformAction($_yy->text, $yy, $action->state->index, $vstack, $vstackCount - 1); - - if (isset($r)) { - return $r; - } - - // pop off stack - while ($len > 0) { - $len--; - - array_pop($stack); - $stackCount--; - - array_pop($vstack); - $vstackCount--; - } - - if (is_null($_yy)) - { - $vstack[] = new /**/ParserValue/**/(); - } - else - { - $vstack[] = $_yy; - } - $vstackCount++; - - $nextSymbol = $this->productions[$action->state->index]->symbol; - // goto new state = table[STATE][NONTERMINAL] - $nextState = $stack[$stackCount - 1]->action->state; - $nextAction = $nextState->actions[$nextSymbol->index]; - - $stack[] = new ParserCachedAction($nextAction, $nextSymbol); - $stackCount++; - - break; - - case 3: - // accept - return true; - } - - } - - return true; - } - - - /* Jison generated lexer */ - public $eof; - public $yy = null; - public $match = ""; - public $matched = ""; - public $conditionStack = array(); - public $conditionStackCount = 0; - public $rules = array(); - public $conditions = array(); - public $done = false; - public $less; - public $more; - public $input; - public $offset; - public $ranges; - public $flex = false; - - function setInput($input) - { - $this->input = $input; - $this->more = $this->less = $this->done = false; - $this->yy = new /**/ParserValue/**/(); - $this->conditionStack = array('INITIAL'); - $this->conditionStackCount = 1; - - if (isset($this->ranges)) { - $loc = $this->yy->loc = new ParserLocation(); - $loc->Range(new ParserRange(0, 0)); - } else { - $this->yy->loc = new ParserLocation(); - } - $this->offset = 0; - } - - function input() - { - $ch = $this->input[0]; - $this->yy->text .= $ch; - $this->yy->leng++; - $this->offset++; - $this->match .= $ch; - $this->matched .= $ch; - $lines = preg_match("/(?:\r\n?|\n).*/", $ch); - if (count($lines) > 0) { - $this->yy->lineNo++; - $this->yy->lastLine++; - } else { - $this->yy->loc->lastColumn++; - } - if (isset($this->ranges)) { - $this->yy->loc->range->y++; - } - - $this->input = array_slice($this->input, 1); - return $ch; - } - - function unput($ch) - { - $len = strlen($ch); - $lines = explode("/(?:\r\n?|\n)/", $ch); - $linesCount = count($lines); - - $this->input = $ch . $this->input; - $this->yy->text = substr($this->yy->text, 0, $len - 1); - //$this->yylen -= $len; - $this->offset -= $len; - $oldLines = explode("/(?:\r\n?|\n)/", $this->match); - $oldLinesCount = count($oldLines); - $this->match = substr($this->match, 0, strlen($this->match) - 1); - $this->matched = substr($this->matched, 0, strlen($this->matched) - 1); - - if (($linesCount - 1) > 0) $this->yy->lineNo -= $linesCount - 1; - $r = $this->yy->loc->range; - $oldLinesLength = (isset($oldLines[$oldLinesCount - $linesCount]) ? strlen($oldLines[$oldLinesCount - $linesCount]) : 0); - - $this->yy->loc = new ParserLocation( - $this->yy->loc->firstLine, - $this->yy->lineNo, - $this->yy->loc->firstColumn, - $this->yy->loc->firstLine, - (empty($lines) ? - ($linesCount == $oldLinesCount ? $this->yy->loc->firstColumn : 0) + $oldLinesLength : - $this->yy->loc->firstColumn - $len) - ); - - if (isset($this->ranges)) { - $this->yy->loc->range = array($r[0], $r[0] + $this->yy->leng - $len); - } - } - - function more() - { - $this->more = true; - } - - function pastInput() - { - $past = substr($this->matched, 0, strlen($this->matched) - strlen($this->match)); - return (strlen($past) > 20 ? '...' : '') . preg_replace("/\n/", "", substr($past, -20)); - } - - function upcomingInput() - { - $next = $this->match; - if (strlen($next) < 20) { - $next .= substr($this->input, 0, 20 - strlen($next)); - } - return preg_replace("/\n/", "", substr($next, 0, 20) . (strlen($next) > 20 ? '...' : '')); - } - - function showPosition() - { - $pre = $this->pastInput(); - - $c = ''; - for($i = 0, $preLength = strlen($pre); $i < $preLength; $i++) { - $c .= '-'; - } - - return $pre . $this->upcomingInput() . "\n" . $c . "^"; - } - - function next() - { - if ($this->done == true) { - return $this->eof; - } - - if (empty($this->input)) { - $this->done = true; - } - - if ($this->more == false) { - $this->yy->text = ''; - $this->match = ''; - } - - $rules = $this->currentRules(); - for ($i = 0, $j = count($rules); $i < $j; $i++) { - preg_match($this->rules[$rules[$i]], $this->input, $tempMatch); - if ($tempMatch && (empty($match) || count($tempMatch[0]) > count($match[0]))) { - $match = $tempMatch; - $index = $i; - if (isset($this->flex) && $this->flex == false) { - break; - } - } - } - if ( $match ) { - $matchCount = strlen($match[0]); - $lineCount = preg_match("/(?:\r\n?|\n).*/", $match[0], $lines); - $line = ($lines ? $lines[$lineCount - 1] : false); - $this->yy->lineNo += $lineCount; - - $this->yy->loc = new ParserLocation( - $this->yy->loc->lastLine, - $this->yy->lineNo + 1, - $this->yy->loc->lastColumn, - ($line ? - strlen($line) - preg_match("/\r?\n?/", $line, $na) : - $this->yy->loc->lastColumn + $matchCount - ) - ); - - - $this->yy->text .= $match[0]; - $this->match .= $match[0]; - $this->matches = $match; - $this->matched .= $match[0]; - - $this->yy->leng = strlen($this->yy->text); - if (isset($this->ranges)) { - $this->yy->loc->range = new ParserRange($this->offset, $this->offset += $this->yy->leng); - } - $this->more = false; - $this->input = substr($this->input, $matchCount, strlen($this->input)); - $ruleIndex = $rules[$index]; - $nextCondition = $this->conditionStack[$this->conditionStackCount - 1]; - - $token = $this->lexerPerformAction($ruleIndex, $nextCondition); - - if ($this->done == true && empty($this->input) == false) { - $this->done = false; - } - - if (empty($token) == false) { - return $this->symbols[ - $token - ]; - } else { - return null; - } - } - - if (empty($this->input)) { - return $this->eof; - } else { - $this->lexerError("Lexical error on line " . ($this->yy->lineNo + 1) . ". Unrecognized text.\n" . $this->showPosition(), new LexerError("", -1, $this->yy->lineNo)); - return null; - } - } - - function lexerLex() - { - $r = $this->next(); - - while (is_null($r) && !$this->done) { - $r = $this->next(); - } - - return $r; - } - - function begin($condition) - { - $this->conditionStackCount++; - $this->conditionStack[] = $condition; - } - - function popState() - { - $this->conditionStackCount--; - return array_pop($this->conditionStack); - } - - function currentRules() - { - $peek = $this->conditionStack[$this->conditionStackCount - 1]; - return $this->conditions[$peek]->rules; - } - - function LexerPerformAction($avoidingNameCollisions, $YY_START = null) - { - //@@LexerPerformActionInjection@@ - } -} - -class ParserLocation -{ - public $firstLine = 1; - public $lastLine = 0; - public $firstColumn = 1; - public $lastColumn = 0; - public $range; - - public function __construct($firstLine = 1, $lastLine = 0, $firstColumn = 1, $lastColumn = 0) - { - $this->firstLine = $firstLine; - $this->lastLine = $lastLine; - $this->firstColumn = $firstColumn; - $this->lastColumn = $lastColumn; - } - - public function Range($range) - { - $this->range = $range; - } - - public function __clone() - { - return new ParserLocation($this->firstLine, $this->lastLine, $this->firstColumn, $this->lastColumn); - } -} - -class ParserValue -{ - public $leng = 0; - public $loc; - public $lineNo = 0; - public $text; - - function __clone() { - $clone = new ParserValue(); - $clone->leng = $this->leng; - if (isset($this->loc)) { - $clone->loc = clone $this->loc; - } - $clone->lineNo = $this->lineNo; - $clone->text = $this->text; - return $clone; - } -} - -class LexerConditions -{ - public $rules; - public $inclusive; - - function __construct($rules, $inclusive) - { - $this->rules = $rules; - $this->inclusive = $inclusive; - } -} - -class ParserProduction -{ - public $len = 0; - public $symbol; - - public function __construct($symbol, $len = 0) - { - $this->symbol = $symbol; - $this->len = $len; - } -} - -class ParserCachedAction -{ - public $action; - public $symbol; - - function __construct($action, $symbol = null) - { - $this->action = $action; - $this->symbol = $symbol; - } -} - -class ParserAction -{ - public $action; - public $state; - public $symbol; - - function __construct($action, &$state = null, &$symbol = null) - { - $this->action = $action; - $this->state = $state; - $this->symbol = $symbol; - } -} - -class ParserSymbol -{ - public $name; - public $index = -1; - public $symbols = array(); - public $symbolsByName = array(); - - function __construct($name, $index) - { - $this->name = $name; - $this->index = $index; - } - - public function addAction($a) - { - $this->symbols[$a->index] = $this->symbolsByName[$a->name] = $a; - } -} - -class ParserError -{ - public $text; - public $state; - public $symbol; - public $lineNo; - public $loc; - public $expected; - - function __construct($text, $state, $symbol, $lineNo, $loc, $expected) - { - $this->text = $text; - $this->state = $state; - $this->symbol = $symbol; - $this->lineNo = $lineNo; - $this->loc = $loc; - $this->expected = $expected; - } -} - -class LexerError -{ - public $text; - public $token; - public $lineNo; - - public function __construct($text, $token, $lineNo) - { - $this->text = $text; - $this->token = $token; - $this->lineNo = $lineNo; - } -} - -class ParserState -{ - public $index; - public $actions = array(); - - function __construct($index) - { - $this->index = $index; - } - - public function setActions(&$actions) - { - $this->actions = $actions; - } -} - -class ParserRange -{ - public $x; - public $y; - - function __construct($x, $y) - { - $this->x = $x; - $this->y = $y; - } -} diff --git a/tests/all-tests.js b/tests/all-tests.js deleted file mode 100755 index 15eb433b3..000000000 --- a/tests/all-tests.js +++ /dev/null @@ -1,4 +0,0 @@ -exports.testParser = require("./parser/parser-tests"); - -if (require.main === module) - require("test").run(exports); diff --git a/tests/parser/actions.js b/tests/parser/actions.js deleted file mode 100644 index 586d08fdc..000000000 --- a/tests/parser/actions.js +++ /dev/null @@ -1,528 +0,0 @@ -var Jison = require("../setup").Jison, - RegExpLexer = require("../setup").RegExpLexer, - assert = require("assert"); - -exports["test Semantic action basic return"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "E" :[ ["E x", "return 0"], - ["E y", "return 1"], - "" ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('x'), 0, "semantic action"); - assert.equal(parser.parse('y'), 1, "semantic action"); -}; - -exports["test return null"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - bnf: { - "E" :[ ["E x", "return null;"], - "" ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('x'), null, "semantic action"); -}; - -exports["test terminal semantic values are not null"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "E" :[ ["E x", "return [$2 === 'x']"], - ["E y", "return [$2]"], - "" ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.deepEqual(parser.parse('x'), [true], "semantic action"); - assert.deepEqual(parser.parse('y'), ['y'], "semantic action"); -}; - -exports["test Semantic action stack lookup"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "pgm" :[ ["E", "return $1"] ], - "E" :[ ["B E", "return $1+$2"], - ["x", "$$ = 'EX'"] ], - "B" :[ ["y", "$$ = 'BY'"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('x'), "EX", "return first token"); - assert.equal(parser.parse('yx'), "BYEX", "return first after reduction"); -}; - -exports["test Semantic actions on nullable grammar"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - bnf: { - "S" :[ ["A", "return $1"] ], - "A" :[ ['x A', "$$ = $2+'x'" ], - ['', "$$ = '->'" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('xx'), "->xx", "return first after reduction"); -}; - -exports["test named semantic value"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - bnf: { - "S" :[ ["A", "return $A"] ], - "A" :[ ['x A', "$$ = $A+'x'" ], - ['', "$$ = '->'" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('xx'), "->xx", "return first after reduction"); -}; - -exports["test ambiguous named semantic value"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - operators: [["left", "y"]], - bnf: { - "S" :[ ["A", "return $A"] ], - "A" :[ ['A y A', "$$ = $A2+'y'+$A1" ], - ['x', "$$ = 'x'" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('xyx'), "xyx", "return first after reduction"); -}; - -exports["test vars that look like named semantic values shouldn't be replaced"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - bnf: { - "S" :[ ["A", "return $A"] ], - "A" :[ ['x A', "var $blah = 'x', blah = 8; $$ = $A + $blah" ], - ['', "$$ = '->'" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('xx'), "->xx", "return first after reduction"); -}; - -exports["test previous semantic value lookup ($0)"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "S" :[ ["A B", "return $A + $B"] ], - "A" :[ ['A x', "$$ = $A+'x'"], ['x', "$$ = $1"] ], - "B" :[ ["y", "$$ = $0"] ], - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('xxy'), "xxxx", "return first after reduction"); -}; - - -exports["test negative semantic value lookup ($-1)"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"], - ["z", "return 'z';"] - ] - }; - var grammar = { - bnf: { - "S" :[ ["G A B", "return $G + $A + $B"] ], - "G" :[ ['z', "$$ = $1"] ], - "A" :[ ['A x', "$$ = $A+'x'"], ['x', "$$ = $1"] ], - "B" :[ ["y", "$$ = $-1"] ], - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('zxy'), "zxz", "return first after reduction"); -}; - -exports["test Build AST"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - bnf: { - "S" :[ ['A', "return $1;" ] ], - "A" :[ ['x A', "$2.push(['ID',{value:'x'}]); $$ = $2;"], - ['', "$$ = ['A',{}];"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - var expectedAST = ['A',{}, - ['ID',{value:'x'}], - ['ID',{value:'x'}], - ['ID',{value:'x'}]]; - - var r = parser.parse("xxx"); - assert.deepEqual(r, expectedAST); -}; - -exports["test 0+0 grammar"] = function() { - var lexData2 = { - rules: [ - ["0", "return 'ZERO';"], - ["\\+", "return 'PLUS';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - bnf: { - "S" :[ [ "E EOF", "return $1" ]], - "E" :[ [ "E PLUS T", "$$ = ['+',$1,$3]" ], - [ "T", "$$ = $1" ] ], - "T" :[ [ "ZERO", "$$ = [0]" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData2); - - var expectedAST = ["+", ["+", [0], [0]], [0]]; - - assert.deepEqual(parser.parse("0+0+0"), expectedAST); -}; - -exports["test implicit $$ = $1 action"] = function() { - var lexData2 = { - rules: [ - ["0", "return 'ZERO';"], - ["\\+", "return 'PLUS';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - bnf: { - "S" :[ [ "E EOF", "return $1" ]], - "E" :[ [ "E PLUS T", "$$ = ['+',$1,$3]" ], - "T" ], - "T" :[ [ "ZERO", "$$ = [0]" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData2); - - var expectedAST = ["+", ["+", [0], [0]], [0]]; - - assert.deepEqual(parser.parse("0+0+0"), expectedAST); -}; - -exports["test yytext"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - bnf: { - "pgm" :[ ["Xexpr", "return $1;"] ], - "Xexpr" :[ ["x", "$$ = yytext;"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('x'), "x", "return first token"); -}; - -exports["test yyleng"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - bnf: { - "pgm" :[ ["Xexpr", "return $1;"] ], - "Xexpr" :[ ["x", "$$ = yyleng;"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('x'), 1, "return first token"); -}; - -exports["test yytext more"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "pgm" :[ ["expr expr", "return $1+$2;"] ], - "expr" :[ ["x", "$$ = yytext;"], - ["y", "$$ = yytext;"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('xy'), "xy", "return first token"); -}; - -exports["test action include"] = function() { - var lexData = { - rules: [ - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "E" :[ ["E y", "return test();"], - "" ] - }, - actionInclude: function () { - function test(val) { - return 1; - } - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('y'), 1, "semantic action"); -}; - -exports["test next token not shifted if only one action"] = function () { - var lexData = { - rules: [ - ["\\(", "return '(';"], - ["\\)", "return ')';"], - ["y", "return yy.xed ? 'yfoo' : 'ybar';"] - ] - }; - var grammar = { - bnf: { - "prog" :[ 'e ybar' ], - "esub" :[[ '(', "yy.xed = true;" ]], - "e" :[[ 'esub yfoo )', "yy.xed = false;" ]] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - assert.ok(parser.parse('(y)y'), "should parse correctly"); -}; - -exports["test token array LIFO"] = function() { - var lexData = { - rules: [ - ["a", "return ['b','a'];"], - ["c", "return 'c';"] - ] - }; - var grammar = { - ebnf: { - "pgm" :[ ["expr expr expr", "return $1+$2+$3;"] ], - "expr" :[ ["a", "$$ = 'a';"], - ["b", "$$ = 'b';"], - ["c", "$$ = 'c';"] ] - }, - options: { 'token-stack': true } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - assert.equal(parser.parse('ac'), "abc", "should return second token"); -}; - -exports["test YYACCEPT"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "pgm" :[ ["E", "return $1"] ], - "E" :[ ["B E", "return $1+$2"], - ["x", "$$ = 'EX'"] ], - "B" :[ ["y", "YYACCEPT"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('x'), "EX", "return first token"); - assert.equal(parser.parse('yx'), true, "return first after reduction"); -}; - -exports["test YYABORT"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "pgm" :[ ["E", "return $1"] ], - "E" :[ ["B E", "return $1+$2"], - ["x", "$$ = 'EX'"] ], - "B" :[ ["y", "YYABORT"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('x'), "EX", "return first token"); - assert.equal(parser.parse('yx'), false, "return first after reduction"); -}; - -exports["test parse params"] = function() { - var lexData = { - rules: [ - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "E" :[ ["E y", "return first + second;"], - "" ] - }, - parseParams: ["first", "second"] - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - assert.equal(parser.parse('y', "foo", "bar"), "foobar", "semantic action"); -}; - -exports["test symbol aliases"] = function() { - var lexData = { - rules: [ - ["a", "return 'a';"], - ["b", "return 'b';"], - ["c", "return 'c';"] - ] - }; - var grammar = { - bnf: { - "pgm" :[ ["expr[alice] expr[bob] expr[carol]", "return $alice+$bob+$carol;"] ], - "expr" :[ ["a", "$$ = 'a';"], - ["b", "$$ = 'b';"], - ["c", "$$ = 'c';"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - assert.equal(parser.parse('abc'), "abc", "should return original string"); -}; - -exports["test symbol aliases in ebnf"] = function() { - var lexData = { - rules: [ - ["a", "return 'a';"], - ["b", "return 'b';"], - ["c", "return 'c';"] - ] - }; - var grammar = { - ebnf: { - "pgm" :[ ["expr[alice] (expr[bob] expr[carol])+", "return $alice+$2;"] ], - "expr" :[ ["a", "$$ = 'a';"], - ["b", "$$ = 'b';"], - ["c", "$$ = 'c';"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - assert.equal(parser.parse('abc'), "ab", "should tolerate aliases in subexpression"); -}; diff --git a/tests/parser/api.js b/tests/parser/api.js deleted file mode 100644 index 4ea90700a..000000000 --- a/tests/parser/api.js +++ /dev/null @@ -1,447 +0,0 @@ -var Jison = require("../setup").Jison, - Lexer = require("../setup").Lexer, - assert = require("assert"); - -var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] -}; - -exports["test tokens as a string"] = function () { - - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new Lexer(lexData); - assert.ok(parser.parse('xyx'), "parse xyx"); -}; - -exports["test generator"] = function () { - - var grammar = { - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new Lexer(lexData); - assert.ok(parser.parse('xyx'), "parse xyx"); -}; - -exports["test extra spaces in productions"] = function () { - - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x ', - 'A y', - '' ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new Lexer(lexData); - assert.ok(parser.parse('xyx'), "parse xyx"); -}; - -exports["test | seperated rules"] = function () { - - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :"A x | A y | " - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new Lexer(lexData); - assert.ok(parser.parse('xyx'), "parse xyx"); -}; - -exports["test start symbol optional"] = function () { - - var grammar = { - tokens: "x y", - bnf: { - "A" :"A x | A y | " - } - }; - - var parser = new Jison.Parser(grammar); - var ok = true; - assert.ok(ok, "no error"); -}; - -exports["test start symbol should be nonterminal"] = function () { - - var grammar = { - tokens: "x y", - startSymbol: "x", - bnf: { - "A" :"A x | A y | " - } - }; - - assert.throws(function(){new Jison.Generator(grammar);}, "throws error"); -}; - -exports["test token list as string"] = function () { - - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :"A x | A y | " - } - }; - - var gen = new Jison.Generator(grammar); - assert.ok(gen.terminals.indexOf('x') >= 0); -}; - -exports["test grammar options"] = function () { - - var grammar = { - options: {type: "slr"}, - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var gen = new Jison.Generator(grammar); - assert.ok(gen); -}; - -exports["test overwrite grammar options"] = function () { - - var grammar = { - options: {type: "slr"}, - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "lr0"}); - assert.equal(gen.constructor, Jison.LR0Generator); -}; - -exports["test yy shared scope"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return yy.xed ? 'yfoo' : 'ybar';"] - ] - }; - var grammar = { - tokens: "x yfoo ybar", - startSymbol: "A", - bnf: { - "A" :[[ 'A x', "yy.xed = true;" ], - [ 'A yfoo', " return 'foo';" ], - [ 'A ybar', " return 'bar';" ], - '' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr0"}); - parser.lexer = new Lexer(lexData); - assert.equal(parser.parse('y'), "bar", "should return bar"); - assert.equal(parser.parse('xxy'), "foo", "should return foo"); -}; - - -exports["test optional token declaration"] = function () { - - var grammar = { - options: {type: "slr"}, - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "lr0"}); - assert.equal(gen.constructor, Jison.LR0Generator); -}; - - -exports["test custom parse error method"] = function () { - var lexData = { - rules: [ - ["a", "return 'a';"], - ["b", "return 'b';"], - ["c", "return 'c';"], - ["d", "return 'd';"], - ["g", "return 'g';"] - ] - }; - var grammar = { - "tokens": "a b c d g", - "startSymbol": "S", - "bnf": { - "S" :[ "a g d", - "a A c", - "b A d", - "b g c" ], - "A" :[ "B" ], - "B" :[ "g" ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lalr"}); - parser.lexer = new Lexer(lexData); - var result={}; - parser.yy.parseError = function (str, hash) { - result = hash; - throw str; - }; - - assert.throws(function () {parser.parse("aga")}); - assert.strictEqual(result.text, "a", "parse error text should equal b"); - assert.strictEqual(typeof result.token, 'string', "parse error token should be a string"); - assert.strictEqual(result.line, 0, "hash should include line number"); -}; - -exports["test jison grammar as string"] = function () { - - var grammar = "%% A : A x | A y | ;" - - var parser = new Jison.Generator(grammar).createParser(); - parser.lexer = new Lexer(lexData); - assert.ok(parser.parse('xyx'), "parse xyx"); -}; - -exports["test no default resolve"] = function () { - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - '' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "lr0", noDefaultResolve: true}); - var parser = gen.createParser(); - parser.lexer = new Lexer(lexData); - - assert.ok(gen.table.length == 4, "table has 4 states"); - assert.ok(gen.conflicts == 2, "encountered 2 conflicts"); - assert.throws(function () {parser.parse("xx")}, "throws parse error for multiple actions"); -}; - - -exports["test EOF in 'Unexpected token' error message"] = function () { - - var grammar = { - bnf: { - "A" :[ 'x x y' ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new Lexer(lexData); - parser.lexer.showPosition = null; // needed for "Unexpected" message - parser.yy.parseError = function (str, hash) { - assert.ok(str.match("end of input")); - }; - - assert.throws(function () {parser.parse("xx"); }); - -}; - -exports["test locations"] = function () { - var grammar = { - tokens: [ 'x', 'y' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - ['y', 'return @1'], - '' ] - } - }; - - var lexData = { - rules: [ - ["\\s", "/*ignore*/"], - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var gen = new Jison.Generator(grammar); - var parser = gen.createParser(); - parser.lexer = new Lexer(lexData); - var loc = parser.parse('xx\nxy'); - - assert.equal(loc.first_line, 2, 'first line correct'); - assert.equal(loc.last_line, 2, 'last line correct'); - assert.equal(loc.first_column, 1, 'first column correct'); - assert.equal(loc.last_column, 2, 'last column correct'); -}; - -exports["test default location action"] = function () { - var grammar = { - tokens: [ 'x', 'y' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - ['y', 'return @$'], - '' ] - } - }; - - var lexData = { - rules: [ - ["\\s", "/*ignore*/"], - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var gen = new Jison.Generator(grammar); - var parser = gen.createParser(); - parser.lexer = new Lexer(lexData); - var loc = parser.parse('xx\nxy'); - - assert.equal(loc.first_line, 2, 'first line correct'); - assert.equal(loc.last_line, 2, 'last line correct'); - assert.equal(loc.first_column, 1, 'first column correct'); - assert.equal(loc.last_column, 2, 'last column correct'); -}; - -exports["test locations by term name in action"] = function () { - var grammar = { - tokens: [ 'x', 'y' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - ['B', 'return @B'], - '' ], - "B" :[ 'y' ] - } - }; - - var lexData = { - rules: [ - ["\\s", "/*ignore*/"], - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var gen = new Jison.Generator(grammar); - var parser = gen.createParser(); - parser.lexer = new Lexer(lexData); - var loc = parser.parse('xx\nxy'); - - assert.equal(loc.first_line, 2, 'first line correct'); - assert.equal(loc.last_line, 2, 'last line correct'); - assert.equal(loc.first_column, 1, 'first column correct'); - assert.equal(loc.last_column, 2, 'last column correct'); -}; - -exports["test lexer with no location support"] = function () { - var grammar = { - tokens: [ 'x', 'y' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - ['B', 'return @B'], - '' ], - "B" :[ 'y' ] - } - }; - - var gen = new Jison.Generator(grammar); - var parser = gen.createParser(); - parser.lexer = { - toks: ['x','x','x','y'], - lex: function () { - return this.toks.shift(); - }, - setInput: function (){} - }; - var loc = parser.parse('xx\nxy'); -}; - -exports["test intance creation"] = function () { - var grammar = { - tokens: [ 'x', 'y' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - ['B', 'return @B'], - '' ], - "B" :[ 'y' ] - } - }; - - var gen = new Jison.Generator(grammar); - var parser = gen.createParser(); - parser.lexer = { - toks: ['x','x','x','y'], - lex: function () { - return this.toks.shift(); - }, - setInput: function (){} - }; - var parser2 = new parser.Parser(); - parser2.lexer = parser.lexer; - parser2.parse('xx\nxy'); - - parser.blah = true; - - assert.notEqual(parser.blah, parser2.blah, "should not inherit"); -}; - -exports["test reentrant parsing"] = function () { - var grammar = { - bnf: { - "S" :['A EOF'], - "A" :['x A', - 'B', - 'C' - ], - "B" :[['y', 'return "foo";']], - "C" :[['w', 'return yy.parser.parse("xxxy") + "bar";']] - } - }; - - var lexData = { - rules: [ - ["\\s", "/*ignore*/"], - ["w", "return 'w';"], - ["x", "return 'x';"], - ["y", "return 'y';"], - ["$", "return 'EOF';"] - ] - }; - var gen = new Jison.Generator(grammar); - var parser = gen.createParser(); - parser.lexer = new Lexer(lexData); - var result = parser.parse('xxw'); - assert.equal(result, "foobar"); -}; - diff --git a/tests/parser/errorlab.js b/tests/parser/errorlab.js deleted file mode 100644 index de09d19ba..000000000 --- a/tests/parser/errorlab.js +++ /dev/null @@ -1,205 +0,0 @@ -var Jison = require("../setup").Jison, - Lexer = require("../setup").Lexer, - assert = require("assert"); - -exports["test error caught"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"], - [".", "return 'ERR';"] - ] - }; - var grammar = { - bnf: { - "A" :['A x', - 'A y', - [ 'A error', "return 'caught';" ], - '' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr0"}); - parser.lexer = new Lexer(lexData); - assert.ok(parser.parse('xxy'), "should parse"); - assert.equal(parser.parse('xyg'), "caught", "should return 'caught'"); -}; - -exports["test error recovery"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"], - [".", "return 'ERR';"] - ] - }; - var grammar = { - bnf: { - "A" :['A x', - ['A y', "return 'recovery'"], - 'A error', - '' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr0"}); - parser.lexer = new Lexer(lexData); - assert.equal(parser.parse('xxgy'), "recovery", "should return foo"); -}; - -exports["test deep error recovery"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"], - ["g", "return 'g';"], - [";", "return ';';"], - [".", "return 'ERR';"] - ] - }; - var grammar = { - bnf: { - "S" :['g A ;', - ['g error ;', 'return "nested"'] - ], - "A" :['A x', - 'x' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr0"}); - parser.lexer = new Lexer(lexData); - assert.ok(parser.parse('gxxx;'), "should parse"); - assert.equal(parser.parse('gxxg;'), "nested", "should return nested"); -}; - -exports["test no recovery"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"], - [".", "return 'ERR';"] - ] - }; - var grammar = { - bnf: { - "A" :['A x', - ['A y', "return 'recovery'"], - '' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr0"}); - parser.lexer = new Lexer(lexData); - assert.throws(function (){parser.parse('xxgy')}, "should throw"); -}; - -exports["test error after error recovery"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"], - ["g", "return 'g';"], - [".", "return 'ERR';"] - ] - }; - var grammar = { - bnf: { - "S" :['g A y', - ['g error y', 'return "nested"'] - ], - "A" :['A x', - 'x' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr0"}); - parser.lexer = new Lexer(lexData); - assert.throws(function (){parser.parse('gxxx;')}, "should return bar"); -}; - -exports["test throws error despite recovery rule"] = function() { - var lexData2 = { - rules: [ - ["0", "return 'ZERO';"], - ["\\+", "return 'PLUS';"], - [";", "return ';';"], - [".", "return 'INVALID'"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - bnf: { - "S" :[ [ "Exp EOF", "return $1" ]], - "Exp" :[ [ "E ;", "$$ = $1;" ], - [ "E error", "$$ = $1;" ]], - "E" :[ [ "E PLUS T", "$$ = ['+',$1,$3]" ], - [ "T", "$$ = $1" ] ], - "T" :[ [ "ZERO", "$$ = [0]" ] ] - } - }; - - var parser = new Jison.Parser(grammar, {debug: true}); - parser.lexer = new Lexer(lexData2); - - var expectedAST = ["+", ["+", [0], [0]], [0]]; - - assert.throws(function (){(parser.parse("0+0+0>"), expectedAST);}); -}; - -exports["test correct AST after error recovery abrupt end"] = function() { - var lexData2 = { - rules: [ - ["0", "return 'ZERO';"], - ["\\+", "return 'PLUS';"], - [";", "return ';';"], - ["$", "return 'EOF';"], - [".", "return 'INVALID';"] - ] - }; - var grammar = { - bnf: { - "S" :[ [ "Exp EOF", "return $1" ]], - "Exp" :[ [ "E ;", "$$ = $1;" ], - [ "E error", "$$ = $1;" ]], - "E" :[ [ "E PLUS T", "$$ = ['+',$1,$3]" ], - [ "T", "$$ = $1" ] ], - "T" :[ [ "ZERO", "$$ = [0]" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new Lexer(lexData2); - - var expectedAST = ["+", ["+", [0], [0]], [0]]; - - assert.deepEqual(parser.parse("0+0+0"), expectedAST); -}; - - -exports["test bison error recovery example"] = function() { - var lexData2 = { - rules: [ - ["0", "return 'ZERO';"], - ["\\+", "return 'PLUS';"], - [";", "return ';';"], - ["$", "return 'EOF';"], - [".", "return 'INVALID';"] - ] - }; - var grammar = { - bnf: { - "S" :[ [ "stmt stmt EOF", "return $1" ]], - "stmt" :[ [ "E ;", "$$ = $1;" ], - [ "error ;", "$$ = $1;" ]], - "E" :[ [ "E PLUS T", "$$ = ['+',$1,$3]" ], - [ "T", "$$ = $1" ] ], - "T" :[ [ "ZERO", "$$ = [0]" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new Lexer(lexData2); - - assert.ok(parser.parse("0+0++++>;0;"), "should recover"); -}; diff --git a/tests/parser/generator.js b/tests/parser/generator.js deleted file mode 100644 index 2ef535dd9..000000000 --- a/tests/parser/generator.js +++ /dev/null @@ -1,381 +0,0 @@ -var Jison = require("../setup").Jison, - Lexer = require("../setup").Lexer, - assert = require("assert"); - -var fs = require('fs'); -var path = require('path'); - -exports["test amd module generator"] = function() { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var input = "xyxxxy"; - var gen = new Jison.Generator(grammar); - gen.lexer = new Lexer(lexData); - - var parserSource = gen.generateAMDModule(); - var parser = null, - define = function(callback){ - // temporary AMD-style define function, for testing. - parser = callback(); - }; - eval(parserSource); - - assert.ok(parser.parse(input)); -}; - -exports["test commonjs module generator"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var input = "xyxxxy"; - var gen = new Jison.Generator(grammar); - gen.lexer = new Lexer(lexData); - - var parserSource = gen.generateCommonJSModule(); - var exports = {}; - eval(parserSource); - - assert.ok(exports.parse(input)); -}; - -exports["test module generator"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var input = "xyxxxy"; - var gen = new Jison.Generator(grammar); - gen.lexer = new Lexer(lexData); - - var parserSource = gen.generateModule(); - eval(parserSource); - - assert.ok(parser.parse(input)); -}; - -exports["test module generator with module name"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var input = "xyxxxy"; - var gen = new Jison.Generator(grammar); - gen.lexer = new Lexer(lexData); - - var parserSource = gen.generate({moduleType: "js", moduleName: "parsey"}); - eval(parserSource); - - assert.ok(parsey.parse(input)); -}; - -exports["test module generator with namespaced module name"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - tokens: "x y", - startSymbol: "A", - bnf: { - "A" :[ 'A x', - 'A y', - '' ] - } - }; - - var compiler = {}; - - var input = "xyxxxy"; - var gen = new Jison.Generator(grammar); - gen.lexer = new Lexer(lexData); - - var parserSource = gen.generateModule({moduleName: "compiler.parser"}); - eval(parserSource); - - assert.ok(compiler.parser.parse(input)); -}; - -exports["test module include"] = function () { - var grammar = { - "comment": "ECMA-262 5th Edition, 15.12.1 The JSON Grammar. (Incomplete implementation)", - "author": "Zach Carter", - - "lex": { - "macros": { - "digit": "[0-9]", - "exp": "([eE][-+]?{digit}+)" - }, - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["-?{digit}+(\\.{digit}+)?{exp}?", "return 'NUMBER';"], - ["\"[^\"]*", function(){ - if(yytext.charAt(yyleng-1) == '\\') { - // remove escape - yytext = yytext.substr(0,yyleng-2); - this.more(); - } else { - yytext = yytext.substr(1); // swallow start quote - this.input(); // swallow end quote - return "STRING"; - } - }], - ["\\{", "return '{'"], - ["\\}", "return '}'"], - ["\\[", "return '['"], - ["\\]", "return ']'"], - [",", "return ','"], - [":", "return ':'"], - ["true\\b", "return 'TRUE'"], - ["false\\b", "return 'FALSE'"], - ["null\\b", "return 'NULL'"] - ] - }, - - "tokens": "STRING NUMBER { } [ ] , : TRUE FALSE NULL", - "start": "JSONText", - - "bnf": { - "JSONString": [ "STRING" ], - - "JSONNumber": [ "NUMBER" ], - - "JSONBooleanLiteral": [ "TRUE", "FALSE" ], - - - "JSONText": [ "JSONValue" ], - - "JSONValue": [ "JSONNullLiteral", - "JSONBooleanLiteral", - "JSONString", - "JSONNumber", - "JSONObject", - "JSONArray" ], - - "JSONObject": [ "{ }", - "{ JSONMemberList }" ], - - "JSONMember": [ "JSONString : JSONValue" ], - - "JSONMemberList": [ "JSONMember", - "JSONMemberList , JSONMember" ], - - "JSONArray": [ "[ ]", - "[ JSONElementList ]" ], - - "JSONElementList": [ "JSONValue", - "JSONElementList , JSONValue" ] - } -}; - - var gen = new Jison.Generator(grammar); - - var parserSource = gen.generateModule(); - eval(parserSource); - - assert.ok(parser.parse(JSON.stringify(grammar.bnf))); -}; - -exports["test module include code"] = function () { - var lexData = { - rules: [ - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "E" :[ ["E y", "return test();"], - "" ] - }, - moduleInclude: "function test(val) { return 1; }" - }; - - var gen = new Jison.Generator(grammar); - gen.lexer = new Lexer(lexData); - - var parserSource = gen.generateCommonJSModule(); - var exports = {}; - eval(parserSource); - - assert.equal(parser.parse('y'), 1, "semantic action"); -}; - -exports["test lexer module include code"] = function () { - var lexData = { - rules: [ - ["y", "return test();"] - ], - moduleInclude: "function test() { return 1; }" - }; - var grammar = { - bnf: { - "E" :[ ["E y", "return $2;"], - "" ] - } - }; - - var gen = new Jison.Generator(grammar); - gen.lexer = new Lexer(lexData); - - var parserSource = gen.generateCommonJSModule(); - var exports = {}; - eval(parserSource); - - assert.equal(parser.parse('y'), 1, "semantic action"); -}; - -exports["test generated parser instance creation"] = function () { - var grammar = { - lex: { - rules: [ - ["y", "return 'y'"] - ] - }, - bnf: { - "E" :[ ["E y", "return $2;"], - "" ] - } - }; - - var gen = new Jison.Generator(grammar); - - var parserSource = gen.generateModule(); - eval(parserSource); - - var p = new parser.Parser; - - assert.equal(p.parse('y'), 'y', "semantic action"); - - parser.blah = true; - - assert.notEqual(parser.blah, p.blah, "shouldn't inherit props"); -}; - -exports["test module include code using generator from parser"] = function () { - var lexData = { - rules: [ - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "E" :[ ["E y", "return test();"], - "" ] - }, - moduleInclude: "function test(val) { return 1; }" - }; - - var gen = new Jison.Parser(grammar); - gen.lexer = new Lexer(lexData); - - var parserSource = gen.generateCommonJSModule(); - var exports = {}; - eval(parserSource); - - assert.equal(parser.parse('y'), 1, "semantic action"); -}; - -exports["test module include with each generator type"] = function () { - var lexData = { - rules: [ - ["y", "return 'y';"] - ] - }; - var grammar = { - bnf: { - "E" :[ ["E y", "return test();"], - "" ] - }, - moduleInclude: "var TEST_VAR;" - }; - - var gen = new Jison.Parser(grammar); - gen.lexer = new Lexer(lexData); - ['generateModule', 'generateAMDModule', 'generateCommonJSModule'] - .map(function(type) { - var source = gen[type](); - assert.ok(/TEST_VAR/.test(source), type + " supports module include"); - }); -}; - -// test for issue #246 -exports["test compiling a parser/lexer"] = function () { - var grammar = - '// Simple "happy happy joy joy" parser, written by Nolan Lawson\n' + - '// Based on the song of the same name.\n\n' + - '%lex\n%%\n\n\\s+ /* skip whitespace */\n' + - '("happy") return \'happy\'\n' + - '("joy") return \'joy\'\n' + - '<> return \'EOF\'\n\n' + - '/lex\n\n%start expressions\n\n' + - '%ebnf\n\n%%\n\n' + - 'expressions\n : e EOF\n {return $1;}\n ;\n\n' + - 'e\n : phrase+ \'joy\'? -> $1 + \' \' + yytext \n ;\n\n' + - 'phrase\n : \'happy\' \'happy\' \'joy\' \'joy\' ' + - ' -> [$1, $2, $3, $4].join(\' \'); \n ;'; - - var parser = new Jison.Parser(grammar); - var generated = parser.generate(); - - var tmpFile = path.resolve(__dirname, 'tmp-parser.js'); - fs.writeFileSync(tmpFile, generated); - var parser2 = require('./tmp-parser'); - - assert.ok(parser.parse('happy happy joy joy joy') === 'happy happy joy joy joy', - 'original parser works'); - assert.ok(parser2.parse('happy happy joy joy joy') === 'happy happy joy joy joy', - 'generated parser works'); - fs.unlinkSync(tmpFile); -}; diff --git a/tests/parser/lalr.js b/tests/parser/lalr.js deleted file mode 100644 index 57e692322..000000000 --- a/tests/parser/lalr.js +++ /dev/null @@ -1,183 +0,0 @@ -var Jison = require("../setup").Jison, - Lexer = require("../setup").Lexer, - assert = require("assert"); - -exports["test 0+0 grammar"] = function () { - var lexData2 = { - rules: [ - ["0", "return 'ZERO';"], - ["\\+", "return 'PLUS';"] - ] - }; - var grammar = { - tokens: [ "ZERO", "PLUS"], - startSymbol: "E", - bnf: { - "E" :[ "E PLUS T", - "T" ], - "T" :[ "ZERO" ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lalr"}); - parser.lexer = new Lexer(lexData2); - - assert.ok(parser.parse("0+0+0"), "parse"); - assert.ok(parser.parse("0"), "parse single 0"); - - assert.throws(function () {parser.parse("+")}, "throws parse error on invalid"); -}; - -exports["test xx nullable grammar"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'A x', - '' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lalr"}); - parser.lexer = new Lexer(lexData); - - assert.ok(parser.parse("xxx"), "parse"); - assert.ok(parser.parse("x"), "parse single x"); - assert.throws(function (){parser.parse("+");}, "throws parse error on invalid"); -}; - -exports["test LALR algorithm from Bermudez, Logothetis"] = function () { - var lexData = { - rules: [ - ["a", "return 'a';"], - ["b", "return 'b';"], - ["c", "return 'c';"], - ["d", "return 'd';"], - ["g", "return 'g';"] - ] - }; - var grammar = { - "tokens": "a b c d g", - "startSymbol": "S", - "bnf": { - "S" :[ "a g d", - "a A c", - "b A d", - "b g c" ], - "A" :[ "B" ], - "B" :[ "g" ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lalr"}); - parser.lexer = new Lexer(lexData); - assert.ok(parser.parse("agd")); - assert.ok(parser.parse("agc")); - assert.ok(parser.parse("bgd")); - assert.ok(parser.parse("bgc")); -}; - -exports["test basic JSON grammar"] = function () { - var grammar = { - "lex": { - "macros": { - "digit": "[0-9]", - "esc": "\\\\", - "int": "-?(?:[0-9]|[1-9][0-9]+)", - "exp": "(?:[eE][-+]?[0-9]+)", - "frac": "(?:\\.[0-9]+)" - }, - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["{int}{frac}?{exp}?\\b", "return 'NUMBER';"], - ["\"(?:{esc}[\"bfnrt/{esc}]|{esc}u[a-fA-F0-9]{4}|[^\"{esc}])*\"", "yytext = yytext.substr(1,yyleng-2); return 'STRING';"], - ["\\{", "return '{'"], - ["\\}", "return '}'"], - ["\\[", "return '['"], - ["\\]", "return ']'"], - [",", "return ','"], - [":", "return ':'"], - ["true\\b", "return 'TRUE'"], - ["false\\b", "return 'FALSE'"], - ["null\\b", "return 'NULL'"] - ] - }, - - "tokens": "STRING NUMBER { } [ ] , : TRUE FALSE NULL", - "bnf": { - "JsonThing": [ "JsonObject", - "JsonArray" ], - - "JsonObject": [ "{ JsonPropertyList }" ], - - "JsonPropertyList": [ "JsonProperty", - "JsonPropertyList , JsonProperty" ], - - "JsonProperty": [ "StringLiteral : JsonValue" ], - - "JsonArray": [ "[ JsonValueList ]" ], - - "JsonValueList": [ "JsonValue", - "JsonValueList , JsonValue" ], - - "JsonValue": [ "StringLiteral", - "NumericalLiteral", - "JsonObject", - "JsonArray", - "TRUE", - "FALSE", - "NULL" ], - - "StringLiteral": [ "STRING" ], - - "NumericalLiteral": [ "NUMBER" ] - }, - }; - - var source = '{"foo": "Bar", "hi": 42, "array": [1,2,3.004, -4.04e-4], "false": false, "true":true, "null": null, "obj": {"ha":"ho"}, "string": "str\\ting\\"sgfg" }'; - - var gen = new Jison.Generator(grammar, {type: "lalr"}); - var parser = gen.createParser(); - var gen2 = new Jison.Generator(grammar, {type: "slr"}); - var parser2 = gen2.createParser(); - assert.deepEqual(gen.table, gen2.table, "SLR(1) and LALR(1) tables should be equal"); - assert.ok(parser.parse(source)); -}; - -exports["test LR(1) grammar"] = function () { - var grammar = { - "comment": "Produces a reduce-reduce conflict unless using LR(1).", - "tokens": "z d b c a", - "start": "S", - "bnf": { - "S" :[ "a A c", - "a B d", - "b A d", - "b B c"], - "A" :[ "z" ], - "B" :[ "z" ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "lalr"}); - assert.equal(gen.conflicts, 2); -}; - -exports["test BNF grammar bootstrap"] = function () { - var grammar = "%%\n\nspec\n : declaration_list '%%' grammar EOF\n {$$ = $1; $$.bnf = $3; return $$;}\n | declaration_list '%%' grammar '%%' EOF\n {$$ = $1; $$.bnf = $3; return $$;}\n ;\n\ndeclaration_list\n : declaration_list declaration\n {$$ = $1; yy.addDeclaration($$, $2);}\n | \n %{$$ = {};%}\n ;\n\ndeclaration\n : START id\n %{$$ = {start: $2};%}\n | operator\n %{$$ = {operator: $1};%}\n ;\n\noperator\n : associativity token_list\n {$$ = [$1]; $$.push.apply($$, $2);}\n ;\n\nassociativity\n : LEFT\n {$$ = 'left';}\n | RIGHT\n {$$ = 'right';}\n | NONASSOC\n {$$ = 'nonassoc';}\n ;\n\ntoken_list\n : token_list symbol\n {$$ = $1; $$.push($2);}\n | symbol\n {$$ = [$1];}\n ;\n\ngrammar\n : production_list\n {$$ = $1;}\n ;\n\nproduction_list\n : production_list production\n {$$ = $1; $$[$2[0]] = $2[1];}\n | production\n %{$$ = {}; $$[$1[0]] = $1[1];%}\n ;\n\nproduction\n : id ':' handle_list ';'\n {$$ = [$1, $3];}\n ;\n\nhandle_list\n : handle_list '|' handle_action\n {$$ = $1; $$.push($3);}\n | handle_action\n {$$ = [$1];}\n ;\n\nhandle_action\n : handle action prec\n {$$ = [($1.length ? $1.join(' ') : '')];\n if($2) $$.push($2);\n if($3) $$.push($3);\n if ($$.length === 1) $$ = $$[0];\n }\n ;\n\nhandle\n : handle symbol\n {$$ = $1; $$.push($2)}\n | \n {$$ = [];}\n ;\n\nprec\n : PREC symbol\n %{$$ = {prec: $2};%}\n | \n {$$ = null;}\n ;\n\nsymbol\n : id\n {$$ = $1;}\n | STRING\n {$$ = yytext;}\n ;\n\nid\n : ID\n {$$ = yytext;}\n ;\n\naction\n : ACTION\n {$$ = yytext;}\n | \n {$$ = '';}\n ;\n\n"; - - var lex = "\n%%\n\\s+ \t{/* skip whitespace */}\n\"/*\"[^*]*\"*\" \t{return yy.lexComment(this);}\n[a-zA-Z][a-zA-Z0-9_-]* \t{return 'ID';}\n'\"'[^\"]+'\"' \t{yytext = yytext.substr(1, yyleng-2); return 'STRING';}\n\"'\"[^']+\"'\" \t{yytext = yytext.substr(1, yyleng-2); return 'STRING';}\n\":\" \t{return ':';}\n\";\" \t{return ';';}\n\"|\" \t{return '|';}\n\"%%\" \t{return '%%';}\n\"%prec\" \t{return 'PREC';}\n\"%start\" \t{return 'START';}\n\"%left\" \t{return 'LEFT';}\n\"%right\" \t{return 'RIGHT';}\n\"%nonassoc\" \t{return 'NONASSOC';}\n\"%\"[a-zA-Z]+[^\\n]* \t{/* ignore unrecognized decl */}\n\"{{\"[^}]*\"}\" \t{return yy.lexAction(this);}\n\"{\"[^}]*\"}\" \t{yytext = yytext.substr(1, yyleng-2); return 'ACTION';}\n\"%{\"(.|\\n)*?\"%}\" {yytext = yytext.substr(2, yytext.length-4);return 'ACTION';} \n. \t{/* ignore bad characters */}\n<> \t{return 'EOF';}\n\n%%\n\n"; - - - var gen = new Jison.Generator(grammar, {type: "lalr"}); - gen.lexer = new Lexer(lex); - - var parser = gen.createParser(); - - assert.ok(parser.parse(grammar), "bootstrapped bnf parser should parse correctly."); -}; diff --git a/tests/parser/lr0.js b/tests/parser/lr0.js deleted file mode 100644 index fb1c89dbb..000000000 --- a/tests/parser/lr0.js +++ /dev/null @@ -1,72 +0,0 @@ -var Jison = require("../setup").Jison, - Lexer = require("../setup").Lexer, - assert = require("assert"); - -var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] -}; - -exports["test left-recursive nullable grammar"] = function () { - - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'A x', - '' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr0"}); - parser.lexer = new Lexer(lexData); - - assert.ok(parser.parse('xxx'), "parse 3 x's"); - assert.ok(parser.parse("x"), "parse single x"); - assert.throws(function () {parser.parse("y")}, "throws parse error on invalid token"); -}; - -exports["test right-recursive nullable grammar"] = function () { - - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - '' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "lr0"}); - - assert.ok(gen.table.length == 4, "table has 4 states"); - assert.ok(gen.conflicts == 2, "encountered 2 conflicts"); -}; - -exports["test 0+0 grammar"] = function () { - var lexData2 = { - rules: [ - ["0", "return 'ZERO';"], - ["\\+", "return 'PLUS';"] - ] - }; - var grammar = { - tokens: [ "ZERO", "PLUS"], - startSymbol: "E", - bnf: { - "E" :[ "E PLUS T", - "T" ], - "T" :[ "ZERO" ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr0"}); - parser.lexer = new Lexer(lexData2); - - assert.ok(parser.parse("0+0+0"), "parse"); - assert.ok(parser.parse("0"), "parse single 0"); - - assert.throws(function () {parser.parse("+")}, "throws parse error on invalid"); -}; diff --git a/tests/parser/lr1.js b/tests/parser/lr1.js deleted file mode 100644 index 591a75c40..000000000 --- a/tests/parser/lr1.js +++ /dev/null @@ -1,176 +0,0 @@ -var Jison = require("../setup").Jison, - Lexer = require("../setup").Lexer, - assert = require("assert"); - -exports["test xx nullable grammar"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] - }; - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'A x', - '' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr"}); - parser.lexer = new Lexer(lexData); - - assert.ok(parser.parse("xxx"), "parse"); - assert.ok(parser.parse("x"), "parse single x"); - assert.throws(function (){parser.parse("+");}, "throws parse error on invalid"); -}; - -exports["test LR parse"] = function () { - var lexData2 = { - rules: [ - ["0", "return 'ZERO';"], - ["\\+", "return 'PLUS';"] - ] - }; - var grammar = { - tokens: [ "ZERO", "PLUS"], - startSymbol: "E", - bnf: { - "E" :[ "E PLUS T", - "T" ], - "T" :[ "ZERO" ] - } - }; - var parser = new Jison.Parser(grammar, {type: "lr"}); - parser.lexer = new Lexer(lexData2); - - assert.ok(parser.parse("0+0+0"), "parse"); -}; - -exports["test basic JSON grammar"] = function () { - var grammar = { - "lex": { - "macros": { - "digit": "[0-9]" - }, - "rules": [ - ["\\s+", "/* skip whitespace */"], - ["{digit}+(\\.{digit}+)?", "return 'NUMBER';"], - ["\"[^\"]*", function(){ - if(yytext.charAt(yyleng-1) == '\\') { - // remove escape - yytext = yytext.substr(0,yyleng-2); - this.more(); - } else { - yytext = yytext.substr(1); // swallow start quote - this.input(); // swallow end quote - return "STRING"; - } - }], - ["\\{", "return '{'"], - ["\\}", "return '}'"], - ["\\[", "return '['"], - ["\\]", "return ']'"], - [",", "return ','"], - [":", "return ':'"], - ["true\\b", "return 'TRUE'"], - ["false\\b", "return 'FALSE'"], - ["null\\b", "return 'NULL'"] - ] - }, - - "tokens": "STRING NUMBER { } [ ] , : TRUE FALSE NULL", - "bnf": { - "JsonThing": [ "JsonObject", - "JsonArray" ], - - "JsonObject": [ "{ JsonPropertyList }" ], - - "JsonPropertyList": [ "JsonProperty", - "JsonPropertyList , JsonProperty" ], - - "JsonProperty": [ "StringLiteral : JsonValue" ], - - "JsonArray": [ "[ JsonValueList ]" ], - - "JsonValueList": [ "JsonValue", - "JsonValueList , JsonValue" ], - - "JsonValue": [ "StringLiteral", - "NumericalLiteral", - "JsonObject", - "JsonArray", - "TRUE", - "FALSE", - "NULL" ], - - "StringLiteral": [ "STRING" ], - - "NumericalLiteral": [ "NUMBER" ] - }, - }; - - var source = '{"foo": "Bar", "hi": 42, "array": [1,2,3.004,4], "false": false, "true":true, "null": null, "obj": {"ha":"ho"}, "string": "string\\"sgfg" }'; - - var parser = new Jison.Parser(grammar, {type: "lr"}); - assert.ok(parser.parse(source)); -} - -exports["test compilers test grammar"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"] - ] - }; - var grammar = { - tokens: [ 'x' ], - startSymbol: "S", - bnf: { - "S" :[ 'A' ], - "A" :[ 'B A', '' ], - "B" :[ '', 'x' ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr"}); - parser.lexer = new Lexer(lexData); - - assert.ok(parser.parse("xxx"), "parse"); -}; - -exports["test compilers test grammar 2"] = function () { - var grammar = "%% n : a b ; a : | a x ; b : | b x y ;"; - - var parser = new Jison.Generator(grammar, {type: "lr"}); - - assert.equal(parser.conflicts, 1, "only one conflict"); -}; - -exports["test nullables"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"], - ["z", "return 'z';"], - [";", "return ';';"] - ] - }; - var grammar = { - tokens: [ ';', 'x', 'y', 'z' ], - startSymbol: "S", - bnf: { - "S" :[ 'A ;' ], - "A" :[ 'B C' ], - "B" :[ 'x' ], - "C" :[ 'y', 'D' ], - "D" :[ 'F' ], - "F" :[ '', 'F z' ], - } - }; - - var parser = new Jison.Parser(grammar, {type: "lr"}); - parser.lexer = new Lexer(lexData); - - assert.ok(parser.parse("x;"), "parse"); -}; diff --git a/tests/parser/parser-tests.js b/tests/parser/parser-tests.js deleted file mode 100755 index 2ef8a9d6d..000000000 --- a/tests/parser/parser-tests.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.testAPI = require("./api"); -exports.testLR0 = require("./lr0"); -exports.testSLR = require("./slr"); -exports.testLALR = require("./lalr"); -exports.testLR1 = require("./lr1"); -exports.testAST = require("./actions"); -exports.testTables = require("./tables"); -exports.testPrecedence = require("./precedence"); -exports.testGenerator = require("./generator"); -exports.testErrorLab = require("./errorlab"); - -if (require.main === module) - require("test").run(exports); diff --git a/tests/parser/precedence.js b/tests/parser/precedence.js deleted file mode 100644 index d5783ae90..000000000 --- a/tests/parser/precedence.js +++ /dev/null @@ -1,237 +0,0 @@ -var Jison = require("../setup").Jison, - RegExpLexer = require("../setup").RegExpLexer, - assert = require("assert"); - -var lexData = { - rules: [ - ["x", "return 'x';"], - ["\\+", "return '+';"], - ["$", "return 'EOF';"] - ] -}; - -exports["test Left associative rule"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["\\+", "return '+';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - tokens: [ "x", "+", "EOF" ], - startSymbol: "S", - operators: [ - ["left", "+"] - ], - bnf: { - "S" :[ [ 'E EOF', "return $1;" ] ], - "E" :[ [ "E + E", "$$ = ['+', $1, $3];" ], - [ "x", "$$ = ['x'];"] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - var expectedAST = ["+", ["+", ["x"], ["x"]], ["x"]]; - - var r = parser.parse("x+x+x"); - assert.deepEqual(r, expectedAST); -}; - -exports["test Right associative rule"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["\\+", "return '+';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - tokens: [ "x", "+", "EOF" ], - startSymbol: "S", - operators: [ - ["right", "+"] - ], - bnf: { - "S" :[ [ "E EOF", "return $1;" ] ], - "E" :[ [ "E + E", "$$ = ['+', $1, $3];" ], - [ "x", "$$ = ['x'];" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - var expectedAST = ["+", ["x"], ["+", ["x"], ["x"]]]; - - var r = parser.parse("x+x+x"); - assert.deepEqual(r, expectedAST); -}; - -exports["test Multiple precedence operators"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["\\+", "return '+';"], - ["\\*", "return '*';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - tokens: [ "x", "+", "*", "EOF" ], - startSymbol: "S", - operators: [ - ["left", "+"], - ["left", "*"] - ], - bnf: { - "S" :[ [ "E EOF", "return $1;" ] ], - "E" :[ [ "E + E", "$$ = ['+', $1, $3];" ], - [ "E * E", "$$ = ['*', $1, $3];" ], - [ "x", "$$ = ['x'];" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - var expectedAST = ["+", ["*", ["x"], ["x"]], ["x"]]; - - var r = parser.parse("x*x+x"); - assert.deepEqual(r, expectedAST); -}; - -exports["test Multiple precedence operators"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["\\+", "return '+';"], - ["\\*", "return '*';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - tokens: [ "x", "+", "*", "EOF" ], - startSymbol: "S", - operators: [ - ["left", "+"], - ["left", "*"] - ], - bnf: { - "S" :[ [ "E EOF", "return $1;" ] ], - "E" :[ [ "E + E", "$$ = [$1,'+', $3];" ], - [ "E * E", "$$ = [$1, '*', $3];" ], - [ "x", "$$ = ['x'];" ] ] - } - }; - - var parser = new Jison.Parser(grammar); - parser.lexer = new RegExpLexer(lexData); - - var expectedAST = [["x"], "+", [["x"], "*", ["x"]]]; - - var r = parser.parse("x+x*x"); - assert.deepEqual(r, expectedAST); -}; - -exports["test Non-associative operator"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["=", "return '=';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - tokens: [ "x", "=", "EOF" ], - startSymbol: "S", - operators: [ - ["nonassoc", "="] - ], - bnf: { - "S" :[ "E EOF" ], - "E" :[ "E = E", - "x" ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "lalr"}); - parser.lexer = new RegExpLexer(lexData); - - assert.throws(function () {parser.parse("x=x=x");}, "throws parse error when operator used twice."); - assert.ok(parser.parse("x=x"), "normal use is okay."); -}; - -exports["test Context-dependent precedence"] = function () { - var lexData = { - rules: [ - ["x", "return 'x';"], - ["-", "return '-';"], - ["\\+", "return '+';"], - ["\\*", "return '*';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - tokens: [ "x", "-", "+", "*", "EOF" ], - startSymbol: "S", - operators: [ - ["left", "-", "+"], - ["left", "*"], - ["left", "UMINUS"] - ], - bnf: { - "S" :[ [ "E EOF", "return $1;" ] ], - "E" :[ [ "E - E", "$$ = [$1,'-', $3];" ], - [ "E + E", "$$ = [$1,'+', $3];" ], - [ "E * E", "$$ = [$1,'*', $3];" ], - [ "- E", "$$ = ['#', $2];", {prec: "UMINUS"} ], - [ "x", "$$ = ['x'];" ] ] - } - }; - - var parser = new Jison.Parser(grammar, {type: "slr"}); - parser.lexer = new RegExpLexer(lexData); - - var expectedAST = [[[["#", ["x"]], "*", ["#", ["x"]]], "*", ["x"]], "-", ["x"]]; - - var r = parser.parse("-x*-x*x-x"); - assert.deepEqual(r, expectedAST); -}; - -exports["test multi-operator rules"] = function () { - var lexData = { - rules: [ - ["x", "return 'ID';"], - ["\\.", "return 'DOT';"], - ["=", "return 'ASSIGN';"], - ["\\(", "return 'LPAREN';"], - ["\\)", "return 'RPAREN';"], - ["$", "return 'EOF';"] - ] - }; - var grammar = { - tokens: "ID DOT ASSIGN LPAREN RPAREN EOF", - startSymbol: "S", - operators: [ - ["right", "ASSIGN"], - ["left", "DOT"] - ], - bnf: { - "S" :[ [ "e EOF", "return $1;" ] ], - "id":[ [ "ID", "$$ = ['ID'];"] ], - "e" :[ [ "e DOT id", "$$ = [$1,'-', $3];" ], - [ "e DOT id ASSIGN e", "$$ = [$1,'=', $3];" ], - [ "e DOT id LPAREN e RPAREN", "$$ = [$1,'+', $3];" ], - [ "id ASSIGN e", "$$ = [$1,'+', $3];" ], - [ "id LPAREN e RPAREN", "$$ = [$1,'+', $3];" ], - [ "id", "$$ = $1;" ] ] - } - }; - - var gen = new Jison.Generator(grammar, {type: 'slr'}); - - assert.equal(gen.conflicts, 0); -}; diff --git a/tests/parser/slr.js b/tests/parser/slr.js deleted file mode 100644 index 48672e756..000000000 --- a/tests/parser/slr.js +++ /dev/null @@ -1,52 +0,0 @@ -var Jison = require("../setup").Jison, - Lexer = require("../setup").Lexer, - assert = require("assert"); - -var lexData = { - rules: [ - ["x", "return 'x';"], - ["y", "return 'y';"] - ] -}; - -exports["test left-recursive nullable grammar"] = function () { - - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'A x', - '' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "slr"}); - var parser = gen.createParser(); - parser.lexer = new Lexer(lexData); - - assert.ok(parser.parse('xxx'), "parse 3 x's"); - assert.ok(parser.parse("x"), "parse single x"); - assert.throws(function(){parser.parse("y")}, "throws parse error on invalid token"); - assert.ok(gen.conflicts == 0, "no conflicts"); -}; - -exports["test right-recursive nullable grammar"] = function () { - - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - '' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "slr"}); - var parser = gen.createParser(); - parser.lexer = new Lexer(lexData); - - assert.ok(parser.parse('xxx'), "parse 3 x's"); - assert.ok(gen.table.length == 4, "table has 4 states"); - assert.ok(gen.conflicts == 0, "no conflicts"); - assert.equal(gen.nullable('A'), true, "A is nullable"); -}; diff --git a/tests/parser/tables.js b/tests/parser/tables.js deleted file mode 100644 index 5b0b13aa4..000000000 --- a/tests/parser/tables.js +++ /dev/null @@ -1,126 +0,0 @@ -var Jison = require("../setup").Jison, - assert = require("assert"); - -exports["test right-recursive nullable grammar"] = function () { - - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - '' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "slr"}); - var gen2 = new Jison.Generator(grammar, {type: "lalr"}); - - assert.equal(gen.table.length, 4, "table has 4 states"); - assert.equal(gen.nullable('A'), true, "A is nullable"); - assert.equal(gen.conflicts, 0, "should have no conflict"); - assert.deepEqual(gen.table, gen2.table, "should have identical tables"); -}; - -exports["test slr lalr lr tables are equal"] = function () { - var grammar = { - tokens: [ "ZERO", "PLUS"], - startSymbol: "E", - bnf: { - "E" :[ "E PLUS T", - "T" ], - "T" :[ "ZERO" ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "slr"}); - var gen2 = new Jison.Generator(grammar, {type: "lalr"}); - var gen3 = new Jison.Generator(grammar, {type: "lr"}); - - assert.deepEqual(gen.table, gen2.table, "slr lalr should have identical tables"); - assert.deepEqual(gen2.table, gen3.table, "lalr lr should have identical tables"); -}; - -exports["test LL parse table"] = function () { - - var grammar = { - tokens: [ 'x' ], - startSymbol: "A", - bnf: { - "A" :[ 'x A', - '' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "ll"}); - - assert.deepEqual(gen.table, {$accept:{x:[0], $end:[0]}, A:{x:[1], $end:[2]}}, "ll table has 2 states"); -}; - -exports["test LL parse table with conflict"] = function () { - - var grammar = { - tokens: [ 'x' ], - startSymbol: "L", - bnf: { - "L" :[ 'T L T', - '' ], - "T" :[ "x" ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "ll"}); - assert.equal(gen.conflicts, 1, "should have 1 conflict"); -}; - -exports["test Ambigous grammar"] = function () { - - var grammar = { - tokens: [ 'x', 'y' ], - startSymbol: "A", - bnf: { - "A" :[ 'A B A', - 'x' ], - "B" :[ '', - 'y' ] - } - }; - - var gen = new Jison.Generator(grammar, {type: "lr"}); - assert.equal(gen.conflicts, 2, "should have 2 conflict"); -}; - -// for Minimal LR testing. Not there yet. -/*exports["test Spector grammar G1"] = function () {*/ - - //var grammar = { - //"tokens": "z d b c a", - //"startSymbol": "S", - //"bnf": { - //"S" :[ "a A c", - //"a B d", - //"b A d", - //"b B c"], - //"A" :[ "z" ], - //"B" :[ "z" ] - //} - //}; - - //var gen = new Jison.Generator(grammar, {type: "mlr", debug:true}); - //assert.strictEqual(gen.conflicts, 0, "should have no conflict"); -//}; - -//exports["test De Remer G4"] = function () { - - //var grammar = { - //"tokens": "z d b c a", - //"startSymbol": "S", - //"bnf": { - //"S" : "a A d | b A c | b B d", - //"A" : "e A | e", - //"B" : "e B | e" - //} - //}; - - //var gen = new Jison.Generator(grammar, {type: "mlr", debug:true}); - //assert.strictEqual(gen.conflicts, 0, "should have no conflict"); -/*};*/ diff --git a/tests/performance.js b/tests/performance.js deleted file mode 100755 index 94c48fc2f..000000000 --- a/tests/performance.js +++ /dev/null @@ -1,108 +0,0 @@ -// TODO: ...should probably have some real performance tests. - -var Jison = require("./setup").Jison; - -var grammar = { - "lex": { - "macros": { - "digit": "[0-9]", - "id": "[a-zA-Z][a-zA-Z0-9]*" - }, - - "rules": [ - ["//.*", "/* ignore comment */"], - ["main\\b", "return 'MAIN';"], - ["class\\b", "return 'CLASS';"], - ["extends\\b", "return 'EXTENDS';"], - ["nat\\b", "return 'NATTYPE';"], - ["if\\b", "return 'IF';"], - ["else\\b", "return 'ELSE';"], - ["for\\b", "return 'FOR';"], - ["printNat\\b", "return 'PRINTNAT';"], - ["readNat\\b", "return 'READNAT';"], - ["this\\b", "return 'THIS';"], - ["new\\b", "return 'NEW';"], - ["var\\b", "return 'VAR';"], - ["null\\b", "return 'NUL';"], - ["{digit}+", "return 'NATLITERAL';"], - ["{id}", "return 'ID';"], - ["==", "return 'EQUALITY';"], - ["=", "return 'ASSIGN';"], - ["\\+", "return 'PLUS';"], - ["-", "return 'MINUS';"], - ["\\*", "return 'TIMES';"], - [">", "return 'GREATER';"], - ["\\|\\|", "return 'OR';"], - ["!", "return 'NOT';"], - ["\\.", "return 'DOT';"], - ["\\{", "return 'LBRACE';"], - ["\\}", "return 'RBRACE';"], - ["\\(", "return 'LPAREN';"], - ["\\)", "return 'RPAREN';"], - [";", "return 'SEMICOLON';"], - ["\\s+", "/* skip whitespace */"], - [".", "print('Illegal character');throw 'Illegal character';"], - ["$", "return 'ENDOFFILE';"] - ] - }, - - "tokens": "MAIN CLASS EXTENDS NATTYPE IF ELSE FOR PRINTNAT READNAT THIS NEW VAR NUL NATLITERAL ID ASSIGN PLUS MINUS TIMES EQUALITY GREATER OR NOT DOT SEMICOLON LBRACE RBRACE LPAREN RPAREN ENDOFFILE", - "operators": [ - ["right", "ASSIGN"], - ["left", "OR"], - ["nonassoc", "EQUALITY", "GREATER"], - ["left", "PLUS", "MINUS"], - ["left", "TIMES"], - ["right", "NOT"], - ["left", "DOT"] - ], - - "bnf": { - "pgm": ["cdl MAIN LBRACE vdl el RBRACE ENDOFFILE"], - - "cdl": ["c cdl", - ""], - - "c": ["CLASS id EXTENDS id LBRACE vdl mdl RBRACE"], - - "vdl": ["VAR t id SEMICOLON vdl", - ""], - - "mdl": ["t id LPAREN t id RPAREN LBRACE vdl el RBRACE mdl", - ""], - - "t": ["NATTYPE", - "id"], - - "id": ["ID"], - - "el": ["e SEMICOLON el", - "e SEMICOLON"], - - "e": ["NATLITERAL", - "NUL", - "id", - "NEW id", - "THIS", - "IF LPAREN e RPAREN LBRACE el RBRACE ELSE LBRACE el RBRACE ", - "FOR LPAREN e SEMICOLON e SEMICOLON e RPAREN LBRACE el RBRACE", - "READNAT LPAREN RPAREN", - "PRINTNAT LPAREN e RPAREN", - "e PLUS e", - "e MINUS e", - "e TIMES e", - "e EQUALITY e", - "e GREATER e", - "NOT e", - "e OR e", - "e DOT id", - "id ASSIGN e", - "e DOT id ASSIGN e", - "id LPAREN e RPAREN", - "e DOT id LPAREN e RPAREN", - "LPAREN e RPAREN"] - } -}; - -var parser = new Jison.Parser(grammar, {type: 'lalr'}); - diff --git a/tests/setup.js b/tests/setup.js deleted file mode 100644 index 46d2d5172..000000000 --- a/tests/setup.js +++ /dev/null @@ -1,2 +0,0 @@ -exports.Jison = require("../lib/jison").Jison; -exports.Lexer = exports.RegExpLexer = require("jison-lex"); diff --git a/web/.gitignore b/web/.gitignore deleted file mode 100644 index ab5f99f7b..000000000 --- a/web/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -output/ -tmp/ diff --git a/web/README b/web/README deleted file mode 100644 index 5a1e851a9..000000000 --- a/web/README +++ /dev/null @@ -1 +0,0 @@ -Build with nanoc diff --git a/web/Rakefile b/web/Rakefile deleted file mode 100644 index f484d249c..000000000 --- a/web/Rakefile +++ /dev/null @@ -1 +0,0 @@ -require 'nanoc3/tasks' \ No newline at end of file diff --git a/web/Rules b/web/Rules deleted file mode 100644 index eb7eddc7d..000000000 --- a/web/Rules +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env ruby - -# A few helpful tips about the Rules file: -# -# * The order of rules is important: for each item, only the first matching -# rule is applied. -# -# * Item identifiers start and end with a slash (e.g. “/about/” for the file -# “content/about.html”). To select all children, grandchildren, … of an -# item, use the pattern “/about/*/”; “/about/*” will also select the parent, -# because “*” matches zero or more characters. - - -compile '/jison/assets/*' do - # do nothing -end - - -compile '/jison/demos/*/' do - layout 'default' -end - -compile '/jison/try/' do - filter :erb - layout 'default' -end - -compile '/jison/try/*' do - # do nothing -end - -compile '/jison/' do - filter :erb -end - -compile '*' do - filter :kramdown - layout 'default' -end - -### Routing ######################################################### - -route '/jison/assets/styles/*' do - item.identifier.gsub(/\/$/, '') + '.css' -end - -route '/jison/assets/js/*' do - item.identifier.gsub(/\/$/, '') + '.js' -end - -route '/jison/assets/pngs/*' do - item.identifier.gsub('/pngs/', '/images/').gsub(/\/$/, '') + '.png' -end - - -route '/jison/assets/*' do - dir = File.join('content', item.identifier) - puts dir - base = File.basename(dir) - regexp = /^#{base}\.(?!yaml)(.*)/ - - file_name = Dir.entries(dir).sort.find do |d| - d.match(regexp) - end - - if file_name - ext = file_name.match(regexp)[1] - File.join(File.dirname(item.identifier), "#{base}.#{ext}") - else - nil - end -end - -route '*' do - item.identifier + 'index.html' -end - -layout '*', :erb diff --git a/web/config.yaml b/web/config.yaml deleted file mode 100644 index c52e81848..000000000 --- a/web/config.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# A list of file extensions that nanoc will consider to be textual rather than -# binary. If an item with an extension not in this list is found, the file -# will be considered as binary. -text_extensions: [ 'css', 'erb', 'haml', 'htm', 'html', 'js', 'less', 'markdown', 'md', 'php', 'rb', 'sass', 'txt' ] - -# The path to the directory where all generated files will be written to. This -# can be an absolute path starting with a slash, but it can also be path -# relative to the site directory. -output_dir: output - -# A list of index filenames, i.e. names of files that will be served by a web -# server when a directory is requested. Usually, index files are named -# “index.hml”, but depending on the web server, this may be something else, -# such as “default.htm”. This list is used by nanoc to generate pretty URLs. -index_filenames: [ 'index.html' ] - -# Whether or not to generate a diff of the compiled content when compiling a -# site. The diff will contain the differences between the compiled content -# before and after the last site compilation. -enable_output_diff: false - -# The data sources where nanoc loads its data from. This is an array of -# hashes; each array element represents a single data source. By default, -# there is only a single data source that reads data from the “content/” and -# “layout/” directories in the site directory. -data_sources: - - - # The type is the identifier of the data source. By default, this will be - # `filesystem_unified`. - type: filesystem_unified - - # The path where items should be mounted (comparable to mount points in - # Unix-like systems). This is “/” by default, meaning that items will have - # “/” prefixed to their identifiers. If the items root were “/en/” - # instead, an item at content/about.html would have an identifier of - # “/en/about/” instead of just “/about/”. - items_root: /jison/ - - # The path where layouts should be mounted. The layouts root behaves the - # same as the items root, but applies to layouts rather than items. - layouts_root: / diff --git a/web/content/about.html b/web/content/about.html deleted file mode 100644 index 033cd8e46..000000000 --- a/web/content/about.html +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: About ---- - -What is it? -===== - -Parsers help computers derive meaning from arbitrary text. And Jison helps you build parsers! - -Jison is essentially a clone of the parser generator [Bison](http://dinosaur.compilertools.net/#bison) (thus Yacc,) but in JavaScript. It includes its own lexical analyzer modeled after [Flex](http://dinosaur.compilertools.net/#flex). - -It was originally created by Zach Carter to help study for a Compilers course. diff --git a/web/content/assets/js/calculator.js b/web/content/assets/js/calculator.js deleted file mode 100644 index 63bbc151c..000000000 --- a/web/content/assets/js/calculator.js +++ /dev/null @@ -1,346 +0,0 @@ -/* Jison generated parser */ -var calculator = (function(){ -var parser = {trace: function trace() { }, -yy: {}, -symbols_: {"error":2,"expressions":3,"e":4,"EOF":5,"+":6,"-":7,"*":8,"/":9,"^":10,"(":11,")":12,"NUMBER":13,"E":14,"PI":15,"$accept":0,"$end":1}, -terminals_: {"2":"error","5":"EOF","6":"+","7":"-","8":"*","9":"/","10":"^","11":"(","12":")","13":"NUMBER","14":"E","15":"PI"}, -productions_: [0,[3,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,2],[4,3],[4,1],[4,1],[4,1]], -performAction: function anonymous(yytext, yyleng, yylineno, yy) { -var $$ = arguments[5],$0=arguments[5].length; -switch(arguments[4]) { -case 1:return $$[$0-2+1-1]; -break; -case 2:this.$ = $$[$0-3+1-1]+$$[$0-3+3-1]; -break; -case 3:this.$ = $$[$0-3+1-1]-$$[$0-3+3-1]; -break; -case 4:this.$ = $$[$0-3+1-1]*$$[$0-3+3-1]; -break; -case 5:this.$ = $$[$0-3+1-1]/$$[$0-3+3-1]; -break; -case 6:this.$ = Math.pow($$[$0-3+1-1], $$[$0-3+3-1]); -break; -case 7:this.$ = -$$[$0-2+2-1]; -break; -case 8:this.$ = $$[$0-3+2-1]; -break; -case 9:this.$ = Number(yytext); -break; -case 10:this.$ = Math.E; -break; -case 11:this.$ = Math.PI; -break; -} -}, -table: [{"3":1,"4":2,"7":[1,3],"11":[1,4],"13":[1,5],"14":[1,6],"15":[1,7]},{"1":[3]},{"5":[1,8],"6":[1,9],"7":[1,10],"8":[1,11],"9":[1,12],"10":[1,13]},{"4":14,"7":[1,3],"11":[1,4],"13":[1,5],"14":[1,6],"15":[1,7]},{"4":15,"7":[1,3],"11":[1,4],"13":[1,5],"14":[1,6],"15":[1,7]},{"5":[2,9],"6":[2,9],"7":[2,9],"8":[2,9],"9":[2,9],"10":[2,9],"12":[2,9]},{"5":[2,10],"6":[2,10],"7":[2,10],"8":[2,10],"9":[2,10],"10":[2,10],"12":[2,10]},{"5":[2,11],"6":[2,11],"7":[2,11],"8":[2,11],"9":[2,11],"10":[2,11],"12":[2,11]},{"1":[2,1]},{"4":16,"7":[1,3],"11":[1,4],"13":[1,5],"14":[1,6],"15":[1,7]},{"4":17,"7":[1,3],"11":[1,4],"13":[1,5],"14":[1,6],"15":[1,7]},{"4":18,"7":[1,3],"11":[1,4],"13":[1,5],"14":[1,6],"15":[1,7]},{"4":19,"7":[1,3],"11":[1,4],"13":[1,5],"14":[1,6],"15":[1,7]},{"4":20,"7":[1,3],"11":[1,4],"13":[1,5],"14":[1,6],"15":[1,7]},{"6":[2,7],"7":[2,7],"8":[2,7],"9":[2,7],"10":[2,7],"5":[2,7],"12":[2,7]},{"12":[1,21],"6":[1,9],"7":[1,10],"8":[1,11],"9":[1,12],"10":[1,13]},{"6":[2,2],"7":[2,2],"8":[1,11],"9":[1,12],"10":[1,13],"5":[2,2],"12":[2,2]},{"6":[2,3],"7":[2,3],"8":[1,11],"9":[1,12],"10":[1,13],"5":[2,3],"12":[2,3]},{"6":[2,4],"7":[2,4],"8":[2,4],"9":[2,4],"10":[1,13],"5":[2,4],"12":[2,4]},{"6":[2,5],"7":[2,5],"8":[2,5],"9":[2,5],"10":[1,13],"5":[2,5],"12":[2,5]},{"6":[2,6],"7":[2,6],"8":[2,6],"9":[2,6],"10":[2,6],"5":[2,6],"12":[2,6]},{"5":[2,8],"6":[2,8],"7":[2,8],"8":[2,8],"9":[2,8],"10":[2,8],"12":[2,8]}], -parseError: function parseError(str, hash) { - throw new Error(str); -}, -parse: function parse(input) { - var self = this, - stack = [0], - vstack = [null], // semantic value stack - table = this.table, - yytext = '', - yylineno = 0, - yyleng = 0, - shifts = 0, - reductions = 0, - recovering = 0, - TERROR = 2, - EOF = 1; - - this.lexer.setInput(input); - this.lexer.yy = this.yy; - this.yy.lexer = this.lexer; - - var parseError = this.yy.parseError = typeof this.yy.parseError == 'function' ? this.yy.parseError : this.parseError; - - function popStack (n) { - stack.length = stack.length - 2*n; - vstack.length = vstack.length - n; - } - - function checkRecover (st) { - for (var p in table[st]) if (p == TERROR) { - //print('RECOVER!!'); - return true; - } - return false; - } - - function lex() { - var token; - token = self.lexer.lex() || 1; // $end = 1 - // if token isn't its numeric value, convert - if (typeof token !== 'number') { - token = self.symbols_[token]; - } - return token; - }; - - var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected, recovered = false; - symbol = lex(); - while (true) { - // set first input - state = stack[stack.length-1]; - // read action for current state and first input - action = table[state] && table[state][symbol]; - - // handle parse error - if (typeof action === 'undefined' || !action.length || !action[0]) { - - if (!recovering) { - // Report error - expected = []; - for (p in table[state]) if (this.terminals_[p] && p > 2) { - expected.push("'"+this.terminals_[p]+"'"); - } - if (this.lexer.showPosition) { - parseError.call(this, 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+'\nExpecting '+expected.join(', '), - {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, expected: expected}); - } else { - parseError.call(this, 'Parse error on line '+(yylineno+1)+": Unexpected '"+this.terminals_[symbol]+"'", - {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, expected: expected}); - } - } - - // just recovered from another error - if (recovering == 3) { - if (symbol == EOF) { - throw 'Parsing halted.' - } - - // discard current lookahead and grab another - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - symbol = lex(); - } - - // try to recover from error - while (1) { - // check for error recovery rule in this state - if (checkRecover(state)) { - break; - } - if (state == 0) { - throw 'Parsing halted.' - } - popStack(1); - state = stack[stack.length-1]; - } - - preErrorSymbol = symbol; // save the lookahead token - symbol = TERROR; // insert generic error symbol as new lookahead - state = stack[stack.length-1]; - action = table[state] && table[state][TERROR]; - recovering = 3; // allow 3 real symbols to be shifted before reporting a new error - } - - // this shouldn't happen, unless resolve defaults are off - if (action[0] instanceof Array && action.length > 1) { - throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol); - } - - a = action; - - switch (a[0]) { - - case 1: // shift - shifts++; - - stack.push(symbol); - vstack.push(this.lexer.yytext); // semantic values or junk only, no terminals - stack.push(a[1]); // push state - if (!preErrorSymbol) { // normal execution/no error - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - symbol = lex(); - if (recovering > 0) - recovering--; - } else { // error just occurred, resume old lookahead f/ before error - symbol = preErrorSymbol; - preErrorSymbol = null; - } - break; - - case 2: // reduce - reductions++; - - len = this.productions_[a[1]][1]; - - // perform semantic action - yyval.$ = vstack[vstack.length-len]; // default to $$ = $1 - r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, a[1], vstack); - - if (typeof r !== 'undefined') { - return r; - } - - // pop off stack - if (len) { - stack = stack.slice(0,-1*len*2); - vstack = vstack.slice(0, -1*len); - } - - stack.push(this.productions_[a[1]][0]); // push nonterminal (reduce) - vstack.push(yyval.$); - // goto new state = table[STATE][NONTERMINAL] - newState = table[stack[stack.length-2]][stack[stack.length-1]]; - stack.push(newState); - break; - - case 3: // accept - - this.reductionCount = reductions; - this.shiftCount = shifts; - return true; - } - - } - - return true; -}};/* Jison generated lexer */ -var lexer = (function(){var lexer = ({EOF:"", -parseError:function parseError(str, hash) { - if (this.yy.parseError) { - this.yy.parseError(str, hash); - } else { - throw new Error(str); - } - }, -setInput:function (input) { - this._input = input; - this._more = this._less = this.done = false; - this.yylineno = this.yyleng = 0; - this.yytext = this.matched = this.match = ''; - return this; - }, -input:function () { - var ch = this._input[0]; - this.yytext+=ch; - this.yyleng++; - this.match+=ch; - this.matched+=ch; - var lines = ch.match(/\n/); - if (lines) this.yylineno++; - this._input = this._input.slice(1); - return ch; - }, -unput:function (ch) { - this._input = ch + this._input; - return this; - }, -more:function () { - this._more = true; - return this; - }, -pastInput:function () { - var past = this.matched.substr(0, this.matched.length - this.match.length); - return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); - }, -upcomingInput:function () { - var next = this.match; - if (next.length < 20) { - next += this._input.substr(0, 20-next.length); - } - return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); - }, -showPosition:function () { - var pre = this.pastInput(); - var c = new Array(pre.length + 1).join("-"); - return pre + this.upcomingInput() + "\n" + c+"^"; - }, -next:function () { - if (this.done) { - return this.EOF; - } - if (!this._input) this.done = true; - - var token, - match, - lines; - if (!this._more) { - this.yytext = ''; - this.match = ''; - } - for (var i=0;i < this.rules.length; i++) { - match = this._input.match(this.rules[i]); - if (match) { - lines = match[0].match(/\n/g); - if (lines) this.yylineno += lines.length; - this.yytext += match[0]; - this.match += match[0]; - this.matches = match; - this.yyleng = this.yytext.length; - this._more = false; - this._input = this._input.slice(match[0].length); - this.matched += match[0]; - token = this.performAction.call(this, this.yy, this, i); - if (token) return token; - else return; - } - } - if (this._input == this.EOF) { - return this.EOF; - } else { - this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), - {text: "", token: null, line: this.yylineno}); - } - }, -lex:function () { - var r = this.next(); - if (typeof r !== 'undefined') { - return r; - } else { - return this.lex(); - } - }}); -lexer.performAction = function anonymous(yy, yy_) { -switch(arguments[2]) { -case 0:/* skip whitespace */ -break; -case 1:return 13; -break; -case 2:return 8; -break; -case 3:return 9; -break; -case 4:return 7; -break; -case 5:return 6; -break; -case 6:return 10; -break; -case 7:return 11; -break; -case 8:return 12; -break; -case 9:return 15; -break; -case 10:return 14; -break; -case 11:return 5; -break; -} -}; -lexer.rules = [/^\s+/,/^[0-9]+(\.[0-9]+)?\b\b/,/^\*/,/^\//,/^-/,/^\+/,/^\^/,/^\(/,/^\)/,/^PI\b/,/^E\b/,/^$/];return lexer;})() -parser.lexer = lexer; -return parser; -})(); -if (typeof require !== 'undefined') { -exports.parser = calculator; -exports.parse = function () { return calculator.parse.apply(calculator, arguments); } -exports.main = function commonjsMain(args) { - var cwd = require("file").path(require("file").cwd()); - if (!args[1]) - throw new Error('Usage: '+args[0]+' FILE'); - var source = cwd.join(args[1]).read({charset: "utf-8"}); - exports.parser.parse(source); -} -if (require.main === module) { - exports.main(require("system").args); -} -} diff --git a/web/content/assets/js/es5.js b/web/content/assets/js/es5.js deleted file mode 100644 index 884895acc..000000000 --- a/web/content/assets/js/es5.js +++ /dev/null @@ -1,233 +0,0 @@ -if (!Object.keys) { - Object.keys = function (object) { - var keys = []; - for (var name in object) { - if (Object.prototype.hasOwnProperty.call(object, name)) { - keys.push(name); - } - } - return keys; - }; -} - -if (!Object.defineProperty) - Object.defineProperty = function(object, property, descriptor) { - var has = Object.prototype.hasOwnProperty; - if (typeof descriptor == "object") { - if (has.call(descriptor, "value")) { - if (!object.__lookupGetter__(property) && !object.__lookupSetter__(property)) - // data property defined and no pre-existing accessors - object[property] = descriptor.value; - if ((has.call(descriptor, "get") || has.call(descriptor, "set"))) - // descriptor has a value property but accessor already exists - throw new TypeError("Object doesn't support this action"); - } - if ( // can't implement these features; allow false but not true - !(has.call(descriptor, "writable") ? descriptor.writable : true) || - !(has.call(descriptor, "enumerable") ? descriptor.enumerable : true) || - !(has.call(descriptor, "configurable") ? descriptor.configurable : true) - ) - throw new RangeError( - "This implementation of Object.defineProperty does not " + - "support configurable, enumerable, or writable." - ); - else if (typeof descriptor.get == "function") - object.__defineGetter__(property, descriptor.get); - if (typeof descriptor.set == "function") - object.__defineSetter__(property, descriptor.set); - } - return object; - }; - -if (!Object.defineProperties) { - Object.defineProperties = function(object, properties) { - for (var property in properties) { - if (Object.prototype.hasOwnProperty.call(properties, property)) - Object.defineProperty(object, property, properties[property]); - } - return object; - }; -} - -if (!Object.create) { - Object.create = function(prototype, properties) { - function Type() {}; - Type.prototype = prototype; - var object = new Type(); - if (typeof properties !== "undefined") - Object.defineProperties(object, properties); - return object; - }; -} - -// ES5 15.5.4.20 -if (!String.prototype.trim) { - // http://blog.stevenlevithan.com/archives/faster-trim-javascript - var trimBeginRegexp = /^\s\s*/; - var trimEndRegexp = /\s\s*$/; - String.prototype.trim = function () { - return String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, ''); - }; -} -// Array additions. - -// ES5 draft: -// http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf - -// ES5 15.4.3.2 -if (!Array.isArray) { - Array.isArray = function(obj) { - return Object.prototype.toString.call(obj) == "[object Array]"; - }; -} - -// ES5 15.4.4.18 -if (!Array.prototype.forEach) { - Array.prototype.forEach = function(block, thisObject) { - var len = this.length >>> 0; - for (var i = 0; i < len; i++) { - if (i in this) { - block.call(thisObject, this[i], i, this); - } - } - }; -} - -// ES5 15.4.4.19 -// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map -if (!Array.prototype.map) { - Array.prototype.map = function(fun /*, thisp*/) { - var len = this.length >>> 0; - if (typeof fun != "function") - throw new TypeError(); - - var res = new Array(len); - var thisp = arguments[1]; - for (var i = 0; i < len; i++) { - if (i in this) - res[i] = fun.call(thisp, this[i], i, this); - } - - return res; - }; -} - -// filter -if (!Array.prototype.filter) { - Array.prototype.filter = function (block /*, thisp */) { - var values = []; - var thisp = arguments[1]; - for (var i = 0; i < this.length; i++) - if (block.call(thisp, this[i])) - values.push(this[i]); - return values; - }; -} - -// every -if (!Array.prototype.every) { - Array.prototype.every = function (block /*, thisp */) { - var thisp = arguments[1]; - for (var i = 0; i < this.length; i++) - if (!block.call(thisp, this[i])) - return false; - return true; - }; -} - -// some -if (!Array.prototype.some) { - Array.prototype.some = function (block /*, thisp */) { - var thisp = arguments[1]; - for (var i = 0; i < this.length; i++) - if (block.call(thisp, this[i])) - return true; - return false; - }; -} - -// reduce -// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce -if (!Array.prototype.reduce) { - Array.prototype.reduce = function(fun /*, initial*/) { - var len = this.length >>> 0; - if (typeof fun != "function") - throw new TypeError(); - - // no value to return if no initial value and an empty array - if (len == 0 && arguments.length == 1) - throw new TypeError(); - - var i = 0; - if (arguments.length >= 2) { - var rv = arguments[1]; - } else { - do { - if (i in this) { - rv = this[i++]; - break; - } - - // if array contains no values, no initial value to return - if (++i >= len) - throw new TypeError(); - } while (true); - } - - for (; i < len; i++) { - if (i in this) - rv = fun.call(null, rv, this[i], i, this); - } - - return rv; - }; -} - -// reduceRight -// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight -if (!Array.prototype.reduceRight) { - Array.prototype.reduceRight = function(fun /*, initial*/) { - var len = this.length >>> 0; - if (typeof fun != "function") - throw new TypeError(); - - // no value to return if no initial value, empty array - if (len == 0 && arguments.length == 1) - throw new TypeError(); - - var i = len - 1; - if (arguments.length >= 2) { - var rv = arguments[1]; - } else { - do { - if (i in this) { - rv = this[i--]; - break; - } - - // if array contains no values, no initial value to return - if (--i < 0) - throw new TypeError(); - } while (true); - } - - for (; i >= 0; i--) { - if (i in this) - rv = fun.call(null, rv, this[i], i, this); - } - - return rv; - }; -} - -if(!Array.prototype.indexOf){ - Array.prototype.indexOf = function(obj){ - for(var i=0; i type pairs - class2type = {}, - - // List of deleted data cache ids, so we can reuse them - core_deletedIds = [], - - core_version = "1.9.0pre", - - // Save a reference to some core methods - core_concat = core_deletedIds.concat, - core_push = core_deletedIds.push, - core_slice = core_deletedIds.slice, - core_indexOf = core_deletedIds.indexOf, - core_toString = class2type.toString, - core_hasOwn = class2type.hasOwnProperty, - core_trim = core_version.trim, - - // Define a local copy of jQuery - jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context, rootjQuery ); - }, - - // Used for matching numbers - core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, - - // Used for splitting on whitespace - core_rnotwhite = /\S+/g, - - // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, - - // A simple way to check for HTML strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - // Strict HTML recognition (#11290: must start with <) - rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/, - - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, - - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, - rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g, - - // Matches dashed string for camelizing - rmsPrefix = /^-ms-/, - rdashAlpha = /-([\da-z])/gi, - - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function( all, letter ) { - return letter.toUpperCase(); - }, - - // The ready event handler and self cleanup method - DOMContentLoaded = function() { - if ( document.addEventListener ) { - document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - jQuery.ready(); - } else if ( document.readyState === "complete" ) { - // we're here because readyState === "complete" in oldIE - // which is good enough for us to call the dom ready! - document.detachEvent( "onreadystatechange", DOMContentLoaded ); - jQuery.ready(); - } - }; - -jQuery.fn = jQuery.prototype = { - // The current version of jQuery being used - jquery: core_version, - - constructor: jQuery, - init: function( selector, context, rootjQuery ) { - var match, elem; - - // HANDLE: $(""), $(null), $(undefined), $(false) - if ( !selector ) { - return this; - } - - // HANDLE: $(DOMElement) - if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - } - - // Handle HTML strings - if ( typeof selector === "string" ) { - if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = rquickExpr.exec( selector ); - } - - // Match html or make sure no context is specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) { - context = context instanceof jQuery ? context[0] : context; - - // scripts is true for back-compat - jQuery.merge( this, jQuery.parseHTML( - match[1], - context && context.nodeType ? context.ownerDocument || context : document, - true - ) ); - - // HANDLE: $(html, props) - if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { - for ( match in context ) { - // Properties of context are called as methods if possible - if ( jQuery.isFunction( this[ match ] ) ) { - this[ match ]( context[ match ] ); - - // ...and otherwise set as attributes - } else { - this.attr( match, context[ match ] ); - } - } - } - - return this; - - // HANDLE: $(#id) - } else { - elem = document.getElementById( match[2] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return ( context || rootjQuery ).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return rootjQuery.ready( selector ); - } - - if ( selector.selector !== undefined ) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }, - - // Start with an empty selector - selector: "", - - // The default length of a jQuery object is 0 - length: 0, - - // The number of elements contained in the matched element set - size: function() { - return this.length; - }, - - toArray: function() { - return core_slice.call( this ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num == null ? - - // Return a 'clean' array - this.toArray() : - - // Return just the object - ( num < 0 ? this[ this.length + num ] : this[ num ] ); - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems ) { - - // Build a new jQuery matched element set - var ret = jQuery.merge( this.constructor(), elems ); - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - ret.context = this.context; - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - ready: function( fn ) { - // Add the callback - jQuery.ready.promise().done( fn ); - - return this; - }, - - slice: function() { - return this.pushStack( core_slice.apply( this, arguments ) ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - eq: function( i ) { - var len = this.length, - j = +i + ( i < 0 ? len : 0 ); - return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function( elem, i ) { - return callback.call( elem, i, elem ); - })); - }, - - end: function() { - return this.prevObject || this.constructor(null); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: core_push, - sort: [].sort, - splice: [].splice -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.extend = jQuery.fn.extend = function() { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if ( length === i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) { - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { - // Extend the base object - for ( name in options ) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { - if ( copyIsArray ) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; - - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend({ - noConflict: function( deep ) { - if ( window.$ === jQuery ) { - window.$ = _$; - } - - if ( deep && window.jQuery === jQuery ) { - window.jQuery = _jQuery; - } - - return jQuery; - }, - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } - }, - - // Handle when the DOM is ready - ready: function( wait ) { - - // Abort if there are pending holds or we're already ready - if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { - return; - } - - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger("ready").off("ready"); - } - }, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return jQuery.type(obj) === "function"; - }, - - isArray: Array.isArray || function( obj ) { - return jQuery.type(obj) === "array"; - }, - - isWindow: function( obj ) { - return obj != null && obj == obj.window; - }, - - isNumeric: function( obj ) { - return !isNaN( parseFloat(obj) ) && isFinite( obj ); - }, - - type: function( obj ) { - return obj == null ? - String( obj ) : - class2type[ core_toString.call(obj) ] || "object"; - }, - - isPlainObject: function( obj ) { - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { - return false; - } - - try { - // Not own constructor property must be Object - if ( obj.constructor && - !core_hasOwn.call(obj, "constructor") && - !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { - return false; - } - } catch ( e ) { - // IE8,9 Will throw exceptions on certain host objects #9897 - return false; - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - - var key; - for ( key in obj ) {} - - return key === undefined || core_hasOwn.call( obj, key ); - }, - - isEmptyObject: function( obj ) { - var name; - for ( name in obj ) { - return false; - } - return true; - }, - - error: function( msg ) { - throw new Error( msg ); - }, - - // data: string of html - // context (optional): If specified, the fragment will be created in this context, defaults to document - // keepScripts (optional): If true, will include scripts passed in the html string - parseHTML: function( data, context, keepScripts ) { - if ( !data || typeof data !== "string" ) { - return null; - } - if ( typeof context === "boolean" ) { - keepScripts = context; - context = false; - } - context = context || document; - - var parsed = rsingleTag.exec( data ), - scripts = !keepScripts && []; - - // Single tag - if ( parsed ) { - return [ context.createElement( parsed[1] ) ]; - } - - parsed = context.createDocumentFragment(); - jQuery.clean( [ data ], context, parsed, scripts ); - if ( scripts ) { - jQuery( scripts ).remove(); - } - return jQuery.merge( [], parsed.childNodes ); - }, - - parseJSON: function( data ) { - // Attempt to parse using the native JSON parser first - if ( window.JSON && window.JSON.parse ) { - return window.JSON.parse( data ); - } - - if ( data === null ) { - return data; - } - - if ( typeof data === "string" ) { - - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); - - if ( data ) { - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test( data.replace( rvalidescape, "@" ) - .replace( rvalidtokens, "]" ) - .replace( rvalidbraces, "")) ) { - - return ( new Function( "return " + data ) )(); - } - } - } - - jQuery.error( "Invalid JSON: " + data ); - }, - - // Cross-browser xml parsing - parseXML: function( data ) { - var xml, tmp; - if ( !data || typeof data !== "string" ) { - return null; - } - try { - if ( window.DOMParser ) { // Standard - tmp = new DOMParser(); - xml = tmp.parseFromString( data , "text/xml" ); - } else { // IE - xml = new ActiveXObject( "Microsoft.XMLDOM" ); - xml.async = "false"; - xml.loadXML( data ); - } - } catch( e ) { - xml = undefined; - } - if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { - jQuery.error( "Invalid XML: " + data ); - } - return xml; - }, - - noop: function() {}, - - // Evaluates a script in a global context - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function( data ) { - if ( data && jQuery.trim( data ) ) { - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - ( window.execScript || function( data ) { - window[ "eval" ].call( window, data ); - } )( data ); - } - }, - - // Convert dashed to camelCase; used by the css and data modules - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function( string ) { - return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); - }, - - // args is for internal usage only - each: function( obj, callback, args ) { - var value, - i = 0, - length = obj.length, - isArray = isArraylike( obj ); - - if ( args ) { - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback.apply( obj[ i ], args ); - - if ( value === false ) { - break; - } - } - } else { - for ( i in obj ) { - value = callback.apply( obj[ i ], args ); - - if ( value === false ) { - break; - } - } - } - - // A special, fast, case for the most common use of each - } else { - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback.call( obj[ i ], i, obj[ i ] ); - - if ( value === false ) { - break; - } - } - } else { - for ( i in obj ) { - value = callback.call( obj[ i ], i, obj[ i ] ); - - if ( value === false ) { - break; - } - } - } - } - - return obj; - }, - - // Use native String.trim function wherever possible - trim: core_trim && !core_trim.call("\uFEFF\xA0") ? - function( text ) { - return text == null ? - "" : - core_trim.call( text ); - } : - - // Otherwise use our own trimming functionality - function( text ) { - return text == null ? - "" : - ( text + "" ).replace( rtrim, "" ); - }, - - // results is for internal usage only - makeArray: function( arr, results ) { - var ret = results || []; - - if ( arr != null ) { - if ( isArraylike( Object(arr) ) ) { - jQuery.merge( ret, - typeof arr === "string" ? - [ arr ] : arr - ); - } else { - core_push.call( ret, arr ); - } - } - - return ret; - }, - - inArray: function( elem, arr, i ) { - var len; - - if ( arr ) { - if ( core_indexOf ) { - return core_indexOf.call( arr, elem, i ); - } - - len = arr.length; - i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; - - for ( ; i < len; i++ ) { - // Skip accessing in sparse arrays - if ( i in arr && arr[ i ] === elem ) { - return i; - } - } - } - - return -1; - }, - - merge: function( first, second ) { - var l = second.length, - i = first.length, - j = 0; - - if ( typeof l === "number" ) { - for ( ; j < l; j++ ) { - first[ i++ ] = second[ j ]; - } - } else { - while ( second[j] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, inv ) { - var retVal, - ret = [], - i = 0, - length = elems.length; - inv = !!inv; - - // Go through the array, only saving the items - // that pass the validator function - for ( ; i < length; i++ ) { - retVal = !!callback( elems[ i ], i ); - if ( inv !== retVal ) { - ret.push( elems[ i ] ); - } - } - - return ret; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var value, - i = 0, - length = elems.length, - isArray = isArraylike( elems ), - ret = []; - - // Go through the array, translating each of the items to their - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - - // Go through every key on the object, - } else { - for ( i in elems ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - } - - // Flatten any nested arrays - return core_concat.apply( [], ret ); - }, - - // A global GUID counter for objects - guid: 1, - - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function( fn, context ) { - var tmp, args, proxy; - - if ( typeof context === "string" ) { - tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if ( !jQuery.isFunction( fn ) ) { - return undefined; - } - - // Simulated bind - args = core_slice.call( arguments, 2 ); - proxy = function() { - return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) ); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || jQuery.guid++; - - return proxy; - }, - - // Multifunctional method to get and set values of a collection - // The value/s can optionally be executed if it's a function - access: function( elems, fn, key, value, chainable, emptyGet, raw ) { - var i = 0, - length = elems.length, - bulk = key == null; - - // Sets many values - if ( jQuery.type( key ) === "object" ) { - chainable = true; - for ( i in key ) { - jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); - } - - // Sets one value - } else if ( value !== undefined ) { - chainable = true; - - if ( !jQuery.isFunction( value ) ) { - raw = true; - } - - if ( bulk ) { - // Bulk operations run against the entire set - if ( raw ) { - fn.call( elems, value ); - fn = null; - - // ...except when executing function values - } else { - bulk = fn; - fn = function( elem, key, value ) { - return bulk.call( jQuery( elem ), value ); - }; - } - } - - if ( fn ) { - for ( ; i < length; i++ ) { - fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); - } - } - } - - return chainable ? - elems : - - // Gets - bulk ? - fn.call( elems ) : - length ? fn( elems[0], key ) : emptyGet; - }, - - now: function() { - return ( new Date() ).getTime(); - } -}); - -jQuery.ready.promise = function( obj ) { - if ( !readyList ) { - - readyList = jQuery.Deferred(); - - // Catch cases where $(document).ready() is called after the browser event has already occurred. - // we once tried to use readyState "interactive" here, but it caused issues like the one - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - setTimeout( jQuery.ready ); - - // Standards-based browsers support DOMContentLoaded - } else if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", jQuery.ready, false ); - - // If IE event model is used - } else { - // Ensure firing before onload, maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", DOMContentLoaded ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", jQuery.ready ); - - // If IE and not a frame - // continually check to see if the document is ready - var top = false; - - try { - top = window.frameElement == null && document.documentElement; - } catch(e) {} - - if ( top && top.doScroll ) { - (function doScrollCheck() { - if ( !jQuery.isReady ) { - - try { - // Use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - top.doScroll("left"); - } catch(e) { - return setTimeout( doScrollCheck, 50 ); - } - - // and execute any waiting functions - jQuery.ready(); - } - })(); - } - } - } - return readyList.promise( obj ); -}; - -// Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); - -function isArraylike( obj ) { - var length = obj.length, - type = jQuery.type( obj ); - - if ( jQuery.isWindow( obj ) ) { - return false; - } - - if ( obj.nodeType === 1 && length ) { - return true; - } - - return type === "array" || type !== "function" && - ( length === 0 || - typeof length === "number" && length > 0 && ( length - 1 ) in obj ); -} - -// All jQuery objects should point back to these -rootjQuery = jQuery(document); -// String to Object options format cache -var optionsCache = {}; - -// Convert String-formatted options into Object-formatted ones and store in cache -function createOptions( options ) { - var object = optionsCache[ options ] = {}; - jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) { - object[ flag ] = true; - }); - return object; -} - -/* - * Create a callback list using the following parameters: - * - * options: an optional list of space-separated options that will change how - * the callback list behaves or a more traditional option object - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible options: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ -jQuery.Callbacks = function( options ) { - - // Convert options from String-formatted to Object-formatted if needed - // (we check in cache first) - options = typeof options === "string" ? - ( optionsCache[ options ] || createOptions( options ) ) : - jQuery.extend( {}, options ); - - var // Last fire value (for non-forgettable lists) - memory, - // Flag to know if list was already fired - fired, - // Flag to know if list is currently firing - firing, - // First callback to fire (used internally by add and fireWith) - firingStart, - // End of the loop when firing - firingLength, - // Index of currently firing callback (modified by remove if needed) - firingIndex, - // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = !options.once && [], - // Fire callbacks - fire = function( data ) { - memory = options.memory && data; - fired = true; - firingIndex = firingStart || 0; - firingStart = 0; - firingLength = list.length; - firing = true; - for ( ; list && firingIndex < firingLength; firingIndex++ ) { - if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { - memory = false; // To prevent further calls using add - break; - } - } - firing = false; - if ( list ) { - if ( stack ) { - if ( stack.length ) { - fire( stack.shift() ); - } - } else if ( memory ) { - list = []; - } else { - self.disable(); - } - } - }, - // Actual Callbacks object - self = { - // Add a callback or a collection of callbacks to the list - add: function() { - if ( list ) { - // First, we save the current length - var start = list.length; - (function add( args ) { - jQuery.each( args, function( _, arg ) { - var type = jQuery.type( arg ); - if ( type === "function" ) { - if ( !options.unique || !self.has( arg ) ) { - list.push( arg ); - } - } else if ( arg && arg.length && type !== "string" ) { - // Inspect recursively - add( arg ); - } - }); - })( arguments ); - // Do we need to add the callbacks to the - // current firing batch? - if ( firing ) { - firingLength = list.length; - // With memory, if we're not firing then - // we should call right away - } else if ( memory ) { - firingStart = start; - fire( memory ); - } - } - return this; - }, - // Remove a callback from the list - remove: function() { - if ( list ) { - jQuery.each( arguments, function( _, arg ) { - var index; - while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { - list.splice( index, 1 ); - // Handle firing indexes - if ( firing ) { - if ( index <= firingLength ) { - firingLength--; - } - if ( index <= firingIndex ) { - firingIndex--; - } - } - } - }); - } - return this; - }, - // Control if a given callback is in the list - has: function( fn ) { - return jQuery.inArray( fn, list ) > -1; - }, - // Remove all callbacks from the list - empty: function() { - list = []; - return this; - }, - // Have the list do nothing anymore - disable: function() { - list = stack = memory = undefined; - return this; - }, - // Is it disabled? - disabled: function() { - return !list; - }, - // Lock the list in its current state - lock: function() { - stack = undefined; - if ( !memory ) { - self.disable(); - } - return this; - }, - // Is it locked? - locked: function() { - return !stack; - }, - // Call all callbacks with the given context and arguments - fireWith: function( context, args ) { - args = args || []; - args = [ context, args.slice ? args.slice() : args ]; - if ( list && ( !fired || stack ) ) { - if ( firing ) { - stack.push( args ); - } else { - fire( args ); - } - } - return this; - }, - // Call all the callbacks with the given arguments - fire: function() { - self.fireWith( this, arguments ); - return this; - }, - // To know if the callbacks have already been called at least once - fired: function() { - return !!fired; - } - }; - - return self; -}; -jQuery.extend({ - - Deferred: function( func ) { - var tuples = [ - // action, add listener, listener list, final state - [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], - [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], - [ "notify", "progress", jQuery.Callbacks("memory") ] - ], - state = "pending", - promise = { - state: function() { - return state; - }, - always: function() { - deferred.done( arguments ).fail( arguments ); - return this; - }, - then: function( /* fnDone, fnFail, fnProgress */ ) { - var fns = arguments; - return jQuery.Deferred(function( newDefer ) { - jQuery.each( tuples, function( i, tuple ) { - var action = tuple[ 0 ], - fn = fns[ i ]; - // deferred[ done | fail | progress ] for forwarding actions to newDefer - deferred[ tuple[1] ]( jQuery.isFunction( fn ) ? - function() { - var returned = fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise() - .done( newDefer.resolve ) - .fail( newDefer.reject ) - .progress( newDefer.notify ); - } else { - newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, [ returned ] ); - } - } : - newDefer[ action ] - ); - }); - fns = null; - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - return obj != null ? jQuery.extend( obj, promise ) : promise; - } - }, - deferred = {}; - - // Keep pipe for back-compat - promise.pipe = promise.then; - - // Add list-specific methods - jQuery.each( tuples, function( i, tuple ) { - var list = tuple[ 2 ], - stateString = tuple[ 3 ]; - - // promise[ done | fail | progress ] = list.add - promise[ tuple[1] ] = list.add; - - // Handle state - if ( stateString ) { - list.add(function() { - // state = [ resolved | rejected ] - state = stateString; - - // [ reject_list | resolve_list ].disable; progress_list.lock - }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); - } - - // deferred[ resolve | reject | notify ] - deferred[ tuple[0] ] = function() { - deferred[ tuple[0] + "With" ]( promise, arguments ); - return this; - }; - deferred[ tuple[0] + "With" ] = list.fireWith; - }); - - // Make the deferred a promise - promise.promise( deferred ); - - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - - // All done! - return deferred; - }, - - // Deferred helper - when: function( subordinate /* , ..., subordinateN */ ) { - var i = 0, - resolveValues = core_slice.call( arguments ), - length = resolveValues.length, - - // the count of uncompleted subordinates - remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, - - // the master Deferred. If resolveValues consist of only a single Deferred, just use that. - deferred = remaining === 1 ? subordinate : jQuery.Deferred(), - - // Update function for both resolve and progress values - updateFunc = function( i, contexts, values ) { - return function( value ) { - contexts[ i ] = this; - values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; - if( values === progressValues ) { - deferred.notifyWith( contexts, values ); - } else if ( !( --remaining ) ) { - deferred.resolveWith( contexts, values ); - } - }; - }, - - progressValues, progressContexts, resolveContexts; - - // add listeners to Deferred subordinates; treat others as resolved - if ( length > 1 ) { - progressValues = new Array( length ); - progressContexts = new Array( length ); - resolveContexts = new Array( length ); - for ( ; i < length; i++ ) { - if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { - resolveValues[ i ].promise() - .done( updateFunc( i, resolveContexts, resolveValues ) ) - .fail( deferred.reject ) - .progress( updateFunc( i, progressContexts, progressValues ) ); - } else { - --remaining; - } - } - } - - // if we're not waiting on anything, resolve the master - if ( !remaining ) { - deferred.resolveWith( resolveContexts, resolveValues ); - } - - return deferred.promise(); - } -}); -jQuery.support = (function() { - - var support, - all, - a, - select, - opt, - input, - fragment, - eventName, - i, - isSupported, - clickFn, - div = document.createElement("div"); - - // Setup - div.setAttribute( "className", "t" ); - div.innerHTML = "
a"; - - // Support tests won't run in some limited or non-browser environments - all = div.getElementsByTagName("*"); - a = div.getElementsByTagName("a")[ 0 ]; - if ( !all || !a || !all.length ) { - return {}; - } - - // First batch of tests - select = document.createElement("select"); - opt = select.appendChild( document.createElement("option") ); - input = div.getElementsByTagName("input")[ 0 ]; - - a.style.cssText = "top:1px;float:left;opacity:.5"; - support = { - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - getSetAttribute: div.className !== "t", - - // IE strips leading whitespace when .innerHTML is used - leadingWhitespace: div.firstChild.nodeType === 3, - - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - tbody: !div.getElementsByTagName("tbody").length, - - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - htmlSerialize: !!div.getElementsByTagName("link").length, - - // Get the style information from getAttribute - // (IE uses .cssText instead) - style: /top/.test( a.getAttribute("style") ), - - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - hrefNormalized: a.getAttribute("href") === "/a", - - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - opacity: /^0.5/.test( a.style.opacity ), - - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - cssFloat: !!a.style.cssFloat, - - // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) - checkOn: !!input.value, - - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - optSelected: opt.selected, - - // Tests for enctype support on a form (#6743) - enctype: !!document.createElement("form").enctype, - - // Makes sure cloning an html5 element does not cause problems - // Where outerHTML is undefined, this still works - html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", - - // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode - boxModel: document.compatMode === "CSS1Compat", - - // Will be defined later - submitBubbles: true, - changeBubbles: true, - focusinBubbles: false, - deleteExpando: true, - noCloneEvent: true, - inlineBlockNeedsLayout: false, - shrinkWrapBlocks: false, - reliableMarginRight: true, - boxSizingReliable: true, - pixelPosition: false, - hasCanvas: false, - hasVML: false - }; - - // Make sure checked status is properly cloned - input.checked = true; - support.noCloneChecked = input.cloneNode( true ).checked; - - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as disabled) - select.disabled = true; - support.optDisabled = !opt.disabled; - - // Test to see if it's possible to delete an expando from an element - // Fails in Internet Explorer - try { - delete div.test; - } catch( e ) { - support.deleteExpando = false; - } - - if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { - div.attachEvent( "onclick", clickFn = function() { - // Cloning a node shouldn't copy over any - // bound event handlers (IE does this) - support.noCloneEvent = false; - }); - div.cloneNode( true ).fireEvent("onclick"); - div.detachEvent( "onclick", clickFn ); - } - - // Check if we can trust getAttribute("value") - input = document.createElement("input"); - input.setAttribute( "value", "" ); - support.input = input.getAttribute( "value" ) === ""; - - // Check if an input maintains its value after becoming a radio - input.value = "t"; - input.setAttribute( "type", "radio" ); - support.radioValue = input.value === "t"; - - // #11217 - WebKit loses check when the name is after the checked attribute - input.setAttribute( "checked", "checked" ); - input.setAttribute( "name", "t" ); - - div.appendChild( input ); - fragment = document.createDocumentFragment(); - fragment.appendChild( div.lastChild ); - - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; - - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - support.appendChecked = input.checked; - - fragment.removeChild( input ); - fragment.appendChild( div ); - - // Technique from Juriy Zaytsev - // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ - // We only care about the case where non-standard event systems - // are used, namely in IE. Short-circuiting here helps us to - // avoid an eval call (in setAttribute) which can cause CSP - // to go haywire. See: https://developer.mozilla.org/en/Security/CSP - if ( div.attachEvent ) { - for ( i in { - submit: true, - change: true, - focusin: true - }) { - eventName = "on" + i; - isSupported = ( eventName in div ); - if ( !isSupported ) { - div.setAttribute( eventName, "return;" ); - isSupported = ( typeof div[ eventName ] === "function" ); - } - support[ i + "Bubbles" ] = isSupported; - } - } - - // Run tests that need a body at doc ready - jQuery(function() { - var container, div, tds, marginDiv, - divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", - body = document.getElementsByTagName("body")[0]; - - if ( !body ) { - // Return for frameset docs that don't have a body - return; - } - - container = document.createElement("div"); - container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px"; - body.insertBefore( container, body.firstChild ); - - // Construct the test element - div = document.createElement("div"); - container.appendChild( div ); - - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - // (only IE 8 fails this test) - div.innerHTML = "
t
"; - tds = div.getElementsByTagName("td"); - tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; - isSupported = ( tds[ 0 ].offsetHeight === 0 ); - - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; - - // Check if empty table cells still have offsetWidth/Height - // (IE <= 8 fail this test) - support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); - - // Check box-sizing and margin behavior - div.innerHTML = ""; - div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; - support.boxSizing = ( div.offsetWidth === 4 ); - support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); - - // NOTE: To any future maintainer, we've window.getComputedStyle - // because jsdom on node.js will break without it. - if ( window.getComputedStyle ) { - support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; - support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; - - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. For more - // info see bug #3333 - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - marginDiv = document.createElement("div"); - marginDiv.style.cssText = div.style.cssText = divReset; - marginDiv.style.marginRight = marginDiv.style.width = "0"; - div.style.width = "1px"; - div.appendChild( marginDiv ); - support.reliableMarginRight = - !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); - } - - if ( typeof div.style.zoom !== "undefined" ) { - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - // (IE < 8 does this) - div.innerHTML = ""; - div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); - - // Check if elements with layout shrink-wrap their children - // (IE 6 does this) - div.style.display = "block"; - div.style.overflow = "visible"; - div.innerHTML = "