[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sticking custom meta informations to grammar rules
From: |
Christian Schoenebeck |
Subject: |
sticking custom meta informations to grammar rules |
Date: |
Wed, 29 Jan 2014 18:48:47 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.32-5-amd64; KDE/4.4.5; x86_64; ; ) |
Hi everybody!
I am currently working on a shell and wrote custom C++ code that takes Bison's
symbol stack at a certain point (i.e. when an error occured) and walks ahead
the Bison generated yyfoo tables / tree of the shell's grammar. I added that
custom code for two purposes: 1) providing very user friendly error messages
on syntax errors and 2) providing the user visual auto completion & auto
correction while typing in the shell.
It is already working, however to make those syntax error messages and auto
completion suggestions even more appropriate & human friendly, I would need to
stick some additional custom meta informations to the individual grammar
rules. It could be as simple as binding my own constant number to each grammar
rule like (pseudo code):
enum {
MY_META_INFO1 = 3,
MY_META_INFO2 = 7,
...
};
...
foo : bla custom_meta(MY_META_INFO8)
| bar custom_meta(MY_META_INFO2)
| command number custom_meta(MY_META_INFO3)
;
So that I am able to lookup those constants by the respective Bison grammar
rule index number at runtime and accordingly to associate grammar rules in the
Bison generated yyfoo tables with my own table(s), where the latter would
provide my own, more detailed informations about individual grammar rules.
I hope this somehow explains what I am trying to get at. ;-)
Is there already some kind of solution for that in Bison? Or does anybody know
a work around to achieve something like that?
Best regards,
Christian Schoenebeck
- sticking custom meta informations to grammar rules,
Christian Schoenebeck <=