Bisonc++ - Verbose reporting to return conflicting rules? - bisonc++

I have a massive problem with bisonc++'s compiler: The error messages are garbage. It's really hard for me to find the problem, when all it says is Line 63: 2 Reduce/Reduce conflict(s) (line 63 is the last line of the code). Is there a way, a switch or anything to make bisonc++ also return the rules that cause the conflict? Any verbose error reporting? Thank you!

According to the bisonc++ man pages, you can request a detailed output that gets written into a .output file with the -V switch.
--verbose (-V)
Writes a file containing verbose descriptions of the parser states and what is done for each type of look-ahead token in
that state. This file also describes all conflicts detected in the
grammar, both those resolved by operator precedence and those that
remain unresolved. It is not created by default, but if requested the
information is written on .output, where is the
grammar specification file passed to bisonc++

Related

How to fix errors in "Total Parser Combinators" by Nils Anders Danielsson

Note: This was originally posted with incorrect error message and is now corrected.
Am trying to compile the Agda source code associated with the paper Total Parser Combinators by Nils Anders Danielsson. The source code is available here github. When compiling I am getting the following error:
Not in scope:
return′
at parser-combinators-master/TotalParserCombinators/Parser.agda:99,46-53 when scope checking return′
I am using Agda version 2.6.2 and have updated std-lib using cabal (according to instructions on Agda Wiki) and the agda/libs/agda-stdlib/README.agda states
This version of the library has been tested using Agda 2.6.2.
I am very much not not an Agda expert; my motivation is the paper as opposed to the code per se. It would, however, be extremely useful to have the code working.
Any pointers on where to look, what to check or to try greatly appreciated.

clang-format giving inconsistent results

I'm working on a program that does a clang-format check of any newly submitted git files and shows a diff of what the user needs to change to match the correct format.
The issue here is that I've already run clang-format on the current git repo, and when I run it again (on the already clang-formatted file), it decides to continue to make changes. One of the examples is:
1294c1294
< // 3)
---
> //3)
clang-format can't seem to decide whether or not it wants a space here. Another example:
229,230c229
< * testCodeUnknown OBJECT IDENTIFIER ::=
< *{
---
> * testCodeUnknown OBJECT IDENTIFIER ::= {
This is within a comment, so it really doesn't matter, but it's making a mess of the 1600 files I have to check and diff when clang-format doesn't produce consistent results.
I am calling clang-format the same way both times, other than the fact that the actual format includes -i and the check pipes stdout to a temp file.
Is this expected behavior? Is there a way to get clang-format to make up its mind (do I have to explicitly set these values in the .clang-format file?)
Edit
As per this question (clang-format makes changes to an already formatted file), this is an idempotency bug in clang-format. I will further look into reproduction cases, but I need some help on figuring out what rule this is so I can potentially just not implement that rule as a workaround

Seeing Bad parsing rule for Jenkins Log parser plugin

I am trying to use Log Parser Plugin with Jenkins. Following is my rule file which I have taken from the sample given on the link.
# match line starting with 'error', case-insensitive
error /(?i)^error/
# list of warnings here...
warning /[Ww]arning/
warning /WARNING/
# create a quick access link to lines in the report containing 'INFO'
info /INFO/
# each line containing 'BUILD' represents the start of a section for grouping errors and warnings found after the line.
# also creates a quick access link.
start /BUILD/
I still see following at the end of the Parsed Console Output page:
NOTE: Some bad parsing rules have been found:
Bad parsing rule: , Error:1
Bad parsing rule: , Error:1
Bad parsing rule: , Error:1
I did come across this, but dint help as I am not using space anywhere.
Can someone help me resolving this issue?
It appears you have extra white-space somewhere in the file that the plugin is interpreting as you attempting to define a rule. Maybe try running it with the empty lines removed. That plugin has given me quite a bit of trouble as well, it's not very well documented (as is the case with many Jenkins plugins).
I had tried no spaces in the pattern, but that did not work. Turns out that the Parsing Rules files does not support empty lines in it. Once I removed the empty lines, I did not get this "Bad parsing rule: , Error:1".
I think since the line is empty - it doesn't echo any rule after the first colon. Would have been nice it the line number was reported where the problem is.
I posted the same to this thread too - Log parsing rules in Jenkins
Hopefully, it helps out other folks who may be wondering what is causing this.

how to get bison to bail out for all errors

I am using Flex/Bison for a script parser which needs to break out of the parser and return a nonzero status from yyparse() for ALL ERRORS. Every bit of documentation for Bison I can find is about recovery -- how can I write a rule set which bails (i.e., with YYABORT) rather than trying to recover?
Thanks for your collective wisdom.
If you refer to semantic errors, i.e., checks that you are doing in the semantic part of the syntax rules, then you can just invoke the exit() function to immediately exit the parser's executable. The parameter to exit() is the error code to return to the shell environment.
You may also implement yyerror() that would invoke exit() if you wish (to exit on syntax errors). This is documented here.
If there is no applicable error rule, bison will not attempt to recover and will immediately return when a syntax error is detected. So unless you explicitly attempt error recovery, the bison parser will act as you wish.
If you do attempt error recovery, you can still invoke YYABORT in an action to cause yyparse to return.
If your parser is not behaving in this way, please post more details.
If you want to force an error from the scanner, just return a token value which is not used in any production. That is guaranteed to create an error in the parser because the token cannot be shifted.

Exceptions in LEX&YACC

I'm developing a lex/yacc c compiler.
In order to handle failures and parse errors, I want to deploy an exception system handler.
Actually only a "parse error" message is handled whatever the problem is.for example:
typedef struct , struct_name{...} this input will produce a parsing error because of the extra comma.
My purpose is to throw a contextual exception,giving us the possibility to focus exactly where the problem is.such as for this example :
"Invalid structure declaration "
I really need help to solve this problème.
This will go into your parser. As it runs, it gets tokens from the lexer. If the next token does not "fit" the current rule, then you have a problem. Luckily, there already exists a section for dealing with these situations! See bison error recovery for the gnu version of yacc and how to deal with this. It'll go through the concepts, and variables to deal with just the situation you have here.

Resources