Add C support

edge_only_predecessors
Wilfred Hughes 2021-09-14 23:25:22 +07:00
parent 7a7ce06af3
commit fb96b0a78d
6 changed files with 18 additions and 2 deletions

@ -1,6 +1,8 @@
## 0.10 (unreleased)
No changes.
### Parsing
Added a C parser.
## 0.9

@ -16,6 +16,7 @@ See [the manual](http://difftastic.wilfred.me.uk/) to get started.
Difftastic supports the following languages:
* C
* Clojure
* CSS
* Elixir

@ -36,6 +36,7 @@ fn main() {
println!("cargo:rerun-if-changed=vendor");
// TODO: build these in parallel.
build("tree-sitter-c", "vendor/tree-sitter-c-src", &[]);
build("tree-sitter-clojure", "vendor/tree-sitter-clojure-src", &[]);
build(
"tree-sitter-css",

@ -1,8 +1,9 @@
# Introduction
Difftastic is a diff tool that understands syntax. It currently
supports 14 languages:
supports 15 languages:
* C
* Clojure
* CSS
* Elixir

@ -25,6 +25,7 @@ pub struct TreeSitterConfig {
}
extern "C" {
fn tree_sitter_c() -> Language;
fn tree_sitter_clojure() -> Language;
fn tree_sitter_css() -> Language;
fn tree_sitter_elisp() -> Language;
@ -45,6 +46,15 @@ pub fn from_extension(extension: &OsStr) -> Option<TreeSitterConfig> {
// TODO: find a nice way to extract name and extension information
// from the package.json in these parsers.
match extension.to_string_lossy().borrow() {
"c" | "h" => Some(TreeSitterConfig {
name: "C",
language: unsafe { tree_sitter_c() },
atom_nodes: (vec!["string_literal", "char_literal"])
.into_iter()
.collect(),
// TODO: Handle array_declarator where [ is the second token.
open_delimiter_tokens: (vec!["(", "{"]).into_iter().collect(),
}),
"bb" | "boot" | "clj" | "cljc" | "clje" | "cljs" | "cljx" | "edn" | "joke" | "joker" => {
Some(TreeSitterConfig {
name: "Clojure",

@ -0,0 +1 @@
tree-sitter-c/src