c# - Customization, categorization, collecting errors in Antlr -
i new antlr. trying implement css parser. start using this grammar generate parser. following this tutorial guide. generating code in c# using antlr 3.4 (next, going try using antlr 4.0 well).
i facing several issues , unable find resources on internet can understand them clearly.
issues having:
generate customized error messages in different types (errors, warnings). provided in antlr. please provide me resources understand how achieve this.
in tutorial following, able catch exceptions in parsing , lexing. in grammar tried not give errors though have added following code , tested on wrong css content.
partial class css3lexer { public override void reporterror(recognitionexception e) { base.reporterror(e); console.writeline("error in lexer @ line " + e.line + ":" + e.charpositioninline + e.message); } }
i want collect list of errors (parser , lexer errors) in kind of data structure (list of error object has error type, message, location) can use them task. there more meaningful way of doing this.
i suggestions on approach because still unable reach more elegant design.
antlr's built-in error reporting mechanism pretty simple, , doesn't provide way give error categories or numbers particular errors. often, syntax errors occur @ parse time given same error number. example, antlr 4 tool reports parser errors error 50.
after initial parse complete , have parse tree (antlr 4) or ast (antlr 3) available, can continue perform semantic evaluation. errors identified there on can considered either errors or warnings depending on overall impact. data structures use sometime application-specific, such visual studio or netbeans extension needs report errors/warnings specific ui components, otherwise free define in whatever manner makes sense you.
Comments
Post a Comment