tree-sitter-c
Advanced tools
Comparing version 0.20.4 to 0.20.5
# tree-sitter-c | ||
This crate provides a C grammar for the [tree-sitter][] parsing library. To | ||
This crate provides a C grammar for the [tree-sitter][] parsing library. To | ||
use this crate, add it to the `[dependencies]` section of your `Cargo.toml` | ||
file. (Note that you will probably also need to depend on the | ||
file. (Note that you will probably also need to depend on the | ||
[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful | ||
way.) | ||
``` toml | ||
```toml | ||
[dependencies] | ||
tree-sitter = "0.17" | ||
tree-sitter-c = "0.16" | ||
tree-sitter = "0.20.10" | ||
tree-sitter-c = "0.20.5" | ||
``` | ||
@@ -18,3 +18,3 @@ | ||
``` rust | ||
```rust | ||
let code = r#" | ||
@@ -33,3 +33,2 @@ int double(int x) { | ||
[Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html | ||
[language func]: https://docs.rs/tree-sitter-c/*/tree_sitter_c/fn.language.html | ||
@@ -36,0 +35,0 @@ [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html |
@@ -60,4 +60,2 @@ /** | ||
[$._type_specifier, $._declarator, $.macro_type_specifier], | ||
[$._type_specifier, $._expression], | ||
[$._type_specifier, $._expression, $.macro_type_specifier], | ||
[$._type_specifier, $._expression_not_binary], | ||
@@ -67,3 +65,2 @@ [$._type_specifier, $._expression_not_binary, $.macro_type_specifier], | ||
[$.sized_type_specifier], | ||
[$._type_specifier, $.sized_type_specifier], | ||
[$.attributed_statement], | ||
@@ -153,3 +150,3 @@ [$._declaration_modifiers, $.attributed_statement], | ||
preproc_arg: _ => token(prec(-1, /\S([^/\n]|\\\r?\n)*/)), | ||
preproc_arg: _ => token(prec(-1, /\S([^/\n]|\/[^*]|\\\r?\n)*/)), | ||
preproc_directive: _ => /#[ \t]*[a-zA-Z0-9]\w*/, | ||
@@ -239,3 +236,3 @@ | ||
commaSep1(field('declarator', choice( | ||
$._declarator, | ||
seq($._declarator, optional($.gnu_asm_expression)), | ||
$.init_declarator, | ||
@@ -247,2 +244,3 @@ ))), | ||
type_definition: $ => seq( | ||
optional('__extension__'), | ||
'typedef', | ||
@@ -253,2 +251,3 @@ repeat($.type_qualifier), | ||
commaSep1(field('declarator', $._type_declarator)), | ||
repeat($.attribute_specifier), | ||
';', | ||
@@ -439,6 +438,7 @@ ), | ||
function_declarator: $ => prec(1, | ||
function_declarator: $ => prec.right(1, | ||
seq( | ||
field('declarator', $._declarator), | ||
field('parameters', $.parameter_list), | ||
optional($.gnu_asm_expression), | ||
repeat($.attribute_specifier), | ||
@@ -506,3 +506,7 @@ )), | ||
'inline', | ||
'__inline', | ||
'__inline__', | ||
'__forceinline', | ||
'thread_local', | ||
'__thread', | ||
), | ||
@@ -516,2 +520,3 @@ | ||
'__restrict__', | ||
'__extension__', | ||
'_Atomic', | ||
@@ -817,2 +822,3 @@ '_Noreturn', | ||
$.sizeof_expression, | ||
$.alignof_expression, | ||
$.offsetof_expression, | ||
@@ -950,2 +956,7 @@ $.generic_expression, | ||
alignof_expression: $ => prec(PREC.SIZEOF, seq( | ||
choice('__alignof__', '__alignof', '_alignof', 'alignof', '_Alignof'), | ||
seq('(', field('type', $.type_descriptor), ')'), | ||
)), | ||
offsetof_expression: $ => prec(PREC.OFFSETOF, seq( | ||
@@ -1046,3 +1057,3 @@ 'offsetof', | ||
// The compound_statement is added to parse macros taking statements as arguments, e.g. MYFORLOOP(1, 10, i, { foo(i); bar(i); }) | ||
argument_list: $ => seq('(', commaSep(choice($._expression, $.compound_statement)), ')'), | ||
argument_list: $ => seq('(', commaSep(choice(seq(optional('__extension__'), $._expression), $.compound_statement)), ')'), | ||
@@ -1132,4 +1143,5 @@ field_expression: $ => seq( | ||
concatenated_string: $ => seq( | ||
choice($.identifier, $.string_literal), | ||
$.string_literal, | ||
repeat1(choice($.string_literal, $.identifier)), // Identifier is added to parse macros that are strings, like PRIu64 | ||
repeat(choice($.string_literal, $.identifier)), // Identifier is added to parse macros that are strings, like PRIu64 | ||
), | ||
@@ -1136,0 +1148,0 @@ |
{ | ||
"name": "tree-sitter-c", | ||
"version": "0.20.4", | ||
"version": "0.20.5", | ||
"description": "C grammar for node-tree-sitter", | ||
@@ -17,8 +17,8 @@ "main": "bindings/node", | ||
"dependencies": { | ||
"nan": "^2.14.0" | ||
"nan": "^2.17.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.41.0", | ||
"eslint": "^8.46.0", | ||
"eslint-config-google": "^0.14.0", | ||
"tree-sitter-cli": "^0.20.0" | ||
"tree-sitter-cli": "^0.20.8" | ||
}, | ||
@@ -25,0 +25,0 @@ "scripts": { |
# tree-sitter-c | ||
[![Build Status](https://travis-ci.org/tree-sitter/tree-sitter-c.svg?branch=master)](https://travis-ci.org/tree-sitter/tree-sitter-c) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/7u0sy6ajmxro4wfh/branch/master?svg=true)](https://ci.appveyor.com/project/maxbrunsfeld/tree-sitter-c/branch/master) | ||
[![CI](https://github.com/tree-sitter/tree-sitter-c/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-c/actions/workflows/ci.yml) | ||
C grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter). | ||
Adapted from [this C99 grammar](http://slps.github.io/zoo/c/iso-9899-tc3.html). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4943441
13454
24
7
Updatednan@^2.17.0