diff --git a/Package.swift b/Package.swift index 495eca7..f0ba6b7 100644 --- a/Package.swift +++ b/Package.swift @@ -33,7 +33,6 @@ let package = Package( ".gitignore", ".gitattributes", ".gitmodules", - ".npmignore", ], sources: [ "src/parser.c", diff --git a/grammar.js b/grammar.js index 529ac27..89a5a29 100644 --- a/grammar.js +++ b/grammar.js @@ -1157,7 +1157,7 @@ module.exports = grammar({ seq(optional(digits), '.', digits, optional(exponent)), seq(digits, exponent), ), - optional(choice(/[Ll]/, /[jJ]/)), + optional(/[jJ]/), )); }, diff --git a/src/grammar.json b/src/grammar.json index c8278da..e4d56a8 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -5999,17 +5999,8 @@ "type": "CHOICE", "members": [ { - "type": "CHOICE", - "members": [ - { - "type": "PATTERN", - "value": "[Ll]" - }, - { - "type": "PATTERN", - "value": "[jJ]" - } - ] + "type": "PATTERN", + "value": "[jJ]" }, { "type": "BLANK" diff --git a/src/parser.c b/src/parser.c index 28ed64b..351f202 100644 --- a/src/parser.c +++ b/src/parser.c @@ -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 @@ -9273,18 +9272,14 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == 'E' || lookahead == 'e') ADVANCE(27); if (lookahead == 'J' || - lookahead == 'L' || - lookahead == 'j' || - lookahead == 'l') ADVANCE(145); + lookahead == 'j') ADVANCE(145); if (('0' <= lookahead && lookahead <= '9')) ADVANCE(146); END_STATE(); case 147: ACCEPT_TOKEN(sym_float); if (lookahead == '_') ADVANCE(149); if (lookahead == 'J' || - lookahead == 'L' || - lookahead == 'j' || - lookahead == 'l') ADVANCE(145); + lookahead == 'j') ADVANCE(145); if (('0' <= lookahead && lookahead <= '9')) ADVANCE(147); END_STATE(); case 148: @@ -9292,17 +9287,13 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == 'E' || lookahead == 'e') ADVANCE(27); if (lookahead == 'J' || - lookahead == 'L' || - lookahead == 'j' || - lookahead == 'l') ADVANCE(145); + lookahead == 'j') ADVANCE(145); if (('0' <= lookahead && lookahead <= '9')) ADVANCE(146); END_STATE(); case 149: ACCEPT_TOKEN(sym_float); if (lookahead == 'J' || - lookahead == 'L' || - lookahead == 'j' || - lookahead == 'l') ADVANCE(145); + lookahead == 'j') ADVANCE(145); if (('0' <= lookahead && lookahead <= '9')) ADVANCE(147); END_STATE(); case 150: @@ -132835,10 +132826,12 @@ unsigned tree_sitter_python_external_scanner_serialize(void *, char *); void tree_sitter_python_external_scanner_deserialize(void *, const char *, unsigned); #ifdef _WIN32 -#define extern __declspec(dllexport) +#define TS_PUBLIC __declspec(dllexport) +#else +#define TS_PUBLIC __attribute__((visibility("default"))) #endif -extern const TSLanguage *tree_sitter_python(void) { +TS_PUBLIC const TSLanguage *tree_sitter_python() { static const TSLanguage language = { .version = LANGUAGE_VERSION, .symbol_count = SYMBOL_COUNT, diff --git a/src/tree_sitter/alloc.h b/src/tree_sitter/alloc.h index 1f7610a..1f4466d 100644 --- a/src/tree_sitter/alloc.h +++ b/src/tree_sitter/alloc.h @@ -9,19 +9,13 @@ extern "C" { #include #include -#ifdef _WIN32 -#define TS_PUBLIC __declspec(dllexport) -#else -#define TS_PUBLIC __attribute__((visibility("default"))) -#endif - -TS_PUBLIC extern void *(*ts_current_malloc)(size_t); -TS_PUBLIC extern void *(*ts_current_calloc)(size_t, size_t); -TS_PUBLIC extern void *(*ts_current_realloc)(void *, size_t); -TS_PUBLIC extern void (*ts_current_free)(void *); - // Allow clients to override allocation functions -#ifdef TS_REUSE_ALLOCATOR +#ifdef TREE_SITTER_REUSE_ALLOCATOR + +extern void *(*ts_current_malloc)(size_t); +extern void *(*ts_current_calloc)(size_t, size_t); +extern void *(*ts_current_realloc)(void *, size_t); +extern void (*ts_current_free)(void *); #ifndef ts_malloc #define ts_malloc ts_current_malloc diff --git a/src/tree_sitter/array.h b/src/tree_sitter/array.h index 4596924..186ba67 100644 --- a/src/tree_sitter/array.h +++ b/src/tree_sitter/array.h @@ -15,10 +15,7 @@ extern "C" { #ifdef _MSC_VER #pragma warning(disable : 4101) -#elif defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-variable" -#elif defined(__GNUC__) +#elif defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" #endif @@ -109,9 +106,13 @@ extern "C" { #define array_assign(self, other) \ _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self)) +/// Swap one array with another #define array_swap(self, other) \ _array__swap((Array *)(self), (Array *)(other)) +/// Get the size of the array contents +#define array_elem_size(self) (sizeof *(self)->contents) + /// Search a sorted array for a given `needle` value, using the given `compare` /// callback to determine the order. /// @@ -128,7 +129,7 @@ extern "C" { /// /// See also `array_search_sorted_with`. #define array_search_sorted_by(self, field, needle, _index, _exists) \ - _array__search_sorted(self, 0, compare_int, field, needle, _index, _exists) + _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists) /// Insert a given `value` into a sorted array, using the given `compare` /// callback to determine the order. @@ -154,8 +155,6 @@ extern "C" { typedef Array(void) Array; -#define array_elem_size(self) sizeof(*(self)->contents) - /// This is not what you're looking for, see `array_delete`. static inline void _array__delete(Array *self) { if (self->contents) { @@ -273,13 +272,11 @@ static inline void _array__splice(Array *self, size_t element_size, /// Helper macro for the `_sorted_by` routines below. This takes the left (existing) /// parameter by reference in order to work with the generic sorting function above. -#define compare_int(a, b) ((int)*(a) - (int)(b)) +#define _compare_int(a, b) ((int)*(a) - (int)(b)) #ifdef _MSC_VER #pragma warning(default : 4101) -#elif defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) +#elif defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif diff --git a/test/corpus/literals.txt b/test/corpus/literals.txt index 0d844e3..a0ee2d9 100644 --- a/test/corpus/literals.txt +++ b/test/corpus/literals.txt @@ -60,8 +60,6 @@ Floats 1_1. 1e+3_4j .3e1_4 -1_0.l -.1l -------------------------------------------------------------------------------- @@ -82,10 +80,6 @@ Floats (float)) (expression_statement (float)) - (expression_statement - (float)) - (expression_statement - (float)) (expression_statement (float)))