Skip to content

Commit f015235

Browse files
committed
Merge branch 'master' into codee
2 parents 210a9dc + ca6c338 commit f015235

8 files changed

Lines changed: 100 additions & 23 deletions

codee/patches/0004-Unhide-end_of_statement.patch

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Subject: Unhide `end_of_statement`
88
test/corpus/constructs.txt | 482 +++++++++++-----
99
test/corpus/cudafortran.txt | 26 +-
1010
test/corpus/expressions.txt | 262 +++++++--
11-
test/corpus/line_continuations.txt | 86 ++-
11+
test/corpus/line_continuations.txt | 93 +++-
1212
test/corpus/preprocessor.txt | 259 ++++++---
1313
test/corpus/regressions.txt | 68 ++-
1414
test/corpus/statements.txt | 846 +++++++++++++++++++++++------
15-
8 files changed, 1606 insertions(+), 497 deletions(-)
15+
8 files changed, 1611 insertions(+), 499 deletions(-)
1616

1717
diff --git a/grammar.js b/grammar.js
1818
index 1289710..6d39d36 100644
@@ -2832,7 +2832,7 @@ index cf7f6c4..8545f3d 100644
28322832
+ (end_program_statement
28332833
+ (end_of_statement))))
28342834
diff --git a/test/corpus/line_continuations.txt b/test/corpus/line_continuations.txt
2835-
index c30265a..a3ebedb 100644
2835+
index 952ef1e..5e64143 100644
28362836
--- a/test/corpus/line_continuations.txt
28372837
+++ b/test/corpus/line_continuations.txt
28382838
@@ -13,7 +13,8 @@ end program
@@ -3080,14 +3080,34 @@ index c30265a..a3ebedb 100644
30803080
(variable_declaration
30813081
(intrinsic_type)
30823082
(init_declarator
3083-
@@ -300,5 +340,7 @@ end program test
3083+
@@ -300,8 +340,10 @@ end program test
30843084
(number_literal)
30853085
(number_literal)
30863086
(number_literal))))
30873087
+ (end_of_statement)
30883088
(end_program_statement
30893089
- (name))))
30903090
+ (name)
3091+
+ (end_of_statement))))
3092+
3093+
================================================================================
3094+
Line continuation as part of string
3095+
@@ -316,11 +358,14 @@ end program main
3096+
(translation_unit
3097+
(program
3098+
(program_statement
3099+
- (name))
3100+
+ (name)
3101+
+ (end_of_statement))
3102+
(comment)
3103+
(print_statement
3104+
(format_identifier)
3105+
(output_item_list
3106+
(string_literal)))
3107+
+ (end_of_statement)
3108+
(end_program_statement
3109+
- (name))))
3110+
+ (name)
30913111
+ (end_of_statement))))
30923112
diff --git a/test/corpus/preprocessor.txt b/test/corpus/preprocessor.txt
30933113
index a42ff39..5f3811a 100644

codee/patches/0005-Consume-end_of_statement.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ they can also be consumed as `comment` tokens).
1313
1 file changed, 4 insertions(+), 4 deletions(-)
1414

1515
diff --git a/src/scanner.c b/src/scanner.c
16-
index 0b4caef..10a22d7 100644
16+
index 4a735f7..be574ae 100644
1717
--- a/src/scanner.c
1818
+++ b/src/scanner.c
1919
@@ -226,7 +226,7 @@ static bool scan_end_of_statement(Scanner *scanner, TSLexer *lexer) {

codee/patches/0013-Stop-parsing-continuation-lines-in-number-literals.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ explicitly.
1414
3 files changed, 58 insertions(+), 39 deletions(-)
1515

1616
diff --git a/src/scanner.c b/src/scanner.c
17-
index 10a22d7..b768d99 100644
17+
index be574ae..9007f34 100644
1818
--- a/src/scanner.c
1919
+++ b/src/scanner.c
2020
@@ -19,6 +19,16 @@ typedef struct {
@@ -123,7 +123,7 @@ index 10a22d7..b768d99 100644
123123
}
124124
lexer->result_symbol = FLOAT_LITERAL;
125125
}
126-
@@ -432,8 +444,13 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
126+
@@ -433,8 +445,13 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
127127
if (valid_symbols[INTEGER_LITERAL] || valid_symbols[FLOAT_LITERAL] ||
128128
valid_symbols[BOZ_LITERAL]) {
129129
// extract out root number from expression
@@ -183,7 +183,7 @@ index 7316d3b..1b23f9a 100644
183183
(end_of_statement)
184184
(end_program_statement
185185
diff --git a/test/corpus/line_continuations.txt b/test/corpus/line_continuations.txt
186-
index a3ebedb..c086fe8 100644
186+
index 5e64143..fbf4084 100644
187187
--- a/test/corpus/line_continuations.txt
188188
+++ b/test/corpus/line_continuations.txt
189189
@@ -339,7 +339,8 @@ end program test

codee/patches/0016-Allow-to-parse-macro-identifiers.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ index d40361e..9685d86 100644
4545

4646
parenthesized_expression: $ => seq(
4747
diff --git a/src/scanner.c b/src/scanner.c
48-
index b768d99..e5a37ee 100644
48+
index 9007f34..2c348ff 100644
4949
--- a/src/scanner.c
5050
+++ b/src/scanner.c
5151
@@ -1,4 +1,5 @@
@@ -133,7 +133,7 @@ index b768d99..e5a37ee 100644
133133
return true;
134134
}
135135

136-
@@ -393,6 +413,33 @@ static bool scan_string_literal(TSLexer *lexer) {
136+
@@ -394,6 +414,33 @@ static bool scan_string_literal(TSLexer *lexer) {
137137
return false;
138138
}
139139

@@ -167,7 +167,7 @@ index b768d99..e5a37ee 100644
167167
/// Need an external scanner to catch '!' before its parsed as a comment
168168
static bool scan_preproc_unary_operator(TSLexer *lexer) {
169169
const char next_char = lexer->lookahead;
170-
@@ -467,19 +514,57 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
170+
@@ -468,19 +515,57 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
171171
return true;
172172
}
173173

@@ -229,7 +229,7 @@ index b768d99..e5a37ee 100644
229229
}
230230

231231
bool tree_sitter_fortran_external_scanner_scan(void *payload, TSLexer *lexer,
232-
@@ -491,8 +576,9 @@ bool tree_sitter_fortran_external_scanner_scan(void *payload, TSLexer *lexer,
232+
@@ -492,8 +577,9 @@ bool tree_sitter_fortran_external_scanner_scan(void *payload, TSLexer *lexer,
233233
unsigned tree_sitter_fortran_external_scanner_serialize(void *payload,
234234
char *buffer) {
235235
Scanner *scanner = (Scanner *)payload;
@@ -241,7 +241,7 @@ index b768d99..e5a37ee 100644
241241
}
242242

243243
void tree_sitter_fortran_external_scanner_deserialize(void *payload,
244-
@@ -500,11 +586,18 @@ void tree_sitter_fortran_external_scanner_deserialize(void *payload,
244+
@@ -501,11 +587,18 @@ void tree_sitter_fortran_external_scanner_deserialize(void *payload,
245245
unsigned length) {
246246
Scanner *scanner = (Scanner *)payload;
247247
if (length > 0) {

codee/patches/0017-Unhide-_string_literal.patch

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Subject: Unhide `_string_literal`
77
grammar.js | 15 +--
88
test/corpus/constructs.txt | 24 +++--
99
test/corpus/expressions.txt | 136 +++++++++++++++++++++++-----
10-
test/corpus/line_continuations.txt | 33 ++++---
10+
test/corpus/line_continuations.txt | 36 +++++---
1111
test/corpus/preprocessor.txt | 9 +-
1212
test/corpus/regressions.txt | 33 ++++---
1313
test/corpus/statements.txt | 141 +++++++++++++++++++----------
14-
7 files changed, 282 insertions(+), 109 deletions(-)
14+
7 files changed, 284 insertions(+), 110 deletions(-)
1515

1616
diff --git a/grammar.js b/grammar.js
1717
index 9685d86..bdfa3d6 100644
@@ -395,7 +395,7 @@ index 29eacb4..870a02e 100644
395395
+ (end_subroutine_statement
396396
+ (end_of_statement))))
397397
diff --git a/test/corpus/line_continuations.txt b/test/corpus/line_continuations.txt
398-
index c086fe8..ba12587 100644
398+
index fbf4084..caa7bf2 100644
399399
--- a/test/corpus/line_continuations.txt
400400
+++ b/test/corpus/line_continuations.txt
401401
@@ -18,10 +18,12 @@ end program
@@ -474,6 +474,16 @@ index c086fe8..ba12587 100644
474474
(end_of_statement)
475475
(end_program_statement
476476
(end_of_statement))))
477+
@@ -365,7 +376,8 @@ end program main
478+
(print_statement
479+
(format_identifier)
480+
(output_item_list
481+
- (string_literal)))
482+
+ (prefixed_string_literal
483+
+ (string_literal))))
484+
(end_of_statement)
485+
(end_program_statement
486+
(name)
477487
diff --git a/test/corpus/preprocessor.txt b/test/corpus/preprocessor.txt
478488
index b0b35bd..ea589be 100644
479489
--- a/test/corpus/preprocessor.txt

codee/patches/0019-Parse-whitespaces.patch

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Subject: Parse whitespaces
99
test/corpus/constructs.txt | 810 +++++++++++++-
1010
test/corpus/cudafortran.txt | 39 +-
1111
test/corpus/expressions.txt | 675 ++++++++++-
12-
test/corpus/line_continuations.txt | 117 +-
12+
test/corpus/line_continuations.txt | 124 ++-
1313
test/corpus/preprocessor.txt | 339 +++++-
1414
test/corpus/regressions.txt | 140 ++-
1515
test/corpus/statements.txt | 1660 +++++++++++++++++++++++++++-
16-
9 files changed, 3744 insertions(+), 83 deletions(-)
16+
9 files changed, 3751 insertions(+), 83 deletions(-)
1717

1818
diff --git a/grammar.js b/grammar.js
1919
index c8ce7d9..a546930 100644
@@ -52,7 +52,7 @@ index c8ce7d9..a546930 100644
5252
$._external_end_of_statement,
5353
),
5454
diff --git a/src/scanner.c b/src/scanner.c
55-
index e5a37ee..5fabf79 100644
55+
index 2c348ff..fc1b6bd 100644
5656
--- a/src/scanner.c
5757
+++ b/src/scanner.c
5858
@@ -15,6 +15,7 @@ enum TokenType {
@@ -63,7 +63,7 @@ index e5a37ee..5fabf79 100644
6363
};
6464

6565
typedef Array(char *) StringArray;
66-
@@ -451,10 +452,28 @@ static bool scan_preproc_unary_operator(TSLexer *lexer) {
66+
@@ -452,10 +453,28 @@ static bool scan_preproc_unary_operator(TSLexer *lexer) {
6767
return false;
6868
}
6969

@@ -95,7 +95,7 @@ index e5a37ee..5fabf79 100644
9595
}
9696

9797
// Close the current statement if we can
98-
@@ -468,6 +487,16 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
98+
@@ -469,6 +488,16 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
9999
// statements, so we should eat all whitespace including
100100
// newlines, until we come to something more interesting
101101
while (iswspace(lexer->lookahead)) {
@@ -4437,7 +4437,7 @@ index 870a02e..c4b4bfe 100644
44374437
(number_literal)
44384438
(string_literal)))
44394439
diff --git a/test/corpus/line_continuations.txt b/test/corpus/line_continuations.txt
4440-
index ba12587..32739bf 100644
4440+
index caa7bf2..440f58e 100644
44414441
--- a/test/corpus/line_continuations.txt
44424442
+++ b/test/corpus/line_continuations.txt
44434443
@@ -13,23 +13,34 @@ end program
@@ -4760,7 +4760,7 @@ index ba12587..32739bf 100644
47604760
(end_of_statement))))
47614761

47624762
================================================================================
4763-
@@ -338,21 +437,35 @@ end program test
4763+
@@ -338,22 +437,36 @@ end program test
47644764
(translation_unit
47654765
(program
47664766
(program_statement
@@ -4794,6 +4794,30 @@ index ba12587..32739bf 100644
47944794
(end_of_statement)
47954795
(end_program_statement
47964796
+ (whitespace)
4797+
+ (whitespace)
4798+
(name)
4799+
(end_of_statement))))
4800+
4801+
@@ -370,15 +483,22 @@ end program main
4802+
(translation_unit
4803+
(program
4804+
(program_statement
4805+
+ (whitespace)
4806+
(name)
4807+
(end_of_statement))
4808+
+ (whitespace)
4809+
(comment)
4810+
+ (whitespace)
4811+
(print_statement
4812+
+ (whitespace)
4813+
(format_identifier)
4814+
+ (whitespace)
4815+
(output_item_list
4816+
(prefixed_string_literal
4817+
(string_literal))))
4818+
(end_of_statement)
4819+
(end_program_statement
4820+
+ (whitespace)
47974821
+ (whitespace)
47984822
(name)
47994823
(end_of_statement))))

src/scanner.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ static bool scan_string_literal(TSLexer *lexer) {
389389
advance(lexer);
390390
}
391391
}
392+
continue;
392393
}
393394

394395
// If we hit the same kind of quote that opened this literal,

test/corpus/line_continuations.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,3 +469,25 @@ end program test
469469
(whitespace)
470470
(name)
471471
(end_of_statement))))
472+
473+
================================================================================
474+
Line continuation as part of string
475+
================================================================================
476+
program main
477+
! This should print "I like fish&chips"
478+
print *, "I like fish&&
479+
&chips"
480+
end program main
481+
--------------------------------------------------------------------------------
482+
483+
(translation_unit
484+
(program
485+
(program_statement
486+
(name))
487+
(comment)
488+
(print_statement
489+
(format_identifier)
490+
(output_item_list
491+
(string_literal)))
492+
(end_program_statement
493+
(name))))

0 commit comments

Comments
 (0)