# grammarjs-grammar

> Parsing expression grammar (PEG)

Latest version **0.5.0** (published 2014-09-11) · 0 weekly downloads

## Install

```sh
npm install grammarjs-grammar
pnpm add grammarjs-grammar
yarn add grammarjs-grammar
bun add grammarjs-grammar
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2014-09-11 |
| First published | 2014-05-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Maintainers | viatropos |
| Keywords | peg, parsing, expression, grammar |

## Links

- npm: https://www.npmjs.com/package/grammarjs-grammar
- Repository: http://github.com/grammarjs/grammar
- Homepage: https://github.com/grammarjs/grammar
- Issues: https://github.com/grammarjs/grammar/issues
- npm.io page: https://npm.io/package/grammarjs-grammar

## Dependencies (1)

- [component-type](https://npm.io/package/component-type.md) ~1.0.0

## Recent versions

- 0.5.0 (latest) — 2014-09-11
- 0.4.0 — 2014-09-10
- 0.3.2 — 2014-09-09
- 0.3.1 — 2014-09-09
- 0.3.0 — 2014-09-09
- 0.2.0 — 2014-09-09
- 0.1.5 — 2014-06-10
- 0.1.4 — 2014-06-10
- 0.1.2 — 2014-05-30

## README

# Parsing Expression Grammar

![experimental](http://img.shields.io/badge/status-experimental-orange.svg?style=flat)
[![Build Status](http://img.shields.io/travis/grammarjs/grammar/v0.6.svg?style=flat)](https://travis-ci.org/grammarjs/grammar)

PEG-like expression builder for JavaScript. <1kb.

## Installation

```
$ npm install grammarjs-grammar
```

browser:

```
$ component install grammarjs/grammar
```

## Features

- easily define a custom parsing expression grammar (PEG)
- reuse and recombine PEGs with `.use(grammar)`
- expressions can be referenced by name, so complex grammars are very readable

## Overview

A `grammar` is a set of expressions that share a common namespace. This means you can define named expressions within a grammar, and access them from anywhere else within the grammar.

Expressions can't exist outside of a grammar. A grammar itself is just an expression, it is the start of the expression hierarchy.

You can nest grammars, and so build on top of them easily!

## Examples

See the [tests](https://github.com/grammarjs/recursive-parser/blob/master/test/index.js) for examples. Basically, in building a grammar, you are just building a Concrete Syntax Tree. This can be used for syntax highlighting, linting, and lots of other things. The next goal is to then find a standard mapping of the CST to the AST (Abstract Syntax Tree). This way you can define a grammar once, use it in an editor if you want, and also convert it to executable code.

## Test

```
make test
```

## Selectors

```
punctuation
punctuation.whitespace
punctuation.definition
literal
literal.string
literal.string.quote
literal.string.quote.double
literal.string.quote.single
literal.string
literal.number.integer
literal.number.decimal
literal.boolean
literal.boolean
keyword.control
keyword.other.var
keyword.operator
keyword.operator.gte
keyword.operator.percent
comment
comment.line
comment.line.dash
comment.line.dash.double
comment.line.percent
comment.block
type.struct (or entity?)
type.function
type.object
type.array
type.tag
type.pointer
type.interface
type.class
type.channel
type.map
constant
character.source
character.unicode
expression
expression.assignment
statement
statement.if
statement.switch
statement.continue
statement.debugger
statement.for
statement.while
statement.return
operator
delimiter https://golang.org/ref/spec
declaration
declaration.variable
declaration.class
declaration.type
declaration.function
support
```

## Notes

- http://stackoverflow.com/questions/5109905/are-there-any-javascript-frameworks-for-parsing-auto-completing-a-domain-specifi
- https://github.com/cgrand/parsley
- http://hackage.haskell.org/package/incremental-parser-0.2.3.2/docs/Text-ParserCombinators-Incremental.html
- error productions (http://www.codekana.com/blog/2009/04/02/on-the-speed-of-light-innovation-and-the-future-of-parsing/)
- http://manual.macromates.com/en/language_grammars

## Licence

MIT

---
_Source: https://npm.io/package/grammarjs-grammar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
