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

Implement parameterised rules #70

Closed
david-pfx opened this issue Dec 8, 2015 · 4 comments
Closed

Implement parameterised rules #70

david-pfx opened this issue Dec 8, 2015 · 4 comments

Comments

@david-pfx
Copy link

The basic idea is to use the existing label syntax, but allow labels to be passed as parameters into a rule, where it can be used as a rule, or to replace a literal, or to pass into another rule.

IronMeta has this feature.

@otac0n
Copy link
Owner

otac0n commented Dec 8, 2015

This is a duplicate of #32.

@otac0n otac0n closed this as completed Dec 8, 2015
@david-pfx
Copy link
Author

If you say so, but it was intended to be something much simpler.

Rule1 = "foo" / Error("foo expected");
Rule2 = "bar" / Error("bar expected");
Error(m) = #STATE{ Error(m); } Skip;

Basically just a way to avoid some repetition.

@otac0n
Copy link
Owner

otac0n commented Dec 17, 2015

It can't quite be that simple:

Error ("foo expected")

This is ambiguous between a parameterized rule and a sequence.

@david-pfx
Copy link
Author

So it would appear. The usual way of resolving this ambiguity is by significant whitespace.

Error ("foo expected") // sequence
Error("foo expected") // rule with parameter

The compiler will pick up any errors, assuming the rule either does or does not have a parameter.

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

2 participants