Merge commit 'f35789006ccbe5be8db21d1a2dd4cc0b5a1286f2'

pull/502/head
Wilfred Hughes 2023-03-15 21:40:59 +07:00
commit b636201a8c
14 changed files with 38882 additions and 38671 deletions

@ -8,7 +8,7 @@ Added support for Ada.
Improved parsing for TOML.
Updated grammar for Bash and Clojure.
Updated grammar for Bash, C and Clojure.
### Display

@ -0,0 +1,33 @@
name: Publish on crates.io
on:
push:
tags:
- v*
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust stable
run: |
rustup toolchain install stable --profile minimal --no-self-update
- name: Verify publish crate
uses: katyo/publish-crates@v1
with:
dry-run: true
- name: Publish crate
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

@ -3,3 +3,4 @@ node_modules
build
package-lock.json
/target/
.build/

@ -1,7 +1,7 @@
[package]
name = "tree-sitter-c"
description = "C grammar for the tree-sitter parsing library"
version = "0.20.1"
version = "0.20.2"
authors = ["Max Brunsfeld <maxbrunsfeld@gmail.com>"]
license = "MIT"
readme = "bindings/rust/README.md"

@ -0,0 +1,36 @@
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "TreeSitterC",
platforms: [.macOS(.v10_13), .iOS(.v11)],
products: [
.library(name: "TreeSitterC", targets: ["TreeSitterC"]),
],
dependencies: [],
targets: [
.target(name: "TreeSitterC",
path: ".",
exclude: [
"binding.gyp",
"bindings",
"Cargo.toml",
"examples",
"grammar.js",
"LICENSE",
"Makefile",
"package.json",
"README.md",
"src/grammar.json",
"src/node-types.json",
],
sources: [
"src/parser.c",
],
resources: [
.copy("queries")
],
publicHeadersPath: "bindings/swift",
cSettings: [.headerSearchPath("src")])
]
)

@ -0,0 +1,16 @@
#ifndef TREE_SITTER_C_H_
#define TREE_SITTER_C_H_
typedef struct TSLanguage TSLanguage;
#ifdef __cplusplus
extern "C" {
#endif
extern TSLanguage *tree_sitter_c();
#ifdef __cplusplus
}
#endif
#endif // TREE_SITTER_C_H_

@ -46,8 +46,8 @@ module.exports = grammar({
[$._type_specifier, $._expression, $.macro_type_specifier],
[$._type_specifier, $.macro_type_specifier],
[$.sized_type_specifier],
[$.attributed_statement],
[$._declaration_modifiers, $.attributed_statement],
[$._declaration_modifiers, $.attributed_non_case_statement],
],
word: $ => $.identifier,
@ -601,17 +601,13 @@ module.exports = grammar({
$._statement
),
attributed_non_case_statement: $ => seq(
repeat1($.attribute_declaration),
$._non_case_statement
),
_statement: $ => choice(
$.case_statement,
$._non_case_statement
),
_non_case_statement: $ => choice(
$.attributed_statement,
$.labeled_statement,
$.compound_statement,
$.expression_statement,
@ -663,7 +659,6 @@ module.exports = grammar({
),
':',
repeat(choice(
alias($.attributed_non_case_statement, $.attributed_statement),
$._non_case_statement,
$.declaration,
$.type_definition
@ -691,10 +686,10 @@ module.exports = grammar({
field('initializer', $.declaration),
seq(field('initializer', optional(choice($._expression, $.comma_expression))), ';')
),
field('condition', optional($._expression)), ';',
field('condition', optional(choice($._expression, $.comma_expression))), ';',
field('update', optional(choice($._expression, $.comma_expression))),
')',
$._statement
field('body', $._statement)
),
return_statement: $ => seq(

@ -1,6 +1,6 @@
{
"name": "tree-sitter-c",
"version": "0.20.1",
"version": "0.20.2",
"description": "C grammar for node-tree-sitter",
"main": "bindings/node",
"keywords": [

@ -3795,22 +3795,6 @@
}
]
},
"attributed_non_case_statement": {
"type": "SEQ",
"members": [
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "attribute_declaration"
}
},
{
"type": "SYMBOL",
"name": "_non_case_statement"
}
]
},
"_statement": {
"type": "CHOICE",
"members": [
@ -3827,6 +3811,10 @@
"_non_case_statement": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "attributed_statement"
},
{
"type": "SYMBOL",
"name": "labeled_statement"
@ -4048,15 +4036,6 @@
"content": {
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "attributed_non_case_statement"
},
"named": true,
"value": "attributed_statement"
},
{
"type": "SYMBOL",
"name": "_non_case_statement"
@ -4198,8 +4177,17 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "SYMBOL",
"name": "comma_expression"
}
]
},
{
"type": "BLANK"
@ -4241,8 +4229,12 @@
"value": ")"
},
{
"type": "SYMBOL",
"name": "_statement"
"type": "FIELD",
"name": "body",
"content": {
"type": "SYMBOL",
"name": "_statement"
}
}
]
},
@ -6584,12 +6576,11 @@
"sized_type_specifier"
],
[
"_declaration_modifiers",
"attributed_statement"
],
[
"_declaration_modifiers",
"attributed_non_case_statement"
"attributed_statement"
]
],
"precedences": [],

@ -175,6 +175,10 @@
"type": "_statement",
"named": true,
"subtypes": [
{
"type": "attributed_statement",
"named": true
},
{
"type": "break_statement",
"named": true
@ -1028,10 +1032,6 @@
"type": "_type_specifier",
"named": true
},
{
"type": "attributed_statement",
"named": true
},
{
"type": "declaration",
"named": true
@ -1203,10 +1203,6 @@
"type": "_type_specifier",
"named": true
},
{
"type": "attributed_statement",
"named": true
},
{
"type": "declaration",
"named": true
@ -1512,6 +1508,16 @@
"type": "for_statement",
"named": true,
"fields": {
"body": {
"multiple": false,
"required": true,
"types": [
{
"type": "_statement",
"named": true
}
]
},
"condition": {
"multiple": false,
"required": false,
@ -1519,6 +1525,10 @@
{
"type": "_expression",
"named": true
},
{
"type": "comma_expression",
"named": true
}
]
},
@ -1554,16 +1564,6 @@
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "_statement",
"named": true
}
]
}
},
{
@ -2297,10 +2297,6 @@
"type": "_type_specifier",
"named": true
},
{
"type": "attributed_statement",
"named": true
},
{
"type": "declaration",
"named": true
@ -2364,10 +2360,6 @@
"type": "_type_specifier",
"named": true
},
{
"type": "attributed_statement",
"named": true
},
{
"type": "declaration",
"named": true
@ -2520,10 +2512,6 @@
"type": "_type_specifier",
"named": true
},
{
"type": "attributed_statement",
"named": true
},
{
"type": "declaration",
"named": true
@ -2612,10 +2600,6 @@
"type": "_type_specifier",
"named": true
},
{
"type": "attributed_statement",
"named": true
},
{
"type": "declaration",
"named": true
@ -2910,10 +2894,6 @@
"type": "_type_specifier",
"named": true
},
{
"type": "attributed_statement",
"named": true
},
{
"type": "declaration",
"named": true

File diff suppressed because it is too large Load Diff

@ -123,6 +123,7 @@ struct TSLanguage {
unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned);
} external_scanner;
const TSStateId *primary_state_ids;
};
/*

@ -117,7 +117,7 @@ void MyFunction(char * __uptr myValue);
right: (identifier))
update: (update_expression
argument: (identifier))
(compound_statement
body: (compound_statement
(expression_statement
(assignment_expression
left: (subscript_expression

@ -43,7 +43,7 @@ int main() {
for (start(); check(); step())
3;
for (i = 0, j = 0, k = 0, l = 0; i < 1; i++, j++, k++, l++)
for (i = 0, j = 0, k = 0, l = 0; i < 1, j < 1; i++, j++, k++, l++)
1;
}
@ -76,9 +76,13 @@ int main() {
(comma_expression
(assignment_expression (identifier) (number_literal))
(assignment_expression (identifier) (number_literal)))))
(binary_expression
(identifier)
(number_literal))
(comma_expression
(binary_expression
(identifier)
(number_literal))
(binary_expression
(identifier)
(number_literal)))
(comma_expression
(update_expression (identifier))
(comma_expression
@ -279,6 +283,10 @@ void f() {
[[a]];
[[a]] label: {}
[[a]] goto label;
// these are c++ specific, but their bind locations should be c-compatible
if (true) [[likely]] {} else [[unlikely]] {}
do [[likely]] {} while (true);
}
---
@ -307,5 +315,12 @@ void f() {
(attributed_statement (attribute_declaration (attribute (identifier))) (expression_statement (identifier)))
(attributed_statement (attribute_declaration (attribute (identifier))) (expression_statement))
(attributed_statement (attribute_declaration (attribute (identifier))) (labeled_statement (statement_identifier) (compound_statement)))
(attributed_statement (attribute_declaration (attribute (identifier))) (goto_statement (statement_identifier))))))
(attributed_statement (attribute_declaration (attribute (identifier))) (goto_statement (statement_identifier)))
(comment)
(if_statement
(parenthesized_expression (true))
(attributed_statement (attribute_declaration (attribute (identifier))) (compound_statement))
(attributed_statement (attribute_declaration (attribute (identifier))) (compound_statement)))
(do_statement
(attributed_statement (attribute_declaration (attribute (identifier))) (compound_statement))
(parenthesized_expression (true))))))