Yacc/Bison: Fix the $ symbol and update syntax for Bison
Summary: Hi The Yacc/Bison file highlights as 'dsError' the '$' symbol (it is used as pseudo-variable). The problem comes from the 'isocpp.xml' file of C++, which highlights it as 'Error' (probably, this was added to the C++ file later). **data/syntax/yacc.xml** (lines 131 & 132): 131| <IncludeRules context="##C++" /> 132| <DetectChar attribute="Directive" context="Dol" char="$" /> 133| </context> **autotests/reference/highlight.y.ref** : 35| […] <Symbol>(</Symbol><Error>$</Error><Deimal>2</Decimal><Symbol>) [...] 40| <Normal Text> </Normal Text><Error>$$</Error><Normal Text> </Normal Text> […] That is corrected. Also, this file is outdated for Bison. Therefore, it is updated according to the parser of the latest version of Bison (3.0.4). **Changes/fixes for Bison:** * Add declarations that contain blocks of code that are not currently highlighted. For example: ``` %code { C++ code... } %destructor { C++ code, with symbols $… } %initial-action { C++ code, with symbols $… } ``` * Add the Bison variable '@' (@$, @n, @[name], $@n). * Add directives in rules: %?{ expr…}, %empty, %prec, %dprec and %merge. * Allow a tag in %union declarations. Ex: ``` %union tag { code … } ``` * Allow grammar declarations in the grammar rules section, such as: %union, %code, %type, etc. * Allow declarations in multiple lines. Ex: ``` %token PERCENT_DEBUG "%debug" PERCENT_DEFAULT_PREC "%default-prec" ; ``` * The ';' char is not necessary to finish a rule. Allow ';' followed by ‘|’, within a rule (See line 603 in the “src/parse-gram.y” file, from the Bison 3.0.4 source [2]). * Add the mimetypes (text/x-yacc, text/x-bison) and the extensions '.ypp' & '.y++' [3]. I hope these changes are useful. Any inconvenience (as if it is necessary to contact the original author of the file to approve the changes), do not hesitate to notify. Source: [1] https://www.gnu.org/software/bison/manual/html_node/Table-of-Symbols.html [2] https://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.xz ( ./src/parse-gram.y ) [3] https://www.gnu.org/software/bison/manual/html_node/Invocation.html Test Plan: I've been testing these changes the last week and I think it's ready. Reviewers: #framework_syntax_highlighting, dhaumann Reviewed By: #framework_syntax_highlighting, dhaumann Subscribers: dhaumann, #framework_syntax_highlighting, #frameworks Tags: #frameworks, #framework_syntax_highlighting Differential Revision: https://phabricator.kde.org/D10783
parent
0f75a365
Please register or sign in to comment