Frontend prototype: clickable AST/ASR node navigation#129
Open
amritamishra01 wants to merge 4 commits intolfortran:mainfrom
Open
Frontend prototype: clickable AST/ASR node navigation#129amritamishra01 wants to merge 4 commits intolfortran:mainfrom
amritamishra01 wants to merge 4 commits intolfortran:mainfrom
Conversation
Member
|
@certik I am travelling and would be unable to look into this. Would you be able to take a look, please? |
Contributor
Author
Contributor
Author
|
I’ve pushed the latest updates. Please let me know if anything else should be refined. video1.mp4 |
Pranavchiku
reviewed
Feb 25, 2026
components/LoadLFortran.js
Outdated
| lfortran_funcs.emit_ast_from_source = function (source_code) { | ||
| try { return compiler_funcs.emit_ast_from_source(source_code); } | ||
| catch (e) { console.log(e); myPrint(e + "\nERROR: AST could not be generated from the code"); return 0; } | ||
| catch (e) { myPrint(e + "\nERROR: AST could not be generated from the code"); return 0; } |
Member
There was a problem hiding this comment.
Suggested change
| catch (e) { myPrint(e + "\nERROR: AST could not be generated from the code"); return 0; } | |
| catch (e) { CustomPrint(e + "\nERROR: AST could not be generated from the code"); return 0; } |
Pranavchiku
reviewed
Feb 25, 2026
| return compiler_funcs.emit_wasm_from_source(source_code); | ||
| } | ||
| catch (e) { | ||
| console.log(e); |
Pranavchiku
reviewed
Feb 25, 2026
pages/index.js
Outdated
Comment on lines
+139
to
+155
| // Demo 1: Tag "Declaration" covering the integer parameter line (Line 2) | ||
| let finalOutput = htmlOutput.replace("Declaration", | ||
| `<span | ||
| data-start-line="2" data-start-col="5" | ||
| data-end-line="2" data-end-col="73" | ||
| style="color: #1890ff; cursor: pointer; font-weight: bold; text-decoration: underline;" | ||
| >Declaration</span>` | ||
| ); | ||
|
|
||
| // Demo 2: Tag "Subroutine" covering the subroutine definition (Line 9) | ||
| finalOutput = finalOutput.replace("Subroutine", | ||
| `<span | ||
| data-start-line="9" data-start-col="9" | ||
| data-end-line="12" data-end-col="23" | ||
| style="color: #1890ff; cursor: pointer; font-weight: bold; text-decoration: underline;" | ||
| >Subroutine</span>` | ||
| ); |
Member
There was a problem hiding this comment.
I don't see the sense of it. finalOutput gets overwritten.
Pranavchiku
reviewed
Feb 25, 2026
Member
Pranavchiku
left a comment
There was a problem hiding this comment.
this is solid PR, thank you @amritamishra01! Left a few comments.
Contributor
Author
|
Hi @Pranavchiku , |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR implements a frontend prototype for AST/ASR node → source navigation in the playground.
1.Wrapped selected AST nodes (Declaration, Subroutine) with data-line metadata.
2.Added click handler in ResultBox to extract line numbers.
3.Exposed jumpToLine API from the Editor to enable external navigation.
This currently uses hardcoded line numbers for demonstration. The next step would be integrating real location metadata from the backend serializer.
Closes #17
prototype2.mp4