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

_NAME, _CALL, _GOTO (and/or: _DEF, _USE, ...) #15

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

_NAME, _CALL, _GOTO (and/or: _DEF, _USE, ...) #15

xparq opened this issue Sep 5, 2023 · 0 comments

Comments

@xparq
Copy link
Owner

xparq commented Sep 5, 2023

Well, to avoid the brittle address-tracking horror of #16, a named rule can't pre-register it's this address at construction time, where things are in flux.

At runtime, though:

  • the first time the engine sees a name, it can safely remember its address. (Well, its parent's address, technically, as a _NAME opcode "rule" is always in the PROD of some owner rule -- the real one that the name belongs to.)

    • Well, not really: rules can be copied/created even run-time, so those addresses must be updated then, too! :-/
      • Short of that, only fresh new full searches can provide a reliable association!
        _DEF "name" and _USE "name" have now been implemented, doing just that (72e4508).
  • or, if the first time it sees a branch OP (or other reference to a name), and it can't find it in the name->rule lookup table, it does a full search and updates the table. (Or errs out.)

  • This would also require a preprocessing/compilation stage over the grammar. (It's fully interpreted yet.) -> Grammar preprocessing/compilation phase (after construction, before parsing) #31

    • Which would also imply that a (re)compilation would also be needed for every single run-time change to the grammar!

  • Make a distinction between NAME and LABEL!... Name should really just be the name of a rule... err... but should it also be an ID then?... And LABEL is really any branching (GOTO/CALL) destination... Branching can apply to both names and labels, but not all labels are names! Labels should probably be more indirect, and also support positions (slots) as branching targets, where the actual rule can get replaced by another (independent of those rules' own name/identity)!

    So, labels are a subset of names. Every name can be used as a label, but labels can't always be used as names.

xparq added a commit that referenced this issue Sep 6, 2023
Nested structures like { some = code; { block; {another} stuff} yay }
can be parsed now recursively.

+ Rule tree: name lookup for _USE (no generic find() yet)
+ #14: Recursion is implemented, but not via _SELF yet
+ #15 (_DEF/_USE)
+ #28: Parser::run() added
+ OPERATORS -> CONST_OPERATORS, preparing to taking it seriously
  (RULE.name is mutable though, for _DEF to still work on const rules,
  but that's a tmp. kludge!)
+ Fix #29: Crash in _DEF for missing len = 0
+ Better diagnostics (tests, debug messages etc.)
+ Comments, cosmetics
xparq added a commit that referenced this issue Sep 6, 2023
Nested structures like { some = code; { block; {another} stuff} yay }
can be parsed now with (almost) the ususal recursive grammar productions.

+ Rule tree: name lookup for _USE (no generic find() yet)
+ #14: Recursion is implemented, but not via _SELF yet
+ #15 (_DEF/_USE)
+ #28: Parser::run() added
+ OPERATORS -> CONST_OPERATORS, preparing to taking it seriously
  (RULE.name is mutable though, for _DEF to still work on const rules,
  but that's a tmp. kludge!)
+ Fix #29: Crash in _DEF for missing len = 0
+ Better diagnostics (tests, debug messages etc.)
+ Comments, cosmetics
xparq added a commit that referenced this issue Sep 6, 2023
Nested structures like { some = code; { block; {another} stuff} yay }
can be parsed now with (almost) the ususal recursive grammar productions.

+ Rule tree: name lookup for _USE (no generic find() yet)
+ #14: Recursion is implemented, but not via _SELF yet
+ #15 (_DEF/_USE)
+ #28: Parser::run() added
+ OPERATORS -> CONST_OPERATORS, preparing to taking it seriously
  (RULE.name is mutable though, for _DEF to still work on const rules,
  but that's a tmp. kludge!)
+ Fix #29: Crash in _DEF for missing len = 0
+ Better diagnostics (tests, debug messages etc.)
+ Comments, cosmetics
@xparq xparq mentioned this issue Sep 7, 2023
8 tasks
@xparq xparq changed the title _NAME, _CALL, _GOTO _NAME, _CALL, _GOTO (and/or: _DEF, _USE, ...) Sep 7, 2023
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