Crates.io | conch-parser |
lib.rs | conch-parser |
version | 0.1.1 |
source | src |
created_at | 2016-12-05 00:23:04.681581 |
updated_at | 2019-05-15 05:57:37.770957 |
description | A library for parsing programs written in the shell programming language. |
homepage | https://github.com/ipetkov/conch-parser |
repository | https://github.com/ipetkov/conch-parser |
max_upload_size | |
id | 7468 |
size | 467,156 |
A Rust library for parsing Unix shell commands.
First, add this to your Cargo.toml
:
[dependencies]
conch-parser = "0.1.0"
Next, you can get started with:
extern crate conch_parser;
use conch_parser::lexer::Lexer;
use conch_parser::parse::DefaultParser;
fn main() {
// Initialize our token lexer and shell parser with the program's input
let lex = Lexer::new("echo foo bar".chars());
let parser = DefaultParser::new(lex);
// Parse our input!
for t in parser {
println!("{:?}", t);
}
}
This library offers parsing shell commands as defined by the
POSIX.1-2008 standard. The parser remains agnostic to the final AST
representation by passing intermediate results to an AST Builder
, allowing
for easy changes to the final AST structure without having to walk and transform
an entire AST produced by the parser. See the documentation for more information.
foo && bar || baz
)! foo | bar
){ foo; }
)$(foo)
)for
/ case
/ if
/ while
/ until
$foo
, $@
, etc.)${foo:-bar}
)Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.