Skip to content
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

Update parser to new scm-slang parser #1584

Merged
merged 25 commits into from
Mar 21, 2024

Conversation

s-kybound
Copy link
Member

@s-kybound s-kybound commented Mar 18, 2024

This update completely converts the scm-slang parser used in js-slang to use the newer version.

This improved parser supports:

  • Full coverage of location data - no more missing location data errors
  • Variadic functions
  • Redefinitions of the same variable within the same scope are now possible
  • Scope repair - begin no longer has its own scope - closer to Scheme behaviour
  • Optimizations - unnecessary begin and sequence IIFE expressions can now be "absorbed" by enclosing functions and scopes, allowing for closer 1-1 behaviour between program and stepper/CSE machine
  • Scheme pair representation is now 1-1 with Source Academy's representation
  • Vectors are now supported
  • Scheme numeric tower has been implemented
  • Parser and Lexer errors have been improved to help in usefulness
  • Datum comments with '#;' are implemented for Quality of Life
  • Promise representation has been improved to follow Scheme - promises can be forced once, and subsequently store the value emitted

Most importantly - the parser now uses an intermediate AST representation, which has allowed us to perform above actions such as optimizations and scope repair. Most importantly, it is the first step for conversion between a full LISP AST and the IR AST used, which will greatly help in the future when implementing macro systems for the scheme implementation.

On js-slang's side, continuation representation now accepts a variadic amount of arguments, which will, in the future, allow us to implement scheme procedures that produce more than 1 value.

Resolves #1408.

Copy link
Member

@martin-henz martin-henz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Nice comments. Great to see the CSE machine in action as a Source Academy runner, including REPL.

@coveralls
Copy link

coveralls commented Mar 19, 2024

Pull Request Test Coverage Report for Build 8372106243

Details

  • 143 of 144 (99.31%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 81.276%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser/scheme/index.ts 30 31 96.77%
Totals Coverage Status
Change from base Build 8353856953: 0.08%
Covered Lines: 10429
Relevant Lines: 12423

💛 - Coveralls

@s-kybound s-kybound marked this pull request as draft March 19, 2024 10:24
@s-kybound s-kybound marked this pull request as ready for review March 20, 2024 04:13
@martin-henz martin-henz merged commit 46317e3 into source-academy:master Mar 21, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scheme: scoping issues
3 participants