lutaml / lutaml-uml

UML module for LutaML
2 stars 2 forks source link

Parsing failure of files should provide better messages #71

Closed ronaldtse closed 3 years ago

ronaldtse commented 3 years ago

When a lutaml file contains invalid syntax, such as:

class Foo {
    +structuredidentifier[0..*]: StructuredIdentifierType
    +technicalcommittee[1..*]: TechnicalCommitteeType
}

The parser fails with an unintelligible message:

ruby/gems/2.6.0/gems/parslet-1.7.1/lib/parslet/cause.rb:70:in `raise': Failed to match sequence (WHITESPACE? DIAGRAM_DEFINITION) at line 1 char 1. (Parslet::ParseFailed)

P.S. The correct format above is:

class Foo {
    +structuredidentifier: StructuredIdentifierType[0..*]
    +technicalcommittee: TechnicalCommitteeType[1..*]
}
w00lf commented 3 years ago

This one turned out to be not so easy to implement. In short, parslet(the library we are currently using for dsl parsing) does support detailed errors display by calling error.cause.ascii_tree, but this particular method greatly depends on how rules were constructed, if you are using maybe modificator for your rule it treats it like additional rule and discards it from error.cause.ascii_tree completely, that's why all our errors are always pointing to the first line of the dsl code. I played a little bit with the rules and it seems that we can surpass that restriction by changing the structure of our rules, which will require some additional time to implement. Working further on this one.

w00lf commented 3 years ago

@ronaldtse implemented in https://github.com/lutaml/lutaml-uml/pull/89