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

Context dependencies #260

Open
Aphexus opened this issue Oct 27, 2018 · 1 comment
Open

Context dependencies #260

Aphexus opened this issue Oct 27, 2018 · 1 comment

Comments

@Aphexus
Copy link

Aphexus commented Oct 27, 2018

Is there any way to have a context dependent rule?

A B

Where B depends on the "value" of A.

e.g.,

A = [abc]
B = [efg]

A B{A=a}

The idea is that the rule B only matches if the rule A matched an a.

Probably a much better way to implement it, just trying to demonstrate a possible solution. For simple context dependent grammars, this should work well. I imagine one could do it by grossly complicating the grammar which I want to avoid... it can be done programmatically but I'd rather do it in the grammar if possible, and if not, extend pegged to do it if it is not too difficult.

@veelo
Copy link
Collaborator

veelo commented Jul 1, 2020

There is none. I would just write it out:

<- 'a' B / A

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