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

Add C++ support #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions .github/workflows/snorkell-auto-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This workflow will improvise current file with AI genereated documentation and Create new PR

name: Penify - Revolutionizing Documentation on GitHub

on:
push:
branches: ["main"]
workflow_dispatch:

jobs:
Documentation:
runs-on: ubuntu-latest
steps:
- name: Penify DocGen Client
uses: SingularityX-ai/[email protected]
with:
client_id: ${{ secrets.SNORKELL_CLIENT_ID }}
api_key: ${{ secrets.SNORKELL_API_KEY }}
branch_name: "main"
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
members = [
"treeedb",
"treeedb-c",
"treeedb-cpp",
"treeedb-csharp",
"treeedb-java",
"treeedb-javascript",
Expand All @@ -13,6 +14,7 @@ members = [
"treeedbgen",
"treeedbgen-souffle",
"treeedbgen-souffle-c",
"treeedbgen-souffle-cpp",
"treeedbgen-souffle-csharp",
"treeedbgen-souffle-java",
"treeedbgen-souffle-javascript",
Expand Down
16 changes: 16 additions & 0 deletions treeedb-cpp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "treeedb-cpp"
version = "0.1.0"
edition = "2021"
description = "Generate Datalog facts from C++ source code"
keywords = ["datalog", "cpp", "parsing", "souffle"]
authors = ["Langston Barrett <[email protected]>"]
license = "MIT"
readme = "../README.md"
homepage = "https://github.com/langston-barrett/treeedb"
repository = "https://github.com/langston-barrett/treeedb"

[dependencies]
anyhow = "1.0"
treeedb = { version = "0.1.0", path = "../treeedb", features = ["cli"] }
tree-sitter-cpp = { version = "0.20" }
5 changes: 5 additions & 0 deletions treeedb-cpp/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

fn main() -> Result<()> {
treeedb::cli::main(tree_sitter_cpp::language())
}
1 change: 1 addition & 0 deletions treeedbgen-souffle-cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.csv
21 changes: 21 additions & 0 deletions treeedbgen-souffle-cpp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "treeedbgen-souffle-cpp"
version = "0.1.0"
edition = "2021"
description = "Generate Soufflé types and relations from the C++ tree-sitter grammar"
keywords = ["datalog", "cpp", "parsing", "souffle"]
authors = ["Langston Barrett <[email protected]>"]
license = "MIT"
readme = "../README.md"
homepage = "https://github.com/langston-barrett/treeedb"
repository = "https://github.com/langston-barrett/treeedb"

[dependencies]
anyhow = "1"
treeedbgen-souffle = { version = "0.1.0", path = "../treeedbgen-souffle", features = ["cli"] }
tree-sitter-cpp = { version = "0.20" }

[dev-dependencies]
assert_cmd = "2.0"
predicates = "2.1"
tempfile = "3"
5 changes: 5 additions & 0 deletions treeedbgen-souffle-cpp/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

fn main() -> Result<()> {
treeedbgen_souffle::cli::main(tree_sitter_cpp::NODE_TYPES)
}
33 changes: 33 additions & 0 deletions treeedbgen-souffle-cpp/tests/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use std::process::Command;

use assert_cmd::prelude::*;
use predicates::prelude::*;
use tempfile::NamedTempFile;

#[test]
fn gen() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("treeedbgen-souffle-cpp")?;
let tmp = NamedTempFile::new()?;
cmd.arg("-o").arg(tmp.path());
cmd.arg("--prefix=cpp").arg("--printsize");
cmd.assert()
.success()
.stdout(predicate::str::is_empty())
.stderr(predicate::str::is_empty());

let mut cmd = Command::cargo_bin("treeedb-cpp")?;
cmd.arg("tests/rs/hello-world.rs");
cmd.assert()
.success()
.stdout(predicate::str::is_empty())
.stderr(predicate::str::is_empty());

let mut souffle = Command::new("souffle");
souffle.arg(tmp.path());
souffle
.assert()
.success()
.stdout(predicate::str::contains("cpp_node\t10"))
.stderr(predicate::str::is_empty());
Ok(())
}
3 changes: 3 additions & 0 deletions treeedbgen-souffle-cpp/tests/rs/hello-world.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello World!");
}