JavaMOP - CFG Syntax

Moderator: Automated Software Engineering

LordHoto
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 135
Registriert: 14. Dez 2009 17:00

JavaMOP - CFG Syntax

Beitrag von LordHoto » 27. Feb 2012 23:17

Hi,

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
Compiler 1 Tutor WS 12/13

Benutzeravatar
ericbodden
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 243
Registriert: 5. Apr 2010 19:06

Re: JavaMOP - CFG Syntax

Beitrag von ericbodden » 28. Feb 2012 09:44

Hello.

This is a context-free grammar:
http://en.wikipedia.org/wiki/Context-free_grammar

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

tgp
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 268
Registriert: 15. Nov 2006 21:41

Re: JavaMOP - CFG Syntax

Beitrag von tgp » 28. Feb 2012 11:23

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.

LordHoto
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 135
Registriert: 14. Dez 2009 17:00

Re: JavaMOP - CFG Syntax

Beitrag von LordHoto » 28. Feb 2012 13:32

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.
Compiler 1 Tutor WS 12/13

Antworten

Zurück zu „Automated Software Engineering“