Skip to content

Commit 5e62fbb

Browse files
committed
fix: unescaped curly brace in regex and invert query precedence for test
1 parent 99b29f1 commit 5e62fbb

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

grammar.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ module.exports = grammar({
203203
/[0-7]{1,3}/,
204204
/x[0-9a-fA-F]{2}/,
205205
/u[0-9a-fA-F]{4}/,
206-
/u{[0-9a-fA-F]+}/
206+
/u\{[0-9a-fA-F]+\}/
207207
))),
208208

209209
null_literal: _ => 'null',
@@ -512,7 +512,8 @@ module.exports = grammar({
512512
seq(
513513
$._unannotated_type,
514514
choice($.identifier, $._reserved_identifier)
515-
)),
515+
)
516+
),
516517

517518
underscore_pattern: $ => '_',
518519

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"nan": "^2.14.1"
1818
},
1919
"devDependencies": {
20-
"tree-sitter-cli": "^0.20.6"
20+
"tree-sitter-cli": "^0.21.0"
2121
},
2222
"scripts": {
2323
"build": "tree-sitter generate && node-gyp rebuild",
@@ -34,6 +34,9 @@
3434
"scope": "source.java",
3535
"file-types": [
3636
"java"
37+
],
38+
"highlights": [
39+
"queries/highlights.scm"
3740
]
3841
}
3942
]

queries/highlights.scm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
; Variables
2+
3+
(identifier) @variable
4+
15
; Methods
26

37
(method_declaration
@@ -50,12 +54,12 @@
5054
(void_type)
5155
] @type.builtin
5256

53-
; Variables
57+
; Constants
5458

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

58-
(identifier) @variable
62+
; Builtins
5963

6064
(this) @variable.builtin
6165

src/grammar.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@
14421442
},
14431443
{
14441444
"type": "PATTERN",
1445-
"value": "u{[0-9a-fA-F]+}"
1445+
"value": "u\\{[0-9a-fA-F]+\\}"
14461446
}
14471447
]
14481448
}
@@ -7873,4 +7873,3 @@
78737873
"module_directive"
78747874
]
78757875
}
7876-

src/parser.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "tree_sitter/parser.h"
22

33
#if defined(__GNUC__) || defined(__clang__)
4-
#pragma GCC diagnostic push
54
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
65
#endif
76

@@ -6858,6 +6857,7 @@ static inline bool sym_identifier_character_set_4(int32_t c) {
68586857

68596858
static bool ts_lex(TSLexer *lexer, TSStateId state) {
68606859
START_LEXER();
6860+
eof = lexer->eof(lexer);
68616861
switch (state) {
68626862
case 0:
68636863
if (eof) ADVANCE(69);
@@ -8125,6 +8125,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
81258125

81268126
static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) {
81278127
START_LEXER();
8128+
eof = lexer->eof(lexer);
81288129
switch (state) {
81298130
case 0:
81308131
if (lookahead == '_') ADVANCE(1);
@@ -78394,10 +78395,12 @@ static const TSParseActionEntry ts_parse_actions[] = {
7839478395
extern "C" {
7839578396
#endif
7839678397
#ifdef _WIN32
78397-
#define extern __declspec(dllexport)
78398+
#define TS_PUBLIC __declspec(dllexport)
78399+
#else
78400+
#define TS_PUBLIC __attribute__((visibility("default")))
7839878401
#endif
7839978402

78400-
extern const TSLanguage *tree_sitter_java(void) {
78403+
TS_PUBLIC const TSLanguage *tree_sitter_java() {
7840178404
static const TSLanguage language = {
7840278405
.version = LANGUAGE_VERSION,
7840378406
.symbol_count = SYMBOL_COUNT,

src/tree_sitter/parser.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,24 @@ struct TSLanguage {
129129
* Lexer Macros
130130
*/
131131

132+
#ifdef _MSC_VER
133+
#define UNUSED __pragma(warning(suppress : 4101))
134+
#else
135+
#define UNUSED __attribute__((unused))
136+
#endif
137+
132138
#define START_LEXER() \
133139
bool result = false; \
134140
bool skip = false; \
141+
UNUSED \
135142
bool eof = false; \
136143
int32_t lookahead; \
137144
goto start; \
138145
next_state: \
139146
lexer->advance(lexer, skip); \
140147
start: \
141148
skip = false; \
142-
lookahead = lexer->lookahead; \
143-
eof = lexer->eof(lexer);
149+
lookahead = lexer->lookahead;
144150

145151
#define ADVANCE(state_value) \
146152
{ \

0 commit comments

Comments
 (0)