https://github.com/vorpaljs/bash-parser
Parses bash into an AST
https://github.com/vorpaljs/bash-parser
ast bash parse
Last synced: about 1 month ago
JSON representation
Parses bash into an AST
- Host: GitHub
- URL: https://github.com/vorpaljs/bash-parser
- Owner: vorpaljs
- License: mit
- Created: 2016-03-08T22:17:57.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-06-23T18:55:05.000Z (11 months ago)
- Last Synced: 2024-10-17T02:31:08.556Z (7 months ago)
- Topics: ast, bash, parse
- Language: JavaScript
- Homepage: https://vorpaljs.github.io/bash-parser-playground/
- Size: 1.19 MB
- Stars: 200
- Watchers: 7
- Forks: 34
- Open Issues: 23
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# bash-parser
Parses bash source code to produce an AST
[](http://travis-ci.org/vorpaljs/bash-parser)
[](https://coveralls.io/github/vorpaljs/bash-parser)
[](https://npmjs.org/package/bash-parser)
[](https://npmjs.org/package/bash-parser)
[](https://vorpaljs.github.io/bash-parser-playground/)# Installation
```bash
npm install --save bash-parser
```# Usage
```js
const parse = require('bash-parser');
const ast = parse('echo ciao');
````ast` result is:
```js
{
type: "Script",
commands: [
{
type: "SimpleCommand",
name: {
text: "echo",
type: "Word"
},
suffix: [
{
text: "ciao",
type: "Word"
}
]
}
]
}
```# Related projects
* [cash](https://github.com/dthree/cash) - This parser should become the parser used by `cash` (and also [vorpal](https://github.com/dthree/vorpal))
* [nsh](https://github.com/piranna/nsh) - This parser should become the parser used by `nsh`
* [js-shell-parse](https://github.com/grncdr/js-shell-parse) - bash-parser was born as a fork of `js-shell-parse`, but was rewritten to use a `jison` grammar
* [jison](https://github.com/zaach/jison) - Bison in JavaScript.# Documentation
Look in [documents folder](https://github.com/vorpaljs/bash-parser/tree/master/documents)
# License
The MIT License (MIT)
Copyright (c) 2016 vorpaljs