Skip to content

Commit

Permalink
Bump tree-sitter-preproc to v0.17 (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luni-4 committed Mar 10, 2021
1 parent 9a373ab commit 5717a23
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 231 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -32,7 +32,7 @@ termcolor = "^1.1"

tree-sitter = "^0.17"
tree-sitter-java = "^0.16"
tree-sitter-preproc = { path = "./tree-sitter-preproc", version = "^0.16" }
tree-sitter-preproc = { path = "./tree-sitter-preproc", version = "^0.17" }
tree-sitter-ccomment = { path = "./tree-sitter-ccomment", version = "^0.17" }
tree-sitter-mozcpp = { path = "./tree-sitter-mozcpp", version = "^0.16" }
tree-sitter-mozjs = { path = "./tree-sitter-mozjs", version = "^0.16" }
Expand Down
2 changes: 1 addition & 1 deletion enums/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion enums/Cargo.toml
Expand Up @@ -18,7 +18,7 @@ libc = "^0.2"

tree-sitter = "^0.17"
tree-sitter-java = "^0.16"
tree-sitter-preproc = { path = "../tree-sitter-preproc" }
tree-sitter-preproc = { path = "../tree-sitter-preproc", version = "^0.17" }
tree-sitter-ccomment = { path = "../tree-sitter-ccomment", version = "^0.17" }
tree-sitter-mozcpp = { path = "../tree-sitter-mozcpp" }
tree-sitter-mozjs = { path = "../tree-sitter-mozjs" }
2 changes: 1 addition & 1 deletion tree-sitter-preproc/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "tree-sitter-preproc"
description = "Preproc grammar for the tree-sitter parsing library"
version = "0.16.0"
version = "0.17.0"
authors = ["Calixte Denizet <cdenizet@mozilla.com>"]
license = "MIT"
readme = "bindings/rust/README.md"
Expand Down
21 changes: 13 additions & 8 deletions tree-sitter-preproc/package.json
@@ -1,24 +1,25 @@
{
"name": "tree-sitter-c",
"version": "0.15.2",
"description": "C grammar for node-tree-sitter",
"name": "tree-sitter-preproc",
"version": "0.17.0",
"description": "Preproc grammar for node-tree-sitter",
"main": "index.js",
"keywords": [
"parser",
"lexer"
],
"author": "Max Brunsfeld",
"author": "Calixte Denizet",
"license": "MIT",
"dependencies": {
"nan": "^2.10.0"
"nan": "^2.14.2"
},
"devDependencies": {
"tree-sitter-cli": "^0.15.5"
"tree-sitter-cli": "^0.17.3"
},
"scripts": {
"build": "tree-sitter generate && node-gyp build",
"test": "tree-sitter test && tree-sitter parse examples/* --quiet --time",
"test-windows": "tree-sitter test"
"test-windows": "tree-sitter test",
"install": "node-gyp rebuild"
},
"tree-sitter": [
{
Expand All @@ -27,5 +28,9 @@
"c"
]
}
]
],
"gypfile": true,
"directories": {
"example": "examples"
}
}
2 changes: 1 addition & 1 deletion tree-sitter-preproc/src/grammar.json
Expand Up @@ -351,7 +351,7 @@
},
{
"type": "PATTERN",
"value": "[^*]*\\*+([^\\/*][^*]*\\*+)*"
"value": "[^*]*\\*+([^/*][^*]*\\*+)*"
},
{
"type": "STRING",
Expand Down
4 changes: 4 additions & 0 deletions tree-sitter-preproc/src/node-types.json
Expand Up @@ -364,5 +364,9 @@
{
"type": "preproc_line",
"named": true
},
{
"type": "raw_string_literal",
"named": true
}
]
408 changes: 210 additions & 198 deletions tree-sitter-preproc/src/parser.c

Large diffs are not rendered by default.

53 changes: 34 additions & 19 deletions tree-sitter-preproc/src/tree_sitter/parser.h
Expand Up @@ -35,6 +35,7 @@ typedef uint16_t TSStateId;
typedef struct {
bool visible : 1;
bool named : 1;
bool supertype: 1;
} TSSymbolMetadata;

typedef struct TSLexer TSLexer;
Expand Down Expand Up @@ -62,13 +63,13 @@ typedef struct {
TSStateId state;
bool extra : 1;
bool repetition : 1;
};
} shift;
struct {
TSSymbol symbol;
int16_t dynamic_precedence;
uint8_t child_count;
uint8_t production_id;
};
} reduce;
} params;
TSParseActionType type : 4;
} TSParseAction;
Expand All @@ -83,7 +84,7 @@ typedef union {
struct {
uint8_t count;
bool reusable : 1;
};
} entry;
} TSParseActionEntry;

struct TSLanguage {
Expand Down Expand Up @@ -119,6 +120,8 @@ struct TSLanguage {
const uint16_t *small_parse_table;
const uint32_t *small_parse_table_map;
const TSSymbol *public_symbol_map;
const uint16_t *alias_map;
uint32_t state_count;
};

/*
Expand Down Expand Up @@ -167,22 +170,28 @@ struct TSLanguage {

#define ACTIONS(id) id

#define SHIFT(state_value) \
{ \
{ \
.type = TSParseActionTypeShift, \
.params = {.state = state_value}, \
} \
#define SHIFT(state_value) \
{ \
{ \
.params = { \
.shift = { \
.state = state_value \
} \
}, \
.type = TSParseActionTypeShift \
} \
}

#define SHIFT_REPEAT(state_value) \
{ \
{ \
.type = TSParseActionTypeShift, \
.params = { \
.state = state_value, \
.repetition = true \
.shift = { \
.state = state_value, \
.repetition = true \
} \
}, \
.type = TSParseActionTypeShift \
} \
}

Expand All @@ -194,20 +203,26 @@ struct TSLanguage {
#define SHIFT_EXTRA() \
{ \
{ \
.type = TSParseActionTypeShift, \
.params = {.extra = true} \
.params = { \
.shift = { \
.extra = true \
} \
}, \
.type = TSParseActionTypeShift \
} \
}

#define REDUCE(symbol_val, child_count_val, ...) \
{ \
{ \
.type = TSParseActionTypeReduce, \
.params = { \
.symbol = symbol_val, \
.child_count = child_count_val, \
__VA_ARGS__ \
} \
.reduce = { \
.symbol = symbol_val, \
.child_count = child_count_val, \
__VA_ARGS__ \
}, \
}, \
.type = TSParseActionTypeReduce \
} \
}

Expand Down

0 comments on commit 5717a23

Please sign in to comment.