knowsys / rulewerk

Java library based on the VLog rule engine
Apache License 2.0
32 stars 13 forks source link

[parser] Allow @source anywhere #184

Open mkroetzsch opened 4 years ago

mkroetzsch commented 4 years ago

Currently an @source declaration does not work after an @import declaration. The resulting parser error is:

Error: Failed to parse Rulewerk file: Encountered " "source" "@source "" at line 7, column 1.
Was expecting one of:
    <EOF> 
    <VARORPREDNAME> ...
    <PNAME_LN> ...
    <IRI_ABSOLUTE> ...
    <CUSTOM_DIRECTIVE> ...

This restriction does not seem reasonable and should be relaxed. In general, while good practice might be to have @source at the beginning of a file, there is no need to force users here. @prefix is a different story and should stay on top though.