Nerdy Poly Millionaires

    ember-cli-nearley

    2.0.6 • Public • Published

    Ember Observer Score Build Status Coverage Status NPM Version NPM Downloads Dependency Status DevDependency Status Greenkeeper

    ember-cli-nearley

    Simple Wrapper around Nearley. This provides a service that can be used to parse source code and also automatically compiles the index.ne file in app/grammar/

    DEMO

    Installation

    ember install ember-cli-nearley
    

    Usage

    import Route from '@ember/routing/route';
    
    import { inject } from '@ember/service';
    
    export default Route.extend({
    	nearley: inject(),
    
    	actions: {
    		onClick() {
    			let value = this.controller.get('value');
    			this.get('nearley').parse(value);
    		}
    	}
    });

    OR

    <div>
    	{{#nearley-parse
    		value=(concat input1 operator input2)
    	as |computed|}}
    		Result: {{computed}}
    	{{/nearley-parse}}
    </div>
    • Note this also includes Moo for tokenizing if needed
    • To use tokens from a different file file must be called tokens.js within app/grammar directory
    • and in your index.ne you must do this below. grammar-tokens is a shim created to allow you to import into your grammar.js file created from index.ne
    @{%
    	let moo = require('moo').default;
    
    	let tokens = require('grammar-tokens').default;
    
    	let lexer = moo.compile(tokens);
    %}
    # Pass your lexer object using the @lexer option:
    @lexer lexer
    

    Contributing

    See the Contributing guide for details.

    License

    This project is licensed under the MIT License.

    Install

    npm i ember-cli-nearley

    DownloadsWeekly Downloads

    16

    Version

    2.0.6

    License

    MIT

    Unpacked Size

    19.3 kB

    Total Files

    17

    Last publish

    Collaborators

    • devotox