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

Grammar based moves parsing #80

Closed
wants to merge 25 commits into from

Conversation

everyonesdesign
Copy link
Owner

@everyonesdesign everyonesdesign commented Feb 2, 2025

A better, more flexible way to parse moves defined by grammar instead of regular expressions

Using Nearley to generate and parse the grammar

TypeScript definitions are manually created

Potentially can unblock things like #74

Concerns

Performance and the bundle size.

Bundle size ✅

Bundle size (master): 116K
Bundle size (feature): 126K

Performance ❌

It seems that the performance with this parsing decreases significantly:

Master
  Execution time (1000 cycles, e): 1.375 ms
  Execution time (1000 cycles, e4): 1.7349999845027924 ms
  Execution time (1000 cycles, e4): 1.3700000047683716 ms
  Execution time (1000 cycles, d): 0.75 ms
  Execution time (1000 cycles, d5): 1.145000010728836 ms
  Execution time (1000 cycles, d5): 1.4149999916553497 ms
  Execution time (1000 cycles, d): 0.6149999797344208 ms
  Execution time (1000 cycles, d5): 1.7850000262260437 ms
  Execution time (1000 cycles, d5): 0.8899999856948853 ms

Feature
  Execution time (1000 cycles, e): 11.324999988079071 ms
  Execution time (1000 cycles, e4): 34.96999999880791 ms
  Execution time (1000 cycles, e4): 38.46999999880791 ms
  Execution time (1000 cycles, d): 5.875 ms
  Execution time (1000 cycles, d5): 25.589999973773956 ms
  Execution time (1000 cycles, d5): 30.680000007152557 ms
  Execution time (1000 cycles, d): 4.925000011920929 ms
  Execution time (1000 cycles, d5): 24.645000010728836 ms
  Execution time (1000 cycles, d5): 25.5 ms

@everyonesdesign everyonesdesign force-pushed the grammar-based-moves-parsing branch from 4a44c6c to 9822e96 Compare February 2, 2025 16:19
@everyonesdesign
Copy link
Owner Author

Closing in favour of #82

Implementation based on Nearley seems to be difficult to maintain and very slow.

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.

1 participant