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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | Jison ===== * [issues](http://github.com/zaach/jison/issues) * [discuss](mailto:jison@librelist.com) [![build status](https://secure.travis-ci.org/zaach/jison.png)](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: // 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 |
Commit History @a4494775-e36d-4da1-bf9f-548ce58f2698/main
0
»»
- Change section to javascript Xavier Guimard 3 years ago
- Add "Rules-Requires-Root: no" Xavier Guimard 3 years ago
- Declare compliance with policy 4.5.0 Xavier Guimard 3 years ago
- Bump debhelper compatibility level to 13 Xavier Guimard 3 years ago
- Use canonical URL in Vcs-Git. Debian Janitor 4 years ago
- Update Vcs-* headers from URL redirect. Debian Janitor 4 years ago
- Set upstream metadata fields: Bug-Database, Bug-Submit, Repository, Repository-Browse. Debian Janitor 4 years ago
- Set debhelper-compat version in Build-Depends. Debian Janitor 4 years ago
- Bump debhelper from old 9 to 12. Debian Janitor 4 years ago
- Use secure copyright file specification URI. Debian Janitor 4 years ago
- Trim trailing whitespace. Debian Janitor 4 years ago
- fix autopkgtest Praveen Arimbrathodiyil 7 years ago
- update changelog Praveen Arimbrathodiyil 7 years ago
- pass arguments as well Praveen Arimbrathodiyil 7 years ago
- create an sh launcher Praveen Arimbrathodiyil 7 years ago
- upload to unstable Praveen Arimbrathodiyil 7 years ago
- Merge tag 'upstream/0.4.17+dfsg' Praveen Arimbrathodiyil 7 years ago
- New upstream version 0.4.17+dfsg Praveen Arimbrathodiyil 7 years ago
- remove unwanted files Praveen Arimbrathodiyil 7 years ago
- add itp Praveen Arimbrathodiyil 7 years ago
- fix description Praveen Arimbrathodiyil 7 years ago
- use nodejs Praveen Arimbrathodiyil 7 years ago
- disable tests Praveen Arimbrathodiyil 7 years ago
- fix dependencies Praveen Arimbrathodiyil 7 years ago
- Import Debian patch 0.4.17-1 Pirate Praveen (commit: Praveen Arimbrathodiyil) 7 years ago
- Import Upstream version 0.4.17 Praveen Arimbrathodiyil 7 years ago
0
»»