Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'tree-sitter:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky authored Mar 16, 2024
2 parents 989a3b3 + 5e62fbb commit b882ba0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
5 changes: 3 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ module.exports = grammar({
/[0-7]{1,3}/,
/x[0-9a-fA-F]{2}/,
/u[0-9a-fA-F]{4}/,
/u{[0-9a-fA-F]+}/
/u\{[0-9a-fA-F]+\}/
))),

null_literal: _ => 'null',
Expand Down Expand Up @@ -512,7 +512,8 @@ module.exports = grammar({
seq(
$._unannotated_type,
choice($.identifier, $._reserved_identifier)
)),
)
),

underscore_pattern: $ => '_',

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"nan": "^2.14.1"
},
"devDependencies": {
"tree-sitter-cli": "^0.20.6"
"tree-sitter-cli": "^0.21.0"
},
"scripts": {
"build": "tree-sitter generate && node-gyp rebuild",
Expand All @@ -34,6 +34,9 @@
"scope": "source.java",
"file-types": [
"java"
],
"highlights": [
"queries/highlights.scm"
]
}
]
Expand Down
8 changes: 6 additions & 2 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
; Variables

(identifier) @variable

; Methods

(package_declaration
Expand Down Expand Up @@ -79,12 +83,12 @@
(void_type)
] @type.builtin

; Variables
; Constants

((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z\\d_]+$"))

(identifier) @variable
; Builtins

(this) @variable.builtin

Expand Down
3 changes: 1 addition & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@
},
{
"type": "PATTERN",
"value": "u{[0-9a-fA-F]+}"
"value": "u\\{[0-9a-fA-F]+\\}"
}
]
}
Expand Down Expand Up @@ -7960,4 +7960,3 @@
"module_directive"
]
}

7 changes: 4 additions & 3 deletions src/parser.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <tree_sitter/parser.h>

#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif

Expand Down Expand Up @@ -78980,10 +78979,12 @@ static const TSParseActionEntry ts_parse_actions[] = {
extern "C" {
#endif
#ifdef _WIN32
#define extern __declspec(dllexport)
#define TS_PUBLIC __declspec(dllexport)
#else
#define TS_PUBLIC __attribute__((visibility("default")))
#endif

extern const TSLanguage *tree_sitter_java(void) {
TS_PUBLIC const TSLanguage *tree_sitter_java() {
static const TSLanguage language = {
.version = LANGUAGE_VERSION,
.symbol_count = SYMBOL_COUNT,
Expand Down
7 changes: 7 additions & 0 deletions src/tree_sitter/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,16 @@ struct TSLanguage {
* Lexer Macros
*/

#ifdef _MSC_VER
#define UNUSED __pragma(warning(suppress : 4101))
#else
#define UNUSED __attribute__((unused))
#endif

#define START_LEXER() \
bool result = false; \
bool skip = false; \
UNUSED \
bool eof = false; \
int32_t lookahead; \
goto start; \
Expand Down

0 comments on commit b882ba0

Please sign in to comment.