Skip to content

Commit ca2ab82

Browse files
committed
Remove c parser and use the c++ one instead
1 parent 2d6c404 commit ca2ab82

25 files changed

+16
-105102
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
[submodule "tree-sitter-c-sharp"]
2626
path = tree-sitter-c-sharp
2727
url = https://github.com/tree-sitter/tree-sitter-c-sharp/
28-
[submodule "tree-sitter-c"]
29-
path = tree-sitter-c
30-
url = https://github.com/tree-sitter/tree-sitter-c.git
3128
[submodule "tree-sitter-cpp"]
3229
path = tree-sitter-cpp
3330
url = https://github.com/tree-sitter/tree-sitter-cpp.git

build.rs

-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ fn main() {
139139
}
140140
let ignore = vec![
141141
"tree-sitter-typescript".to_string(),
142-
"tree-sitter-c".to_string(),
143142
"tree-sitter-cpp".to_string(),
144143
];
145144
let dirs = collect_tree_sitter_dirs(ignore);

enums/src/languages.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ mk_langs!(
99
(Java, tree_sitter_java),
1010
(Go, tree_sitter_go),
1111
(Html, tree_sitter_html),
12-
(C, tree_sitter_c),
1312
(CSharp, tree_sitter_c_sharp),
1413
(Rust, tree_sitter_rust),
1514
(Css, tree_sitter_css),

src/checker.rs

-16
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,6 @@ impl Checker for CcommentCode {
4646
}
4747
}
4848

49-
impl Checker for CCode {
50-
mk_checker!(is_comment, Comment);
51-
mk_checker!(is_string, StringLiteral, ConcatenatedString);
52-
mk_checker!(is_call, CallExpression);
53-
mk_checker!(is_func, FunctionDefinition);
54-
mk_checker!(is_func_space, TranslationUnit);
55-
56-
fn is_useful_comment(node: &Node, code: &[u8]) -> bool {
57-
lazy_static! {
58-
static ref AC: AhoCorasick = AhoCorasick::new(vec![b"<div rustbindgen"]);
59-
}
60-
let code = &code[node.start_byte()..node.end_byte()];
61-
AC.is_match(code)
62-
}
63-
}
64-
6549
impl Checker for CppCode {
6650
mk_checker!(is_comment, Comment);
6751
mk_checker!(

src/cyclomatic.rs

-13
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,6 @@ impl Cyclomatic for RustCode {
137137
}
138138
}
139139

140-
impl Cyclomatic for CCode {
141-
fn compute(node: &Node, stats: &mut Stats) {
142-
use C::*;
143-
144-
match node.kind_id().into() {
145-
If | For | While | Case | ConditionalExpression | AMPAMP | PIPEPIPE => {
146-
stats.cyclomatic += 1.;
147-
}
148-
_ => {}
149-
}
150-
}
151-
}
152-
153140
impl Cyclomatic for CppCode {
154141
fn compute(node: &Node, stats: &mut Stats) {
155142
use Cpp::*;

src/getter.rs

-28
Original file line numberDiff line numberDiff line change
@@ -236,34 +236,6 @@ impl Getter for RustCode {
236236
}
237237
}
238238

239-
impl Getter for CCode {
240-
fn get_func_space_name<'a>(node: &Node, code: &'a [u8]) -> Option<&'a str> {
241-
// we're in a function_definition so need to get the declarator
242-
if let Some(declarator) = node.child_by_field_name("declarator") {
243-
if let Some(fd) = declarator.first_occurence(|id| C::FunctionDeclarator == id) {
244-
if let Some(first) = fd.child(0) {
245-
if first.kind_id() == C::Identifier {
246-
let code = &code[first.start_byte()..first.end_byte()];
247-
return std::str::from_utf8(code).ok();
248-
}
249-
}
250-
}
251-
}
252-
None
253-
}
254-
255-
fn get_kind(node: &Node) -> NodeKind {
256-
use C::*;
257-
258-
let typ = node.kind_id();
259-
match typ.into() {
260-
FunctionDefinition => NodeKind::Function,
261-
TranslationUnit => NodeKind::Unit,
262-
_ => NodeKind::Unknown,
263-
}
264-
}
265-
}
266-
267239
impl Getter for CppCode {
268240
fn get_func_space_name<'a>(node: &Node, code: &'a [u8]) -> Option<&'a str> {
269241
let typ = node.kind_id();

src/halstead.rs

-24
Original file line numberDiff line numberDiff line change
@@ -280,30 +280,6 @@ impl Halstead for RustCode {
280280
}
281281
}
282282

283-
impl Halstead for CCode {
284-
fn compute<'a>(node: &Node<'a>, code: &'a [u8], stats: &mut Stats<'a>) {
285-
use C::*;
286-
287-
let id = node.kind_id();
288-
289-
match id.into() {
290-
DOT | LPAREN | COMMA | STAR | GTGT | COLON | Return | Break | Continue | If | Else
291-
| Switch | Case | Default | For | While | Goto | Do | EQ | AMPAMP | PIPEPIPE | PLUS
292-
| PLUSPLUS | SLASH | PERCENT | PIPE | AMP | LTLT | TILDE | LT | LTEQ | EQEQ
293-
| BANGEQ | GTEQ | GT | PLUSEQ | BANG | STAREQ | SLASHEQ | PERCENTEQ | GTGTEQ
294-
| LTLTEQ | AMPEQ | CARET | CARETEQ | PIPEEQ | LBRACK | LBRACE | QMARK
295-
| TypeSpecifier | Sizeof => {
296-
*stats.operators.entry(id).or_insert(0) += 1;
297-
}
298-
Identifier | TypeIdentifier | FieldIdentifier | PrimitiveType | StringLiteral
299-
| NumberLiteral | True | False | Null | DOTDOTDOT => {
300-
*stats.operands.entry(get_id(node, code)).or_insert(0) += 1;
301-
}
302-
_ => {}
303-
}
304-
}
305-
}
306-
307283
impl Halstead for CppCode {
308284
fn compute<'a>(node: &Node<'a>, code: &'a [u8], stats: &mut Stats<'a>) {
309285
use Cpp::*;

0 commit comments

Comments
 (0)