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

Implicitly return Parser instances #164

Closed
Bikossor opened this issue Aug 7, 2022 · 0 comments · Fixed by #165
Closed

Implicitly return Parser instances #164

Bikossor opened this issue Aug 7, 2022 · 0 comments · Fixed by #165
Assignees
Labels
core: combinators Anything related to combinators core: parsers Anything related to parsers refactor
Milestone

Comments

@Bikossor
Copy link
Owner

Bikossor commented Aug 7, 2022

In some parsers and combinators (optional, lazy and failure) the Parser instance is returned explicitly. This differs from the usual implementation of using a concise body syntax (implicit return).

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#function_body

Before:

export const lazy = (parserThunk: () => Parser): Parser => {
  return new Parser(state => {
    return parserThunk().transformState(state);
  });
};

After:

export const lazy = (parserThunk: () => Parser): Parser =>
  new Parser(state => {
    return parserThunk().transformState(state);
  });
@Bikossor Bikossor added core: parsers Anything related to parsers core: combinators Anything related to combinators refactor labels Aug 7, 2022
@Bikossor Bikossor added this to the Rudus v1.0.0 milestone Aug 7, 2022
@Bikossor Bikossor self-assigned this Aug 7, 2022
@Bikossor Bikossor linked a pull request Aug 7, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core: combinators Anything related to combinators core: parsers Anything related to parsers refactor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant