Solving the conflict

Top  Previous  Next

Examples > E-mail address > Solving the conflict

 

To solve the conflict, word must be factored out.

For phrase this is easy. The rule will be redefined as:

 

phrase = word*

 

and at all positions, where phrase is used in the grammar, phrase is replaced by:

 

word phrase

 

The mailbox production just is the only occurrence of phrase; so it becomes to:

 

mailbox ::= addr_spez | word phrase route_addr

 

Analogously is dealt with local_part. The production is redefined to

 

local_part ::= ("." word)*

 

and all places, where local_part exists in the grammar are replaced by:

 

word local_part

 

So addr_spez becomes to:

 

addr_spez ::= word local_part "@" domain

 

Finally word is extracted from addr_spez too, whereby this production regains it's old form (but with a new defined local_part):

 

addr_spez ::= local_part "@" domain

 

Here you must pay attention, because addr_spez is also used in route_addr.

 

route_addr ::= "<" (route)? word addr_spez ">"

 

And finally

 

mailbox ::= word addr_spez | word phrase route_addr

 

Now the factoring out of word can be completed:

 

mailbox ::= word ( addr_spez | phrase route_addr )

 

If you compile this rule now, there is no conflict any more.

 

The corrected project is:

 

\TextTransformer\Examples\Mailbox\mailbox2.ttp

 

 



This page belongs to the TextTransformer Documentation

Home  Content  German