| Grouping | Top Previous Next | 
| Scripts > Productions > Grouping 
 By means of the parenthesis '(' and ')' expressions can be grouped. So the preference of concatenation can be eliminated. 
 Example: 
 ("a" | "b") ("c" | "d") matches "a c", "a d", "b c" and "b d" "a" | "b" "c" | "d" matches "a", "b c" and "d" 
 
 If you forget the preference of concatenation, this can lead to astonishing results, especially, if semantic actions are involved. 
 Example: 
 {{str s;}} "a" {{s = "a"; }} | "b" {{s = "b"; }} 
 will result in an error message for the last line: Unknown identifier: s Implicitly the first three lines are a closed chain. Only inside of this scope the declaration of string s is valid. Correctly you have to write: 
 {{str s;}} ( "a" {{s = "a"; }} | "b" {{s = "b"; }} ) 
 
 A different example for this is the Inner-production in the introduction. There parenthesis around "b" | "c" are necessary. 
 
 | 
| This page belongs to the TextTransformer Documentation | Home Content German |