On 11 Oct 2012, at 15:20, Adam Smalin wrote: > Lets say I want to do something like this > > @Start Blah > int a,b > void func() { > beep() > } > float c > @end > > Then I will use Blah in place of declaring all that. Kind of like a C > define. Now here is the twist > > @Start Blah > int a,b > void func() { > beep() > > float c > @end > > I want this to fail because it doesn't end in the same scope. Doing } } > should fail as well as it end one scope to many. > What is the best way to implement this?
You might try the Usenet newsgroup comp.compilers, as this is a list for help with Bison, and not so much about how to implement parsers. But if you only want to check matching brackets, one method is to pick up the whole section as a string and then check it there in some action. If you want to more careful parsing, then writing a Bison grammar might be suitable. Work with the innards of Bison may be fragile: no support for it, so it may break in a later Bison version. Hans _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison