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

Add mid-rule actions. #527

Open
skvadrik opened this issue Jan 24, 2025 · 0 comments
Open

Add mid-rule actions. #527

skvadrik opened this issue Jan 24, 2025 · 0 comments

Comments

@skvadrik
Copy link
Owner

At the present moment re2c has tags, which technically is the same as having actions that execute YYSTAGP / YYSTAGN / YYMTAGP / YYMTAGN code. We could probably generalize this to arbitrary actions, doing the same analysis and TDFA construction for each action as if it was a tag. It would be safe to add actions if the tag has 1st degree of nondeterminism (meaning that it can be implemented with a single tag variable), otherwise if nondeterminism degree is 2 or more, the action would be unsafe and re2c should warn about it (so the user can still have it at their own risk).

The downside is that actions will always be attached to the outgoing transitions, the way TDFA(1) does it with tag operations. This is more restrictive compared to Ragel that has all sorts of actions attached to different kinds of transitions.

The upside is that re2c can have safe actions that are guaranteed to have no conflicts (or, if the user want, they can have conflict with a warning), and TDFA(1) makes use of the lookahead symbol to reduce nondeterminism.

The proposed syntax was discussed in #521:

  • actions can have named definitions, something like !action:x { ... }
  • !x stands for action named x (used in a regexp, and not as the only element of a regexp, as it would clash with pre-defined actions like !entry)
  • inline actions have syntax !{ ... }
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