Sun Apr 21, 2019 8:10 pm
Login Register Lost Password? Contact Us

Why is this grammar ambiguous?

Questions around writing code and queries

Tue Apr 16, 2019 8:41 am Change Time Zone


To get my head around the Tomita variant of parsing.
I've generated the very simplest grammar, (where there are lots of examples on the Web).
Just to parse palindromes. So I have:
Code: Select all
TOKEN a := 'a';
TOKEN b := 'b';

attrRec := RECORD
STRING  val;

RULE(attrRec) expr := a  USE(attrRec,expr) a
                    | b  USE(attrRec,expr) b
                    | (a|b) TRANSFORM(attrRec,SELF.val := $1 );

infile := DATASET([{'aba'},{'a'},{'b'},{'ab'}],{ STRING line });

OUTPUT(PARSE(infile,line,expr,{STRING Text := MATCHTEXT},FIRST,WHOLE,PARSE,SKIP([' ','\t']+)));

This all works, but I get this warning:
Code: Select all
Warning:  The PARSE pattern for activity 3 is ambiguous.  This may reduce the efficiency of the PARSE. (15, 8), 4537,

And I can't for the life of me work out why.

Any ideas?

Posts: 353
Joined: Sat Oct 01, 2011 7:26 pm

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests