Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions codee/patches/0003-Add-semantic-accessors.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Subject: Add semantic accessors
test/corpus/expressions.txt | 6 +++---
test/corpus/preprocessor.txt | 8 ++++----
test/corpus/regressions.txt | 2 +-
test/corpus/statements.txt | 8 ++++----
6 files changed, 35 insertions(+), 22 deletions(-)
test/corpus/statements.txt | 10 +++++-----
6 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/grammar.js b/grammar.js
index 4e6a7f1..d0af7b9 100644
Expand Down Expand Up @@ -198,7 +198,7 @@ index fc47bf1..1af946a 100644
left: (call_expression
(identifier)
diff --git a/test/corpus/statements.txt b/test/corpus/statements.txt
index ca8c86e..ad47d68 100644
index ca8c86e..d6bebae 100644
--- a/test/corpus/statements.txt
+++ b/test/corpus/statements.txt
@@ -289,7 +289,7 @@ END PROGRAM
Expand Down Expand Up @@ -237,3 +237,12 @@ index ca8c86e..ad47d68 100644
(allocate_statement
allocation: (sized_allocation
(identifier)
@@ -3499,7 +3499,7 @@ end program
(translation_unit
(program
(program_statement
- (name))
+ name: (name))
(implicit_statement
(none))
(variable_declaration
4 changes: 2 additions & 2 deletions codee/patches/0004-Unhide-end_of_statement.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3918,7 +3918,7 @@ index 1af946a..d6b3f37 100644
+ (name)
+ (end_of_statement))))
diff --git a/test/corpus/statements.txt b/test/corpus/statements.txt
index ad47d68..fe7ec84 100644
index d6bebae..fe7ec84 100644
--- a/test/corpus/statements.txt
+++ b/test/corpus/statements.txt
@@ -34,57 +34,76 @@ end subroutine foo
Expand Down Expand Up @@ -6818,7 +6818,7 @@ index ad47d68..fe7ec84 100644
(translation_unit
(program
(program_statement
- (name))
- name: (name))
+ name: (name)
+ (end_of_statement))
(implicit_statement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Diego Alonso <diego.alonso@appentra.com>
Date: Thu, 26 Jun 2025 14:04:51 +0200
Subject: Allow to parse macro identifiers in variable decls
Subject: Allow to parse macro identifiers

---
grammar.js | 2 +
grammar.js | 4 ++
src/scanner.c | 141 +++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 119 insertions(+), 24 deletions(-)
2 files changed, 121 insertions(+), 24 deletions(-)

diff --git a/grammar.js b/grammar.js
index 6e79004..40ac8b7 100644
index 6e79004..1215588 100644
--- a/grammar.js
+++ b/grammar.js
@@ -67,6 +67,7 @@ module.exports = grammar({
Expand All @@ -28,6 +28,22 @@ index 6e79004..40ac8b7 100644
)),
optional(seq(',',
commaSep1(
@@ -1178,6 +1180,7 @@ module.exports = grammar({
// Not strictly valid, but can catch extensions and preprocessor macros
$.call_expression,
$.include_statement,
+ $.macro_identifier
),

statement_label: $ => prec(1, alias($._integer_literal, 'statement_label')),
@@ -1941,6 +1944,7 @@ module.exports = grammar({
$.implied_do_loop_expression,
$.coarray_expression,
$.conditional_expression,
+ $.macro_identifier
),

parenthesized_expression: $ => seq(
diff --git a/src/scanner.c b/src/scanner.c
index b768d99..e5a37ee 100644
--- a/src/scanner.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Subject: Parse multiline preprocessor comments
2 files changed, 79 insertions(+), 10 deletions(-)

diff --git a/grammar.js b/grammar.js
index 40ac8b7..b5c11d1 100644
index 1215588..c6ffa3b 100644
--- a/grammar.js
+++ b/grammar.js
@@ -75,6 +75,7 @@ module.exports = grammar({
Expand All @@ -30,7 +30,7 @@ index 40ac8b7..b5c11d1 100644

preproc_binary_expression: $ => {
const table = [
@@ -2466,36 +2468,50 @@ function preprocIf(suffix, content, precedence = 0) {
@@ -2468,36 +2470,50 @@ function preprocIf(suffix, content, precedence = 0) {
);
}

Expand Down Expand Up @@ -87,7 +87,7 @@ index 40ac8b7..b5c11d1 100644
field('condition', $._preproc_expression),
field('content', content($)),
field('alternative', optional(alternativeBlock($))),
@@ -2504,7 +2520,7 @@ function preprocIf(suffix, content, precedence = 0) {
@@ -2506,7 +2522,7 @@ function preprocIf(suffix, content, precedence = 0) {
['preproc_elifdef' + suffix]: $ => prec(precedence, seq(
choice(preprocessor('elifdef'), preprocessor('elifndef')),
field('name', $.identifier),
Expand Down

This file was deleted.

48 changes: 48 additions & 0 deletions codee/patches/0023-Use-_external_end_of_statement.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?I=C3=B1aki=20Amatria=20Barral?= <inaki.amatria@appentra.com>
Date: Mon, 27 Oct 2025 15:27:51 +0100
Subject: Use `_external_end_of_statement`

---
grammar.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/grammar.js b/grammar.js
index f1c074f..a19a824 100644
--- a/grammar.js
+++ b/grammar.js
@@ -153,14 +153,14 @@ module.exports = grammar({
$.system_lib_string,
alias($.preproc_call_expression, $.call_expression),
)),
- /\r?\n/,
+ $._external_end_of_statement,
),

preproc_def: $ => seq(
preprocessor('define'),
field('name', $.identifier),
field('value', optional($.preproc_arg)),
- token(prec(1, /\r?\n/)), // force newline to win over preproc_arg
+ $._external_end_of_statement,
),

preproc_function_def: $ => seq(
@@ -168,7 +168,7 @@ module.exports = grammar({
field('name', $.identifier),
field('parameters', $.preproc_params),
field('value', optional($.preproc_arg)),
- token.immediate(/\r?\n/),
+ $._external_end_of_statement,
),

preproc_params: $ => seq(
@@ -178,7 +178,7 @@ module.exports = grammar({
preproc_call: $ => seq(
field('directive', $.preproc_directive),
field('argument', optional($.preproc_arg)),
- token.immediate(/\r?\n/),
+ $._external_end_of_statement,
),

...preprocIf('', $ => repeat($._top_level_item)),
Loading