Bison Highlighter is a Visual Studio extension for Visual Studio 2017 which highlights the syntax of language Bison. For the extension to be active, a file with .y extension must be open in the Visual Studio. The extension differentiates between sections of Bison and C within the code. C sections are highlighted as C in Visual Studio and is not modifiable from the extension. Bison sections are highlighted by the extension and can be modified. There are two modifiable colors: the one used for Bison tokens’ names and one used for names for the blocks of rules. By default they are set to hot pink and light sea green but can be changed easily in Visual Studio settings. From the menu Tools > Options… > Enviroment > Fonts and Colors. The two settings are Bison Token and Block Name. The program works by dividing code into sections according to Bison structure:
Because sections are clearly divided by unique punctuation, it’s pretty simple to do so. Each section have a defined range of what code we can expect in it. Prologue and Epilogue consists purely of C while in Bison declarations and Grammar rules C have C language only between { and }. Also, syntax of Bison expected in Bison declarations and Grammar rules differs as well so they are treated as separate languages for the purposes of the code. The code then recognizes smaller subsections of code using other punctuation, such as //, /* and */ for comments, ‘’ and “” for strings, # and % for keywords in C and Bison. Keywords of C and Bison are stored in one of the classes and matched to their usage in code. Similiarily, names of Bison token names are read by the program in Bison declarations sections and stored in a list so they can be matched to their usage in Grammar rules. |