I implemented errorhandling and two errors for testing.

To let it work in my code, this must be added to ADL.g4

.... .... grammar Adl;
@parser::header{
    import nl.rosa.archetype.errorhandling.ADLParserErrorMessages;
}
// // ============== Parser rules ============== // ad..... ..... .....


The error-handling itself is in the grammar. I needed to change the grammar a little bit:

metaDataItem:
      metaDataTagAdlVersion '=' adlVersion |metaDataTagUid '=' GUID 
|metaDataTagBuildUid '=' GUID |metaDataTagRmRelease '=' rmRelease 
|metaDataTagIsControlled |metaDataTagIsGenerated |identifier ('=' metaDataValue 
)?
    ;
adlVersion:VERSION_ID | .+? 
{notifyErrorListeners(String.format(ADLParserErrorMessages.getErrorMessage("VARAV"),
 _localctx.getText()));}//invalid adl_version $1; must be a valid 3-part numeric version 
identifier ;
rmRelease:VERSION_ID | .+? 
{notifyErrorListeners(String.format(ADLParserErrorMessages.getErrorMessage("VARRV"),
 _localctx.getText()));}//invalid rm_release $1; must be a valid 3-part numeric version 
identifier ;

You can find a code-example in the test-file ErrorsTest.java

During this week I will implement the other errors.

If you want to use the error-handling only, copy the different code to your project. Of course you are free to use my code, which is quite compact, has a generated AOM, also.
I try to keep the AOM-part generated.

Best regards
Bert Verhees



_______________________________________________
openEHR-technical mailing list
[email protected]
http://lists.openehr.org/mailman/listinfo/openehr-technical_lists.openehr.org

Reply via email to