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

added support for local decs, plus pretty printing #5

Merged
merged 1 commit into from
Jul 11, 2021
Merged

added support for local decs, plus pretty printing #5

merged 1 commit into from
Jul 11, 2021

Conversation

brandonspark
Copy link
Contributor

@brandonspark brandonspark commented Jul 11, 2021

  • Problem: Currently, there is no support for local declarations. Consider the following program:
local
  val x = 2
in
  val y = x
end

This will cause the following error when parsed:

λ ~/P/parse-sml on main ◦ cat test.sml                    18:58:12
local
  val x = 2
in
  val y = x
end
λ ~/P/parse-sml on main ◦ ./main test.sml                 18:58:14
local
  val x = 2
in
  val y = x
end

Lexing succeeded.
Parsing...

-- ERROR: NOT YET IMPLEMENTED --------------------------- test.sml

Unexpected token.

1| local
   ^^^^^
(TODO: Sam: see Parser.parse.consume_oneDec)
  • Solution: This PR adds in support for local declarations, along with pretty printing for local declarations in the AST. There's also some tests.

Then, we correctly parse as:

λ ~/P/parse-sml on add-local-dec  ./main test.sml         18:59:45
local
  val x = 2
in
  val y = x
end

Lexing succeeded.
Parsing...

local val x = 2 in val y = x end

Parsing succeeded.

@shwestrick shwestrick merged commit c0136e6 into shwestrick:main Jul 11, 2021
@shwestrick
Copy link
Owner

Nice work!! (On this one and the other PRs too!)

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.

2 participants