Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] parsing fixes, better error handling, fuzzing #35

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ harness = false
name = "all-packages"

[dependencies]
cbitset = "0.2.0"
rowan = "0.12.5"
smol_str = "0.1.17"

Expand Down
2 changes: 1 addition & 1 deletion examples/list-fns.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{env, error::Error, fs};

use smol_str::SmolStr;
use rnix::{types::*, NodeOrToken, SyntaxKind::*, SyntaxNode};
use smol_str::SmolStr;

fn main() -> Result<(), Box<dyn Error>> {
let file = match env::args().skip(1).next() {
Expand Down
3 changes: 3 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
corpus
artifacts
106 changes: 106 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "rnix-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.rnix]
path = ".."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "parser"
path = "fuzz_targets/parser.rs"
test = false
doc = false

[[bin]]
name = "lexer"
path = "fuzz_targets/lexer.rs"
test = false
doc = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing final new line

8 changes: 8 additions & 0 deletions fuzz/fuzz_targets/lexer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
if let Ok(text) = std::str::from_utf8(data) {
let _ = rnix::tokenizer::tokenize(text);
}
});
14 changes: 14 additions & 0 deletions fuzz/fuzz_targets/parser.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

use std::io::{self, Write};

fuzz_target!(|data: &[u8]| {
let stdout = io::stdout();
let mut handle = stdout.lock();

if let Ok(text) = std::str::from_utf8(data) {
writeln!(handle, "Fuzzing {:?}\n\n", data).unwrap();
let _ = rnix::parse(text);
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing final new line

6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
mod macros;
mod kinds;
pub mod parser;
mod token_set;
pub mod tokenizer;
pub mod types;
pub mod value;

pub use self::{
kinds::SyntaxKind,
parser::AST,
token_set::TokenSet,
value::{StrPart, Value as NixValue},
};

pub use rowan::{
NodeOrToken, SyntaxElementChildren, SyntaxNodeChildren, TextRange, TextSize,
TokenAtOffset, WalkEvent,
NodeOrToken, SyntaxElementChildren, SyntaxNodeChildren, TextRange, TextSize, TokenAtOffset,
WalkEvent,
};

use self::tokenizer::Tokenizer;
Expand Down
Loading