Skip to content

Commit cf5b92e

Browse files
committed
Update upstream patches
1 parent 5a7fa76 commit cf5b92e

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

codee/patches/0020-Allow-to-parse-macro-identifiers-in-variable-decls.patch

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Subject: Allow to parse macro identifiers in variable decls
55

66
---
77
grammar.js | 2 +
8-
src/scanner.c | 128 +++++++++++++++++++++++++++++++++++++++-----------
9-
2 files changed, 103 insertions(+), 27 deletions(-)
8+
src/scanner.c | 141 +++++++++++++++++++++++++++++++++++++++++---------
9+
2 files changed, 119 insertions(+), 24 deletions(-)
1010

1111
diff --git a/grammar.js b/grammar.js
1212
index 6e79004..40ac8b7 100644
@@ -29,7 +29,7 @@ index 6e79004..40ac8b7 100644
2929
optional(seq(',',
3030
commaSep1(
3131
diff --git a/src/scanner.c b/src/scanner.c
32-
index b768d99..e477df4 100644
32+
index b768d99..e5a37ee 100644
3333
--- a/src/scanner.c
3434
+++ b/src/scanner.c
3535
@@ -1,4 +1,5 @@
@@ -65,10 +65,23 @@ index b768d99..e477df4 100644
6565
+// Returns NULL on error, otherwise an allocated char array for an identifier
6666
+static String *scan_identifier(TSLexer *lexer) {
6767
if (!iswalpha(lexer->lookahead)) {
68+
- return false;
6869
+ return NULL;
69-
+ }
70+
}
71+
-
72+
- lexer->result_symbol = STRING_LITERAL_KIND;
73+
-
74+
- // We need two characters of lookahead to see `_"`
75+
- char current_char = '\0';
76+
-
7077
+ String *possible_identifier = ts_calloc(1, sizeof(String));
71-
+ while (is_identifier_char(lexer->lookahead) && !lexer->eof(lexer)) {
78+
while (is_identifier_char(lexer->lookahead) && !lexer->eof(lexer)) {
79+
- current_char = lexer->lookahead;
80+
- // Don't capture the trailing underscore as part of the kind identifier
81+
- if (lexer->lookahead == '_') {
82+
- lexer->mark_end(lexer);
83+
- }
84+
- advance(lexer);
7285
+ array_push(possible_identifier, lexer->lookahead);
7386
+ // Don't capture the trailing underscore as part of the kind identifier
7487
+ // If another user of this function wants to mark the end again after
@@ -91,32 +104,16 @@ index b768d99..e477df4 100644
91104
+static bool scan_string_literal_kind(TSLexer *lexer, String *identifier) {
92105
+ if (identifier->size == 0) {
93106
+ return false;
94-
+ }
95-
+
107+
}
108+
109+
- if ((current_char != '_') || (lexer->lookahead != '"' && lexer->lookahead != '\'')) {
96110
+ char last_char = identifier->contents[identifier->size - 1];
97111
+ if ((last_char != '_') ||
98112
+ (lexer->lookahead != '"' && lexer->lookahead != '\'')) {
99113
return false;
100114
}
101115

102-
lexer->result_symbol = STRING_LITERAL_KIND;
103-
-
104-
- // We need two characters of lookahead to see `_"`
105-
- char current_char = '\0';
106-
-
107-
- while (is_identifier_char(lexer->lookahead) && !lexer->eof(lexer)) {
108-
- current_char = lexer->lookahead;
109-
- // Don't capture the trailing underscore as part of the kind identifier
110-
- if (lexer->lookahead == '_') {
111-
- lexer->mark_end(lexer);
112-
- }
113-
- advance(lexer);
114-
- }
115-
-
116-
- if ((current_char != '_') || (lexer->lookahead != '"' && lexer->lookahead != '\'')) {
117-
- return false;
118-
- }
119-
-
116+
+ lexer->result_symbol = STRING_LITERAL_KIND;
120117
return true;
121118
}
122119

0 commit comments

Comments
 (0)