[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lojban] Re: CLL and modern Lojban





2017-11-22 14:38 GMT+03:00 Remo Dentato <rdentato@gmail.com>:
On Wed, Nov 22, 2017 at 10:29 AM, Gleki Arxokuna <gleki.is.my.name@gmail.com> wrote:
PEG has no tools to check for ambiguity, it simply does not support it, it's another grammar with its own drawbacks. It can't be compared to YACC, it's just another class of grammars.

If you want tools resolving ambiguity then having tools not more powerful than PEG or CFG is not enough.


Since the absence of syntactic ambiguity is one of (my) requirement for Lojban, let me understand better.

In CFG the source of ambiguity is the at any given moment in parsing one can choos which alternative path to follow.
So, for example, the following CFG grammar is ambiguous:

E = E '+' E | E '-' E | N
N = '0' | '1' | ... | '9'

because the string "4+3-9" may result in two different parse tree:

         E                 E
       / | \             / | \
      E  +  E           E  -  E
      |   / | \       / | \   |
      4  E  -  E     E  +  E  9
         |     |     |     |
         3     9     4     3
     
The corresponding PEG would be:

E = E '+' E / E '-' E | N
N = '0' / '1' / ... / '9'

And there is only parse tree for "4+3+9"
         E      
       / | \    
      E  +  E   
      |   / | \ 
      4  E  -  E
         |     |
         3     9

(note that PEG do support left recursion even if the original packrat algorithm didn't)

CFG grammars need to be checked for ambiguities

yes,that.
 
and have to be rewritten to eliminate them whereas PEG do not have this problem (and hence lack a tool for checking ambiguities).

They simply don't support it since they have priority choice operator that disallows check for ambiguities and requires strict order of subrules.

I already checked PEG grammars proposed by BPFK and discovered that changing this operator back to alternation operator leads to lots of ambiguities.

So BPFK simply cheated by saying "only the first AST is correct". Since people here are also interested in learnability of Lojban by humans this proposed change of grammar makes it potentially much harder. Who would remember that the rule for lujvo comes after cmavo (or maybe vice versa?). CFG doesn't have this problem.

That's only one drawback of PEG in general if we don't delve into specific proposed grammars.



I do agree that ensuring that a PEG grammar does exactly what you want it to do is not easy (especially if it's a complex grammar) but "per se" the PEG itself does not introduce any ambiguity.


Is this what you meant or am I missing something?

--
You received this message because you are subscribed to a topic in the Google Groups "lojban" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lojban/e94H-wdh5gc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lojban+unsubscribe@googlegroups.com.
To post to this group, send email to lojban@googlegroups.com.
Visit this group at https://groups.google.com/group/lojban.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "lojban" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lojban+unsubscribe@googlegroups.com.
To post to this group, send email to lojban@googlegroups.com.
Visit this group at https://groups.google.com/group/lojban.
For more options, visit https://groups.google.com/d/optout.