ufal / lindat-kontext

An alternative web front-end for the Manatee corpus search engine
GNU General Public License v2.0
5 stars 1 forks source link

syntax highlighting of CQL queries: the complaint about non-existing structure appears too soon, about non-existing attribute name too late #225

Open Ansa211 opened 5 years ago

Ansa211 commented 5 years ago

Tested with UD 2.3 - Afrikaans AfriBooms on production. Choose CQL query type. Start entering the name of the <doc> structure. When you are at <d, there is a warning saying Structure does not exist: d. I think this is a little confusing, the warning should come up only when I input a string that cannot be extended into a name of an existing structure.

warning

On the other hand, let's try to input a non-existent attribute name. I can go as far as [damnit="" & omg="" with no warning, although the fact that I have input a nonexistent attribute name should be obvious at the moment I enter the first = (or earlier). The warning about non-existent attribute names appears at the moment when I enter the closing ]: nowarning warning1

tomachalek commented 5 years ago

I know about this flaw and I agree it is quite confusing/annoying. Unfortunately this will require some time to rethink respective parts of the editor/parser code. Basically, the issue is how/where to bind individual query checking functions within an AST of a CQL query.

tomachalek commented 5 years ago

I've made a slight change (see https://github.com/czcorpus/kontext/pull/2801) in the CQL editor/parser. It is still far from perfect (one can complain that now it triggers the message too late) but at least the structure check is now consistent with the rest - once a "human understandable" parent non-terminal symbol is consumed we trigger the check. With the time I can spend on this and with my level of knowledge of the domain I probably can't do much better at the moment. More sophisticated solution would probably require a) slight rewrite of some parts of the grammar to introduce helper non-terminals for binding the checks (or) b) some stateful automaton-like processing of AST to be able to detect exact positions (nodes) where we can trigger the check.