Seite 1 von 1

JavaMOP - CFG Syntax

Verfasst: 27. Feb 2012 23:17
von LordHoto

can anyone please briefly explain the CFG Syntax of JavaMOP (29 in the version with animations), I'm not sure how to interpret that :-). Thanks in advance.

// Johannes

Re: JavaMOP - CFG Syntax

Verfasst: 28. Feb 2012 09:44
von ericbodden

This is a context-free grammar:

The error handler is matched whenever the grammar matches a prefix of the observed trace. Does that help?

Re: JavaMOP - CFG Syntax

Verfasst: 28. Feb 2012 11:23
von tgp
to translate the definition on the slide to the one at wikipedia: with
cfg: S ‐> create N U next, N ‐> next N | epsilon, U ‐> update U | update
you have
  • "N", "U" and "S" as non-terminal characters
  • "create", "next" and "update" as terminals
  • "S ‐> create N U next", "N ‐> next N | epsilon", "U ‐> update U | update" as production rules
  • S as a start symbol
The grammar can be used to produce a "sentence" of terminals. You start with S, which can only produce "create N U next". To eliminate the non-terminal characters N and U, you need to use the other two production rules:

With "N -> next N | epsilon" you either append another next to the sentence (producing "next N" with still a non-terminal), or you eliminate an N ("epsilon" is the empty word, so N gets transformed into "nothing"). So this means you can have zero or more "next"s in your sentence, directly after the "create".

With the rule "U -> update U | update" you produce at least one "update", so in the end you can create exactly the same sentences as the extended regular expression (ere) from slide 28:
create next* update update* next
HTH, too.

Re: JavaMOP - CFG Syntax

Verfasst: 28. Feb 2012 13:32
von LordHoto
That definitly helps, it was just a short blackout on my side ;-). I was a bit wondering about the ","s in there, but I guess it's really just seperators for different production rules.