bash-parser
Parses bash source code to produce an AST
Installation
npm install --save bash-parser
Usage
const parse = require('bash-parser');
const ast = parse('echo foo>file.txt');
ast
is of the following form:
{
type: 'list',
andOrs: [{
type: 'andOr',
left: [{
type: 'simple_command',
name: 'echo',
suffix: {
type: 'cmd_suffix',
list: [
'foo',
{
type: 'io_redirect',
op: '>',
file: 'file.txt'
}
]
}
}]
}]
}
Related projects
- cash - This parser should become the parser used by
cash
(and also vorpal) - nsh - This parser should become the parser used by
nsh
- js-shell-parse - bash-parser was born as a fork of
js-shell-parse
, but was rewritten to use a jison
grammar - jison - Bison in JavaScript.
License
The MIT License (MIT)
Copyright (c) 2016 vorpaljs