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 a package for computing follow sets of a grammar #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shivansh
Copy link
Collaborator

@shivansh shivansh commented May 7, 2018

Even if #71 is unsuccessful, computing follow sets will be informative along with other generated *.txt files in verbose mode.

Tested on calc.bnf - generated follow.txt file.

S': {
	$
}
Calc: {
	$
}
Expr: {
	$
	)
	+
}
Term: {
	$
	)
	*
	+
}
Factor: {
	$
	)
	*
	+
}

@awalterschulze
Copy link
Collaborator

Is it possible for gocc to also use this package when calculating the FollowSymbol ?

@shivansh
Copy link
Collaborator Author

shivansh commented May 7, 2018

I guess you were referring to FollowingSymbol (I wasn't able to find FollowSymbol). Although I'm not sure I understand why we'll require this package when dealing with LR(1) items ?

@awalterschulze
Copy link
Collaborator

Good point :)
I am still a bit concerned about merging code that is not really used.

Maybe it would be cool to use these follow sets for auto completion and to expose an API that allows hints to be given to language users.

If you think this might work, then I would also recommend adding some tests.

Or maybe you can think of a better use case to more tightly integrate follow?

@shivansh
Copy link
Collaborator Author

shivansh commented May 7, 2018

Maybe it would be cool to use these follow sets for auto completion and to expose an API that allows hints to be given to language users.

That would be quite cool. I guess I'll figure out a way to design and implement this.

Or maybe you can think of a better use case to more tightly integrate follow?

One place where I'm using follow sets is while implementing panic-mode recovery. I guess we can defer merging this until that is ready, so that we'll have atleast one usecase where follow sets are being used.

PS. I'm mostly finished with the panic-mode implementation, just a bit of debugging and cleanup left.

@awalterschulze
Copy link
Collaborator

Yes either way. With a use case this looks like a nice library :)

I would maybe first add some examples / tests before cleaning up.
This way we could see the possible use cases, before even starting to look at the code.
Does that make sense?

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

Successfully merging this pull request may close these issues.

3 participants