2.0.6 • Published 5 years ago

ember-cli-nearley v2.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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.

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

6 years ago

2.0.1

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago