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

Introducing locator functionality to AST #28

Merged
merged 24 commits into from
Jan 31, 2022

Conversation

nikololiahim
Copy link
Member

@nikololiahim nikololiahim commented Jan 24, 2022

Initially, this pull request was intended to introduce identifiers with locators (^.^.^.apple, $.self). However several other things have to be done before this:

  1. In order to test and debug the implementation, we need a working pretty-printer.
  2. Existing pretty-printer had some issues that needed to be fixed.
  3. In order to correctly pretty print some AST arrangements, parser needs to recognize single-line abstractions.

What was done:

  1. Explicit locator chains are parsed into EOSimpleAppWithLocator. For example, EO code ^.^.^.a gets parsed into:
EOSimpleAppWithLocator("a", 3)

Previously, such expressions were parsed as:

EODot(EODot(EODot(EOSimpleApp("^"), "^"), "^"), "a")
  1. We created an algorithm for replacing plain EOSimpleApps with EOSimpleAppWithLocators. The following code without locators:
[] > obj
  [self] > method
    self > @
  [method] > shadowedMethod
    method > @
  [] > notShadowedMethod
    method > @

[] > notShadowedObj
  obj > @
  
[] > shadowedObj
  [obj] > method
    [] > innerMethod
      obj > @
    obj > @

[] > outer
  [] > self
    256 > magic
    [] > dummy
      [outer] > dummyMethod
        outer > @
      outer.self > @
    self "yahoo" > @
  [self] > method
    self.magic > @

gets turned into the following code with locators:

[] > obj
  [self] > method
    $.self > @
  [method] > shadowedMethod
    $.method > @
  [] > notShadowedMethod
    ^.method > @
[] > notShadowedObj
  ^.obj > @
[] > shadowedObj
  [obj] > method
    [] > innerMethod
      ^.obj > @
    $.obj > @
[] > outer
  [] > self
    256 > magic
    [] > dummy
      [outer] > dummyMethod
        $.outer > @
      ^.^.^.outer.self > @
    ^.self > @
      "yahoo"
  [self] > method
    $.self.magic > @
  1. Existing tests were adapted and extended. The most prominent one is that the property:
ast->toEO == ast->toEO->parsed->toEO

now holds for both the parsed and pretty-printer.

@fizruk fizruk merged commit 7937c84 into polystat:master Jan 31, 2022
@nikololiahim
Copy link
Member Author

@fizruk I have updated this PR's message.

@nikololiahim nikololiahim deleted the introduce_locators branch February 2, 2022 12:10
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.

3 participants