How does TextX defines boundaries between words?

39 views Asked by At

Consider the following made up example with 3 rules.

Model: id_1=Ident 'is' id_2=Ident;

Keyword: 'is';

Ident: !Keyword ID;

It seems like TextX cannot parse inputs where id_2 starts with "is", e.g., "Tom is isolated". I get the following error: None:1:7: error: Expected Not at position ../test.txt:(1, 7) => 'Tom is* isolated'. Why is that happening? Shouldn't "isolated" be considered as one word that is different from "is"? TextX can parse the input if id_2 does not start with "is".

Is there anyway to solve this problem?

Thanks!

1

There are 1 answers

0
Igor Dejanović On BEST ANSWER

textX doesn't assume by default that matching should be done on word boundaries. To solve your problem you can either define keywords to match on word boundaries like:

Keyword: /\bis\b/;

or use auto keywords feature which can be turned on using autokwd=True in metamodel_from_file/str calls.