Random order of terminals/nonterminals in an EBNF production

SyntaxEditor for WPF Forum

Posted 3 years ago by gareth
Version: 16.1.0632
Avatar

Hi there,

Not sure if this has been asked before but regarding WPF SyntaxEditor grammar, what would the best technique be to allow terminals/nonterminals be in random order for a production?

E.g. projecting something like the following 3 productions as a single production:

Production1 = @term1 + @term2 + @term3 + _nonterm;
Production2 = @term1 + @term3 + _nonterm + @term2;
Production3 = @term1 + _nonterm + @term2 + @term3;

Kind regards,

Gareth

Comments (3)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Gareth,

In your scenario, would @term1 be allowed to be anywhere in there too?  And also, can those terminals each only appear once in the production?


Actipro Software Support

Posted 3 years ago by gareth
Avatar

Hi, thanks for the quick reply. Sorry I should have elaborated a bit more: @term1 is fixed at the start; the rest can be in any order but can only appear once each.

I figure something like this would probably work, but then it would allow multiple instances of @term2, @term3 etc:

Production = @term1 + (@term2 | @term3 | _nonterm).ZeroOrMore();

Is there an easier way to solve this kind of problem or would I have to manually work it out in a CanMatchCallback

Thanks,

Gareth

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Gareth,

Unfortunately for this sort of thing, you'd probably need use multiple productions that branch out to filter down the remaining options that are valid based on what has matched already.  We don't have anything else that would make a random order scenario easier.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.