Index: contrib/arch/hadlbppp.py
===================================================================
--- contrib/arch/hadlbppp.py	(revision cf7b3e025e3db101a36b0419103a3b43b6675127)
+++ contrib/arch/hadlbppp.py	(revision 51d4040da629a823b7cc291e0c50eb3402dfb20d)
@@ -35,6 +35,4 @@
 
 # TODO:
-#  - alternative token
-#  - iface protocol repetition
 #  - interface inheritance
 
@@ -130,5 +128,5 @@
 	return True
 
-def preproc_bp(name, tokens):
+def tentative_bp(name, tokens):
 	"Preprocess tentative statements in Behavior Protocol"
 	
@@ -153,5 +151,5 @@
 				if (level == 0):
 					result.append("(")
-					result.extend(preproc_bp(name, tokens[start:(i - 1)]))
+					result.extend(tentative_bp(name, tokens[start:(i - 1)]))
 					result.append(")")
 					result.append("+")
@@ -162,5 +160,5 @@
 					print "%s: Syntax error in tentative statement" % name
 			else:
-				print "%s: Unexpected token in tentative statement" % name
+				print "%s: Expected '{' for tentative statement" % name
 		else:
 			result.append(tokens[i])
@@ -170,4 +168,76 @@
 	return result
 
+def alternative_bp(name, tokens):
+	"Preprocess alternative statements in Behavior Protocol"
+	
+	result = []
+	i = 0
+	
+	while (i < len(tokens)):
+		if (tokens[i] == "alternative"):
+			if ((i + 1 < len(tokens)) and (tokens[i + 1] == "(")):
+				i += 2
+				reps = []
+				
+				while ((i < len(tokens)) and (tokens[i] != ")")):
+					reps.append(tokens[i])
+					if ((i + 1 < len(tokens)) and (tokens[i + 1] == ";")):
+						i += 2
+					else:
+						i += 1
+				
+				if (len(reps) >= 2):
+					if ((i + 1 < len(tokens)) and (tokens[i + 1] == "{")):
+						i += 2
+						
+						start = i
+						level = 1
+						
+						while ((i < len(tokens)) and (level > 0)):
+							if (tokens[i] == "{"):
+								level += 1
+							elif (tokens[i] == "}"):
+								level -= 1
+							
+							i += 1
+						
+						if (level == 0):
+							first = True
+							
+							for rep in reps[1:]:
+								retokens = []
+								for token in tokens[start:(i - 1)]:
+									parts = token.split(".")
+									if ((len(parts) == 2) and (parts[0] == reps[0])):
+										retokens.append("%s.%s" % (rep, parts[1]))
+									else:
+										retokens.append(token)
+								
+								if (first):
+									first = False
+								else:
+									result.append("+")
+								
+								result.append("(")
+								result.extend(alternative_bp(name, retokens))
+								result.append(")")
+							
+							if (i < len(tokens)):
+								result.append(tokens[i])
+						else:
+							print "%s: Syntax error in alternative statement" % name
+					else:
+						print "%s: Expected '{' for alternative statement body" % name
+				else:
+					print "%s: At least one pattern and one replacement required for alternative statement" % name
+			else:
+				print "%s: Expected '(' for alternative statement head" % name
+		else:
+			result.append(tokens[i])
+		
+		i += 1
+	
+	return result
+
 def split_bp(protocol):
 	"Convert Behavior Protocol to tokens"
@@ -176,7 +246,7 @@
 
 def extend_bp(name, tokens, iface):
-	"Add interface to incoming messages"
-	
-	result = []
+	"Convert interface Behavior Protocol to generic protocol"
+	
+	result = ["("]
 	i = 0
 	
@@ -198,4 +268,7 @@
 		i += 1
 	
+	result.append(")")
+	result.append("*")
+	
 	return result
 
@@ -227,5 +300,6 @@
 	"Parse Behavior Protocol"
 	
-	tokens = preproc_bp(name, tokens)
+	tokens = tentative_bp(name, tokens)
+	tokens = alternative_bp(name, tokens)
 	
 	indent = base_indent
Index: contrib/arch/uspace/lib/libfs/fnc.libfs_lookup
===================================================================
--- contrib/arch/uspace/lib/libfs/fnc.libfs_lookup	(revision cf7b3e025e3db101a36b0419103a3b43b6675127)
+++ contrib/arch/uspace/lib/libfs/fnc.libfs_lookup	(revision 51d4040da629a823b7cc291e0c50eb3402dfb20d)
@@ -1,4 +1,4 @@
 (
-	alternative fs tmpfs fat devfs {
+	alternative (fs; tmpfs; fat; devfs) {
 		!fs.lookup
 	}
Index: contrib/arch/uspace/lib/libfs/fnc.libfs_mount
===================================================================
--- contrib/arch/uspace/lib/libfs/fnc.libfs_mount	(revision cf7b3e025e3db101a36b0419103a3b43b6675127)
+++ contrib/arch/uspace/lib/libfs/fnc.libfs_mount	(revision 51d4040da629a823b7cc291e0c50eb3402dfb20d)
@@ -1,5 +1,5 @@
 ?ipc_m_connection_clone ;
 ?ipc_m_data_write /* mount options */ {
-	alternative fs tmpfs fat devfs {
+	alternative (fs; tmpfs; fat; devfs) {
 		!fs.ipc_m_connect_to_me ;
 		!fs.mounted ;
Index: contrib/arch/uspace/srv/vfs/vfs.bp
===================================================================
--- contrib/arch/uspace/srv/vfs/vfs.bp	(revision cf7b3e025e3db101a36b0419103a3b43b6675127)
+++ contrib/arch/uspace/srv/vfs/vfs.bp	(revision 51d4040da629a823b7cc291e0c50eb3402dfb20d)
@@ -21,5 +21,5 @@
 						(
 							/* root fs */
-							alternative fs tmpfs fat devfs {
+							alternative (fs; tmpfs; fat; devfs) {
 								!fs.mounted ;
 								!fs.ipc_m_data_write /* mount options */
@@ -29,5 +29,5 @@
 							/* non-root fs */
 							tentative {
-								alternative fs tmpfs fat devfs {
+								alternative (fs; tmpfs; fat; devfs) {
 									[fnc.vfs_lookup_internal] ;
 									tentative {
@@ -55,5 +55,5 @@
 			?ipc_m_data_write /* path */ ;
 			tentative {
-				alternative fs tmpfs fat devfs {
+				alternative (fs; tmpfs; fat; devfs) {
 					[fnc.vfs_lookup_internal] ;
 					tentative {
@@ -68,5 +68,5 @@
 	
 	?open_node {
-		alternative fs tmpfs fat devfs {
+		alternative (fs; tmpfs; fat; devfs) {
 			[fnc.vfs_open_node_internal] ;
 			tentative {
@@ -80,5 +80,5 @@
 	?close {
 		tentative {
-			alternative fs tmpfs fat devfs {
+			alternative (fs; tmpfs; fat; devfs) {
 				[fnc.vfs_grab_phone] ;
 				!fs.close ;
@@ -91,5 +91,5 @@
 		tentative {
 			?ipc_m_data_read {
-				alternative fs tmpfs fat devfs {
+				alternative (fs; tmpfs; fat; devfs) {
 					[fnc.vfs_grab_phone] ;
 					!fs.read ;
@@ -104,5 +104,5 @@
 		tentative {
 			?ipc_m_data_write {
-				alternative fs tmpfs fat devfs {
+				alternative (fs; tmpfs; fat; devfs) {
 					[fnc.vfs_grab_phone] ;
 					!fs.write ;
@@ -116,5 +116,5 @@
 	?truncate {
 		tentative {
-			alternative fs tmpfs fat devfs {
+			alternative (fs; tmpfs; fat; devfs) {
 				[fnc.vfs_grab_phone] ;
 				!fs.truncate ;
@@ -127,5 +127,5 @@
 		tentative {
 			?ipc_m_data_read /* struct stat */ {
-				alternative fs tmpfs fat devfs {
+				alternative (fs; tmpfs; fat; devfs) {
 					[fnc.vfs_grab_phone] ;
 					!fs.stat ;
@@ -141,5 +141,5 @@
 		tentative {
 			?ipc_m_data_read /* struct stat */ {
-				alternative fs tmpfs fat devfs {
+				alternative (fs; tmpfs; fat; devfs) {
 					[fnc.vfs_lookup_internal] ;
 					tentative {
@@ -155,5 +155,5 @@
 		?ipc_m_data_write /* path */ ;
 		tentative {
-			alternative fs tmpfs fat devfs {
+			alternative (fs; tmpfs; fat; devfs) {
 				[fnc.vfs_lookup_internal]
 			}
@@ -164,5 +164,5 @@
 		?ipc_m_data_write /* path */ ;
 		tentative {
-			alternative fs tmpfs fat devfs {
+			alternative (fs; tmpfs; fat; devfs) {
 				[fnc.vfs_lookup_internal]
 			}
@@ -175,5 +175,5 @@
 			?ipc_m_data_write /* new path */ ;
 			tentative {
-				alternative fs tmpfs fat devfs {
+				alternative (fs; tmpfs; fat; devfs) {
 					[fnc.vfs_lookup_internal] /* lookup old path */ ;
 					tentative {
@@ -196,5 +196,5 @@
 	?sync {
 		tentative {
-			alternative fs tmpfs fat devfs {
+			alternative (fs; tmpfs; fat; devfs) {
 				!fs.sync
 			}
