forked from stadelmanma/tree-sitter-fortran
-
Notifications
You must be signed in to change notification settings - Fork 0
Parse whitespaces #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use
_external_end_of_statement
- Loading branch information
commit 6a17eb8da2174a2d30c3caef718337377046d615
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the addition of
$.whitespaceas an external rule, this change becomes necessary. Otherwise,tree-sitter-fortranfails to recognize newline characters, since they may be consumed silently by the external scanner. The issue is that the external scanner reads tokens directly from the input buffer without checkingvalid_symbols, which is a bug that should be reported upstream. This behavior has made proper whitespace parsing extremely difficult.