gocc
gocc copied to clipboard
Add a package for computing follow sets of a grammar
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: {
$
)
*
+
}
Is it possible for gocc to also use this package when calculating the FollowSymbol ?
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 ?
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?
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.
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?