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

More Functional Parsing DSL API. #324

Closed
bd82 opened this issue Dec 7, 2016 · 3 comments
Closed

More Functional Parsing DSL API. #324

bd82 opened this issue Dec 7, 2016 · 3 comments
Labels

Comments

@bd82
Copy link
Member

bd82 commented Dec 7, 2016

Some of this was suggested in the past by @Zumbala
#215 (comment)

All the parsing DSL methods should return a value.
Currently this is only true for OR and CONSUME
but it should also be applied to:

  • OPTION
    • Return the value of the implementation function or undefined? if the option was not taken?
  • MANY[_SEP]
    • Return an array of the values return by each iteration of the implementation function. An empty array if no a single iteration happened.
  • AT_LEAST_ONE[_SEP]
    • Same as MANY

The _SEP variants should return two arrays, one of the separator tokens and one of the values.

@bd82 bd82 added the API label Dec 7, 2016
@bd82
Copy link
Member Author

bd82 commented Dec 7, 2016

This may have a slight performance impact, should be measured.

bd82 added a commit that referenced this issue Dec 11, 2016
bd82 added a commit that referenced this issue Dec 11, 2016
relates to #324

Includes some performance Optimizations for *_SEP DSL methods.
bd82 added a commit that referenced this issue Dec 11, 2016
relates to #324

* Includes some performance Optimizations for *_SEP DSL methods.
* Includes updates for performance guidelines docs.
@bd82
Copy link
Member Author

bd82 commented Dec 11, 2016

Performance impact was very small and was mostly mitigated with some optimizations.
worst case measured was about ~4-5% which can be reduced to ~2% if the *_SEP syntactic sugar methods
are not used.

@bd82 bd82 closed this as completed Dec 11, 2016
@bd82
Copy link
Member Author

bd82 commented Dec 11, 2016

Breaking Changes:

This change broke a few APIS:

  • OPTION now returns the value of the inner grammar implementation or undefined otherwise instead of boolean.
  • The *_SEP methods now return an object made up of two arrays, separators and values instead of a single array of separators.

@bd82 bd82 changed the title More Functional Parsing DSL API More Functional Parsing DSL API. Dec 11, 2016
bd82 added a commit that referenced this issue Dec 12, 2016
relates to #324

* Includes some performance Optimizations for *_SEP DSL methods.
* Includes updates for performance guidelines docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant