openEHR / adl-antlr

Antrl4 grammars for ADL
Apache License 2.0
1 stars 4 forks source link

/path/to/dv_boolean = true not possible #30

Closed pieterbos closed 2 years ago

pieterbos commented 7 years ago

Due to the strict separation of boolean and arithmetic logic, /path/to/dv_boolean = true is not possible. This limits score calculations like:

probably_delirium:
        /data[id2]/events[id3]/data[id4]/items[id38]/value/magnitude >= 3 implies /data[id2]/events[id3]/data[id4]/items[id41]/value/value = true
no_delirium:
        /data[id2]/events[id3]/data[id4]/items[id38]/value/magnitude < 3 implies /data[id2]/events[id3]/data[id4]/items[id41]/value/value = false

Also no support for at-codes for dv_coded_text, no string support in '==' and '!=' operators, as well as probably quite a lot of other types.

I'm currently creating a version that does this. It will lose some type-safety checks in the grammar, but you have to do those in code anyway for checking the types of path lookup. It is very likely that we need an assertion-separator sign, or a whitespace sensitive grammar.

pieterbos commented 7 years ago

Updated grammar available at https://github.com/nedap/archie/blob/updated_grammar/src/main/antlr/adl_rules.g4 . Parses. It still has a lot of full context sensitivity with the paths and even some ambiguity warnings. Not sure why.

Next up is implementing the evaluation of the trees generated by this new grammar, and new tests for it.

wolandscat commented 7 years ago

@pieterbos can you provide a working link to your changed grammar - that one is broken!

pieterbos commented 7 years ago

@wolandscat ah, sorry, that link's dead indeed. It's at now https://github.com/nedap/archie/blob/master/src/main/antlr/adl_rules.g4 and it will remain there.

It now also has string literal support, which means you can use it to check and set at-codes of DV_CODED_TEXT. Dates, times and datetimes should probably not be that hard to add, although we could just use strings for that as well.

pieterbos commented 7 years ago

No longer need the ';' and 'satisfies because I moved the path parsing to the lexer at:

https://github.com/nedap/archie/pull/29

Link should keep on working even if I remove the branch :)

The entire Archie testsuite still works. Requires some modifications which I'm not that happy, especially the duration constraint with the '/' syntax. It's possible that that's fixable by some reordering, haven't checked yet. The 'you can only use ID-code in paths in ADL, and only strings and integers in odin' check is gone, but that could be enforced in the parser by splitting this in multiple lexer rules.

Still some ambiguity warnings in arithmetic expressions. I do not yet know why - the samples in the archie testcases do work.

pieterbos commented 2 years ago

very old issue, can be closed.