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

COPYLESS_GRAMMAR #19

Open
3 tasks
xparq opened this issue Sep 5, 2023 · 0 comments
Open
3 tasks

COPYLESS_GRAMMAR #19

xparq opened this issue Sep 5, 2023 · 0 comments

Comments

@xparq
Copy link
Owner

xparq commented Sep 5, 2023

(This is an umbrella issue to keep all the related information kinda-sorta organized, and allow removing most of the notes from the source.)

Currently disabled; it only made the code more complex and less readable, with all the #ifdefs etc. :-/

  • Should copy it over to a separate branch and mature it out, if at all possible, and free the main branch from its burden.

  • COPYLESS_GRAMMAR for empty rules! The problem is that unlike all the other objects that we just reference in this mode, an empty rule is actually a non-empty PROD vector that we need to create ourselves... somehow...

    A static obj could kinda do, if my ctors could be made constexpr, but std::vector itself is dynamically allocated anyway, and isn't constexpr, I guess...

  • The COPYLESS_GRAMMAR API flavor should refuse to take rvalue objects!

From the header comment, FTR:

!!DO NOT USE THIS:
- #define COPYLESS_GRAMMAR to avoid copying the grammar rules, in case the
  life-cycle management of the source objects is of no concern. (Albeit the
  COPYLESS setup API should refuse to take rvalue objects!)
  Alas, it doesn't really work:
  a) The PRODUCTION constructs are std::vectors, which do copy whatever we put in there...
  b) There's no sane way to define the grammar rules directly using C++ code without a
     plethora of temporaries (to copy)...
  c) And grammars are not very big anyway, so... (It just felt so bad, in general, e.g.
     for heap fragmentation and the churning of dozens of tiny temporary vectors...)
  I seem to have implemented COPYLESS_GRAMMAR for nothing! :)
  Move-construction should be the way to go...
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

No branches or pull requests

1 participant