All Projects → cdiggins → Myna Parser

cdiggins / Myna Parser

Licence: mit
Myna Parsing Library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Myna Parser

Lug
Parsing expression grammar (PEG) embedded domain specific language and parsing machine for C++17
Stars: ✭ 44 (-36.23%)
Mutual labels:  parser-combinators, peg
ParsecSharp
The faster monadic parser combinator library for C#
Stars: ✭ 23 (-66.67%)
Mutual labels:  parser-combinators, peg
chumsky
A parser library for humans with powerful error recovery.
Stars: ✭ 740 (+972.46%)
Mutual labels:  parser-combinators, peg
Pegtl
Parsing Expression Grammar Template Library
Stars: ✭ 1,295 (+1776.81%)
Mutual labels:  parser-combinators, peg
Pom
PEG parser combinators using operator overloading without macros.
Stars: ✭ 310 (+349.28%)
Mutual labels:  parser-combinators, peg
Parsel
Create complex parsers by combining simple ones with Parsel!
Stars: ✭ 21 (-69.57%)
Mutual labels:  parser-combinators
Pyparsing
Python library for creating PEG parsers
Stars: ✭ 1,052 (+1424.64%)
Mutual labels:  parser-combinators
Metric Parser
📜 AST-based advanced mathematical parser written by Typescript.
Stars: ✭ 26 (-62.32%)
Mutual labels:  syntax-tree
Funcj
Assorted functional-oriented data structures and algorithms for Java.
Stars: ✭ 60 (-13.04%)
Mutual labels:  parser-combinators
Fssqldom
Library for SQL parsing, AST manipulation and SQL generation in F#
Stars: ✭ 45 (-34.78%)
Mutual labels:  syntax-tree
Chthollylang
A simple implementation of Yet another script language Chtholly
Stars: ✭ 19 (-72.46%)
Mutual labels:  parser-combinators
Comby
A tool for structural code search and replace that supports ~every language.
Stars: ✭ 912 (+1221.74%)
Mutual labels:  parser-combinators
Calyx
A Ruby library for generating text with recursive template grammars.
Stars: ✭ 51 (-26.09%)
Mutual labels:  syntax-tree
Parsec.js
A JavaScript parser combinator library inspired by Parsec of Haskell.
Stars: ✭ 12 (-82.61%)
Mutual labels:  parser-combinators
Footlessparser
A simple parser combinator written in Swift
Stars: ✭ 60 (-13.04%)
Mutual labels:  parser-combinators
Combine
A parser combinator library for Rust
Stars: ✭ 906 (+1213.04%)
Mutual labels:  parser-combinators
Foundatio.parsers
A lucene style query parser that is extensible and allows modifying the query.
Stars: ✭ 39 (-43.48%)
Mutual labels:  peg
3bmd
markdown processor in CL using esrap parser
Stars: ✭ 58 (-15.94%)
Mutual labels:  peg
Parseque
Total Parser Combinators in Coq
Stars: ✭ 37 (-46.38%)
Mutual labels:  parser-combinators
Mini Haskell
A self-hosting mini Haskell compiler with a mini C runtime.
Stars: ✭ 37 (-46.38%)
Mutual labels:  parser-combinators

Myna Parsing Library

npm version Build Status

Home Page | QUnit Tests | Source Code

Myna is an efficient and easy to use parsing library for JavaScript written using TypeScript 2.0 which targets ECMAScript 5.1.

Unlike several popular parsing libraries (e.g. Jison, PEG.js, nearley, and ANTLR) Myna is an API, not a code generation tool, which makes it easier for programmers to write, debug, and maintain their parsing algorithms. This makes Myna closest to Parsimmon and Chevrotain. Myna has no dependencies, you can just download myna.js and start using it immediately.

There are several example tools that demonstrate how to use Myna parsers and a number of sample grammars shipped with Myna that you can use or modify as needed.

Getting Started

You can either download the latest myna.js file via GitHub or via Unpkg and start using it in your project, or you can install Myna from npm.

Using Myna

Below is an example of how to use Myna from Node.JS in a single self-contained example:

    // Reference the Myna module
    var m = require('myna-parser');

    // Construct a grammar object 
    var g = new function() 
    {
        this.textdata   = m.notChar('\n\r"' + delimiter);    
        this.quoted     = m.doubleQuoted(m.notChar('"').or('""').zeroOrMore);
        this.field      = this.textdata.or(this.quoted).zeroOrMore.ast;
        this.record     = this.field.delimited(delimiter).ast;
        this.file       = this.record.delimited(m.newLine).ast;   
    }

    // Let consumers of the Myna module access 
    m.registerGrammar("csv", g, g.file);

    // Get the parser 
    var parser = m.parsers.csv; 
    
    // Parse some input and print the AST
    var input = 'a,1,"hello"\nb,2,"goodbye"';
    console.log(parse(input));

Only rules that are defined with the .ast property will create nodes in the output parse tree. This saves the work of having to convert from a Concrete Syntax Tree (CST) to an Abstract Syntax Tree (AST).

Myna Source Code and Dependencies

The Myna library is written in TypeScript 2.0 and is contained in one file myna.ts. The generated Myna JavaScript file that you would include in your project is myna.js.

Myna has no run-time dependencies. The Myna module, and the grammars are designed to be able to be run from the browser or from Node.JS.

Building Myna

The myna.js library is generated from the myna.ts source file using the TypeScript 2.0 compiler (tsc). I use npm as my build tool and task runner. I would welcome submissions for making my package cross platform. I use Visual Studio Code as my development environment.

The steps I use to making a patch and re-building/publishing Myna are:

  1. npm run full - This will build the TypeScript files, run tests, update docs, create a minified version of the JS file.
  2. git add . - Add the files to the git working state
  3. git commit -m "message" - Create a git commit
  4. npm version patch - Create a patch (will create a secondary Git commit)
  5. git push -u Push the commits to the server
  6. npm publish - Publish the Node package

Myna Tests

There are over a 1000 unit tests written using QUnit. There are also individual test files for each example tool, which you can run as a suite using node tests\test_all_tools.js.

Minification

For convenience I am providing a minified/obfuscated version dist/myna.min.js that is being generated with uglify.js.

Bugs and Issues

Please submit any issues, questions, or feature requests via the GitHub issue tracker.

Supporting Myna

You can show your support by reporting issues, making suggestions, contributing fixes, offering ideas, and providing feedback or critiques of any aspect of this project. Whether it is about code, development environment, documentation, processes, tests, philosophy, or general approach, it is all appreciated and helpful. I want this library to be as useful to you, as it is for me, and I want to continue to learn to be a better developer.

Letting me know how you use Myna, or why you decided against it would also be helpful, as would sharing your grammars with us!

Author

Christopher Diggins

License

Myna is licensed under the MIT License.

Acknowledgements

Thank you to my three gatitas Anneye, Anna, and Beatrice for their love, patience, and support. Also thank you to everyone who has ever written open-source code. We are doing this together!

Thanks to Eric Lindahl of Sciumo for being the first person to financially support the Myna project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].