I am new to Antlr. I am trying to implement a CSS parser. As a start I am using this grammar to generate the parser. I am following this tutorial as a guide. I am generating the code in C# using Antlr 3.4 (Next, I am going to try it using Antlr 4.0 as well).
I am facing several issues and I was unable to find resources on the internet so that I can understand them clearly.
Issues I am having:
Generate customized error messages in different types (Errors, warnings). Is this provided in Antlr. Please provide me some resources to understand how to achieve this.
In the tutorial I am following, I was able to catch the exceptions in parsing and lexing. But in the grammar I tried does not give any errors even though I have added this following code and tested on wrong css content.
partial class CSS3Lexer { public override void ReportError(RecognitionException e) { base.ReportError(e); Console.WriteLine("Error in lexer at line " + e.Line + ":" + e.CharPositionInLine + e.Message); } }
I want to collect the list of errors (parser and lexer errors) in to a some kind of data structure (list of error object which has error type, message, location) so that I can use them for another task. Is there a more meaningful way of doing this.
I would like to get suggestions on my approach as well because I am still unable to reach a more elegant design.