Index: contrib/arch/hadlbppp.py
===================================================================
--- contrib/arch/hadlbppp.py	(revision 2a706725a21e1767f49f217b4694ede563b20ee3)
+++ contrib/arch/hadlbppp.py	(revision ee5b35ae379e113674cdd8fd1e5e1ba75d7ef2b6)
@@ -35,14 +35,11 @@
 
 INC, POST_INC, BLOCK_COMMENT, LINE_COMMENT, SYSTEM, ARCH, HEAD, BODY, NULL, \
-	INST, VAR, FIN, BIND, TO, SEEN_NL, IFACE, PROTOTYPE, PAR_LEFT, PAR_RIGHT, SIGNATURE, PROTOCOL = range(21)
-
-context = set()
-interface = None
-architecture = None
-protocol = None
+	INST, VAR, FIN, BIND, TO, SUBSUME, DELEGATE, IFACE, PROTOTYPE, PAR_LEFT, \
+	PAR_RIGHT, SIGNATURE, PROTOCOL, FRAME, PROVIDES, REQUIRES = range(25)
 
 def usage(prname):
 	"Print usage syntax"
-	print prname + " <OUTPUT>"
+	
+	print "%s <OUTPUT>" % prname
 
 def tabs(cnt):
@@ -91,47 +88,4 @@
 	return tokens
 
-def preproc_bp(outname, tokens):
-	"Preprocess tentative statements in Behavior Protocol"
-	
-	result = []
-	i = 0
-	
-	while (i < len(tokens)):
-		if (tokens[i] == "tentative"):
-			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):
-					result.append("(")
-					result.extend(preproc_bp(outname, tokens[start:(i - 1)]))
-					result.append(")")
-					result.append("+")
-					result.append("NULL")
-				else:
-					print "%s: Syntax error in tentative statement" % outname
-			else:
-				print "%s: Unexpected tentative statement" % outname
-		else:
-			result.append(tokens[i])
-		
-		i += 1
-	
-	return result
-
-def preproc_adl(raw, inarg):
-	"Preprocess %% statements in ADL"
-	
-	return raw.replace("%%", inarg)
-
 def identifier(token):
 	"Check whether the token is an identifier"
@@ -171,77 +125,64 @@
 	return True
 
-def parse_bp(base, root, inname, nested, outname, indent):
+def preproc_bp(name, tokens):
+	"Preprocess tentative statements in Behavior Protocol"
+	
+	result = []
+	i = 0
+	
+	while (i < len(tokens)):
+		if (tokens[i] == "tentative"):
+			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):
+					result.append("(")
+					result.extend(preproc_bp(name, tokens[start:(i - 1)]))
+					result.append(")")
+					result.append("+")
+					result.append("NULL")
+					if (i < len(tokens)):
+						result.append(tokens[i])
+				else:
+					print "%s: Syntax error in tentative statement" % name
+			else:
+				print "%s: Unexpected token in tentative statement" % name
+		else:
+			result.append(tokens[i])
+		
+		i += 1
+	
+	return result
+
+def parse_bp(name, protocol, base_indent):
 	"Parse Behavior Protocol"
 	
-	if (nested):
-		if (inname[0:1] == "/"):
-			path = os.path.join(base, ".%s" % inname)
-			nested_root = os.path.dirname(path)
-		else:
-			path = os.path.join(root, inname)
-			nested_root = root
-		
-		if (not os.path.isfile(path)):
-			print "%s: Unable to include file %s" % (outname, path)
-			return ""
-	else:
-		path = inname
-		nested_root = root
-	
-	inf = file(path, "r")
-	tokens = preproc_bp(outname, split_tokens(inf.read(), ["\n", " ", "\t", "(", ")", "{", "}", "[", "]", "/*", "*/", "#", "*", ";", "+", "||", "|", "!", "?"], True, True))
-	
+	tokens = preproc_bp(name, split_tokens(protocol, ["\n", " ", "\t", "(", ")", "{", "}", "*", ";", "+", "||", "|", "!", "?"], True, True))
+	
+	indent = base_indent
 	output = ""
-	inc = False
-	comment = False
-	lcomment = False
 	
 	for token in tokens:
-		if (comment):
-			if (token == "*/"):
-				comment = False
-			continue
-		
-		if ((not comment) and (token == "/*")):
-			comment = True
-			continue
-		
-		if (lcomment):
-			if (token == "\n"):
-				lcomment = False
-			continue
-		
-		if ((not lcomment) and (token == "#")):
-			lcomment = True
-			continue
-		
 		if (token == "\n"):
-			continue
-		
-		if (inc):
-			output += "\n%s(" % tabs(indent)
-			
-			bp = parse_bp(base, nested_root, token, True, outname, indent + 1)
-			if (bp.strip() == ""):
-				output += "\n%sNULL" % tabs(indent + 1)
-			else:
-				output += bp
-			
-			output += "\n%s)" % tabs(indent)
-			inc = False
 			continue
 		
 		if ((token == ";") or (token == "+") or (token == "||") or (token == "|")):
 			output += " %s" % token
-		elif (token == "["):
-			inc = True
-		elif (token == "]"):
-			inc = False
 		elif (token == "("):
 			output += "\n%s%s" % (tabs(indent), token)
 			indent += 1
 		elif (token == ")"):
-			if (indent <= 0):
-				print "%s: Wrong number of parentheses" % outname
+			if (indent < base_indent):
+				print "%s: Too many parentheses" % name
 			
 			indent -= 1
@@ -251,6 +192,6 @@
 			indent += 1
 		elif (token == "}"):
-			if (indent <= 0):
-				print "%s: Wrong number of parentheses" % outname
+			if (indent < base_indent):
+				print "%s: Too many parentheses" % name
 			
 			indent -= 1
@@ -263,10 +204,51 @@
 			output += "%s" % token
 	
-	inf.close()
+	if (indent > base_indent):
+		print "%s: Missing parentheses" % name
+	
+	output = output.strip()
+	if (output == ""):
+		return "NULL"
 	
 	return output
+
+def dump_iface_bp(interface, protocol, outdir):
+	"Dump Behavior Protocol of a given interface"
+	
+	outname = os.path.join(outdir, "iface_%s.bp" % interface)
+	if (os.path.isfile(outname)):
+		print "%s: File already exists, overwriting" % outname
+	
+	outf = file(outname, "w")
+	outf.write(parse_bp(outname, protocol, 0))
+	outf.close()
+
+def dump_frame_bp(frame, protocol, outdir):
+	"Dump Behavior Protocol of a given frame"
+	
+	outname = os.path.join(outdir, "frame_%s.bp" % frame)
+	if (os.path.isfile(outname)):
+		print "%s: File already exists, overwriting" % outname
+	
+	outf = file(outname, "w")
+	outf.write(parse_bp(outname, protocol, 0))
+	outf.close()
+
+def preproc_adl(raw, inarg):
+	"Preprocess %% statements in ADL"
+	
+	return raw.replace("%%", inarg)
 
 def parse_adl(base, root, inname, nested, indent):
 	"Parse Architecture Description Language"
+	
+	global output
+	global context
+	global architecture
+	global interface
+	global frame
+	global protocol
+	global iface_protocols
+	global frame_protocols
 	
 	if (nested):
@@ -297,5 +279,4 @@
 	raw = preproc_adl(inf.read(), inarg)
 	tokens = split_tokens(raw, ["\n", " ", "\t", "(", ")", "{", "}", "[", "]", "/*", "*/", "#", ";"], True, True)
-	output = ""
 	
 	for token in tokens:
@@ -305,11 +286,5 @@
 		if (INC in context):
 			context.remove(INC)
-			
-			if (PROTOCOL in context):
-				protocol += parse_bp(base, nested_root, token, True, "xxx", indent).strip()
-			else:
-				output += "\n%s" % tabs(indent)
-				output += parse_adl(base, nested_root, token, True, indent).strip()
-			
+			parse_adl(base, nested_root, token, True, indent)
 			context.add(POST_INC)
 			continue
@@ -319,5 +294,4 @@
 				print "%s: Expected ]" % inname
 			
-			context.add(SEEN_NL)
 			context.remove(POST_INC)
 			continue
@@ -351,27 +325,19 @@
 			continue
 		
-		# Seen newline
-		
-		if (SEEN_NL in context):
-			context.remove(SEEN_NL)
-			if (token == "\n"):
-				output += "\n%s" % tabs(indent)
-				continue
-		else:
-			if (token == "\n"):
-				continue
-		
-		# "interface"
-		
-		if (IFACE in context):
+		if (token == "\n"):
+			continue
+		
+		# "frame"
+		
+		if (FRAME in context):
 			if (NULL in context):
 				if (token != ";"):
-					print "%s: Expected ;" % inname
+					print "%s: Expected ';' in frame '%s'" % (inname, frame)
 				else:
 					output += "%s\n" % token
 				
 				context.remove(NULL)
-				context.remove(IFACE)
-				interface = None
+				context.remove(FRAME)
+				frame = None
 				continue
 			
@@ -383,9 +349,15 @@
 						indent -= 1
 					
-					if (indent == 1):
-						output += protocol.strip()
+					if (indent == -1):
+						if (frame in frame_protocols):
+							print "%s: Protocol for frame '%s' already defined" % (inname, frame)
+						else:
+							frame_protocols[frame] = protocol
+						output += "\n%s" % tabs(2)
+						output += parse_bp(inname, protocol, 2)
 						protocol = None
 						
 						output += "\n%s" % token
+						indent = 0
 						
 						context.remove(PROTOCOL)
@@ -397,56 +369,69 @@
 					continue
 				
-				if (PROTOTYPE in context):
+				if (REQUIRES in context):
 					if (FIN in context):
 						if (token != ";"):
-							print "%s: Expected ;" % inname
+							print "%s: Expected ';' in frame '%s'" % (inname, frame)
 						else:
 							output += "%s" % token
 						
 						context.remove(FIN)
-						context.remove(PROTOTYPE)
-						continue
-					
-					if (PAR_RIGHT in context):
-						if (token == ")"):
-							output += "%s" % token
-							context.remove(PAR_RIGHT)
-							context.add(FIN)
-						else:
-							output += " %s" % token
-						
-						continue
-					
-					if (SIGNATURE in context):
-						output += "%s" % token
-						if (token == ")"):
-							context.remove(SIGNATURE)
-							context.add(FIN)
-						
-						context.remove(SIGNATURE)
-						context.add(PAR_RIGHT)
-						continue
-					
-					if (PAR_LEFT in context):
-						if (token != "("):
-							print "%s: Expected (" % inname
-						else:
-							output += "%s" % token
-						
-						context.remove(PAR_LEFT)
-						context.add(SIGNATURE)
-						continue
-					
-					if (not identifier(token)):
-						print "%s: Method identifier expected" % inname
-					else:
-						output += "%s" % token
-					
-					context.add(PAR_LEFT)
-					continue
+						continue
+					
+					if (VAR in context):
+						if (not identifier(token)):
+							print "%s: Instance name expected in frame '%s'" % (inname, frame)
+						else:
+							output += "%s" % token
+						
+						context.remove(VAR)
+						context.add(FIN)
+						continue
+					
+					if ((token == "}") or (token[-1] == ":")):
+						context.remove(REQUIRES)
+					else:
+						if (not identifier(token)):
+							print "%s: Interface name expected in frame '%s'" % (inname, frame)
+						else:
+							output += "\n%s%s " % (tabs(indent), token)
+						
+						context.add(VAR)
+						continue
+				
+				if (PROVIDES in context):
+					if (FIN in context):
+						if (token != ";"):
+							print "%s: Expected ';' in frame '%s'" % (inname, frame)
+						else:
+							output += "%s" % token
+						
+						context.remove(FIN)
+						continue
+					
+					if (VAR in context):
+						if (not identifier(token)):
+							print "%s: Instance name expected in frame '%s'" % (inname, frame)
+						else:
+							output += "%s" % token
+						
+						context.remove(VAR)
+						context.add(FIN)
+						continue
+					
+					if ((token == "}") or (token[-1] == ":")):
+						context.remove(PROVIDES)
+					else:
+						if (not identifier(token)):
+							print "%s: Interface name expected in frame '%s'" % (inname, frame)
+						else:
+							output += "\n%s%s " % (tabs(indent), token)
+						
+						context.add(VAR)
+						continue
 				
 				if (token == "}"):
-					if (indent != 1):
-						print "%s: Wrong number of parentheses" % inname
+					if (indent != 2):
+						print "%s: Wrong number of parentheses in frame '%s'" % (inname, frame)
 					else:
 						indent = 0
@@ -457,16 +442,24 @@
 					continue
 				
-				if (token == "ipcarg_t"):
-					output += "\n%s%s " % (tabs(indent), token)
-					context.add(PROTOTYPE)
+				if (token == "provides:"):
+					output += "\n%s%s" % (tabs(indent - 1), token)
+					context.add(PROVIDES)
+					protocol = ""
+					continue
+				
+				if (token == "requires:"):
+					output += "\n%s%s" % (tabs(indent - 1), token)
+					context.add(REQUIRES)
+					protocol = ""
 					continue
 				
 				if (token == "protocol:"):
 					output += "\n%s%s" % (tabs(indent - 1), token)
+					indent = 0
 					context.add(PROTOCOL)
 					protocol = ""
 					continue
 				
-				print "%s: Unknown token %s in interface" % (inname, token)
+				print "%s: Unknown token '%s' in frame '%s'" % (inname, token, frame)
 				continue
 			
@@ -482,10 +475,153 @@
 					output += "%s\n" % token
 					context.remove(HEAD)
+					context.remove(FRAME)
+					continue
+				
+				print "%s: Unknown token '%s' in frame head '%s'" % (inname, token, frame)
+				
+				continue
+			
+			if (not identifier(token)):
+				print "%s: Expected frame name" % inname
+			else:
+				frame = token
+				output += "%s " % token
+			
+			context.add(HEAD)
+			continue
+		
+		# "interface"
+		
+		if (IFACE in context):
+			if (NULL in context):
+				if (token != ";"):
+					print "%s: Expected ';' in interface '%s'" % (inname, interface)
+				else:
+					output += "%s\n" % token
+				
+				context.remove(NULL)
+				context.remove(IFACE)
+				interface = None
+				continue
+			
+			if (BODY in context):
+				if (PROTOCOL in context):
+					if (token == "{"):
+						indent += 1
+					elif (token == "}"):
+						indent -= 1
+					
+					if (indent == -1):
+						if (interface in iface_protocols):
+							print "%s: Protocol for interface '%s' already defined" % (inname, interface)
+						else:
+							iface_protocols[interface] = protocol
+						
+						output += "\n%s" % tabs(2)
+						output += parse_bp(inname, protocol, 2)
+						protocol = None
+						
+						output += "\n%s" % token
+						indent = 0
+						
+						context.remove(PROTOCOL)
+						context.remove(BODY)
+						context.add(NULL)
+					else:
+						protocol += token
+					
+					continue
+				
+				if (PROTOTYPE in context):
+					if (FIN in context):
+						if (token != ";"):
+							print "%s: Expected ';' in interface '%s'" % (inname, interface)
+						else:
+							output += "%s" % token
+						
+						context.remove(FIN)
+						context.remove(PROTOTYPE)
+						continue
+					
+					if (PAR_RIGHT in context):
+						if (token == ")"):
+							output += "%s" % token
+							context.remove(PAR_RIGHT)
+							context.add(FIN)
+						else:
+							output += " %s" % token
+						
+						continue
+					
+					if (SIGNATURE in context):
+						output += "%s" % token
+						if (token == ")"):
+							context.remove(SIGNATURE)
+							context.add(FIN)
+						
+						context.remove(SIGNATURE)
+						context.add(PAR_RIGHT)
+						continue
+					
+					if (PAR_LEFT in context):
+						if (token != "("):
+							print "%s: Expected '(' in interface '%s'" % (inname, interface)
+						else:
+							output += "%s" % token
+						
+						context.remove(PAR_LEFT)
+						context.add(SIGNATURE)
+						continue
+					
+					if (not identifier(token)):
+						print "%s: Method identifier expected in interface '%s'" % (inname, interface)
+					else:
+						output += "%s" % token
+					
+					context.add(PAR_LEFT)
+					continue
+				
+				if (token == "}"):
+					if (indent != 2):
+						print "%s: Wrong number of parentheses in interface '%s'" % (inname, interface)
+					else:
+						indent = 0
+						output += "\n%s" % token
+					
+					context.remove(BODY)
+					context.add(NULL)
+					continue
+				
+				if ((token == "ipcarg_t") or (token == "unative_t")):
+					output += "\n%s%s " % (tabs(indent), token)
+					context.add(PROTOTYPE)
+					continue
+				
+				if (token == "protocol:"):
+					output += "\n%s%s" % (tabs(indent - 1), token)
+					indent = 0
+					context.add(PROTOCOL)
+					protocol = ""
+					continue
+				
+				print "%s: Unknown token '%s' in interface '%s'" % (inname, token, interface)
+				continue
+			
+			if (HEAD in context):
+				if (token == "{"):
+					output += "%s" % token
+					indent += 2
+					context.remove(HEAD)
+					context.add(BODY)
+					continue
+				
+				if (token == ";"):
+					output += "%s\n" % token
+					context.remove(HEAD)
 					context.remove(ARCH)
-					context.discard(SYSTEM)
 					continue
 				
 				if (not word(token)):
-					print "%s: Expected word" % inname
+					print "%s: Expected word in interface head '%s'" % (inname, interface)
 				else:
 					output += "%s " % token
@@ -507,5 +643,5 @@
 			if (NULL in context):
 				if (token != ";"):
-					print "%s: Expected ;" % inname
+					print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
 				else:
 					output += "%s\n" % token
@@ -518,8 +654,86 @@
 			
 			if (BODY in context):
+				if (DELEGATE in context):
+					if (FIN in context):
+						if (token != ";"):
+							print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
+						else:
+							output += "%s" % token
+						
+						context.remove(FIN)
+						context.remove(DELEGATE)
+						continue
+					
+					if (VAR in context):
+						if (not descriptor(token)):
+							print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)
+						else:
+							output += "%s" % token
+						
+						context.add(FIN)
+						context.remove(VAR)
+						continue
+					
+					if (TO in context):
+						if (token != "to"):
+							print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
+						else:
+							output += "%s " % token
+						
+						context.add(VAR)
+						context.remove(TO)
+						continue
+					
+					if (not identifier(token)):
+						print "%s: Expected interface name in architecture '%s'" % (inname, architecture)
+					else:
+						output += "%s " % token
+					
+					context.add(TO)
+					continue
+				
+				if (SUBSUME in context):
+					if (FIN in context):
+						if (token != ";"):
+							print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
+						else:
+							output += "%s" % token
+						
+						context.remove(FIN)
+						context.remove(SUBSUME)
+						continue
+					
+					if (VAR in context):
+						if (not identifier(token)):
+							print "%s: Expected interface name in architecture '%s'" % (inname, architecture)
+						else:
+							output += "%s" % token
+						
+						context.add(FIN)
+						context.remove(VAR)
+						continue
+					
+					if (TO in context):
+						if (token != "to"):
+							print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
+						else:
+							output += "%s " % token
+						
+						context.add(VAR)
+						context.remove(TO)
+						continue
+					
+					if (not descriptor(token)):
+						print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)
+					else:
+						output += "%s " % token
+					
+					context.add(TO)
+					continue
+				
 				if (BIND in context):
 					if (FIN in context):
 						if (token != ";"):
-							print "%s: Expected ;" % inname
+							print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
 						else:
 							output += "%s" % token
@@ -531,5 +745,5 @@
 					if (VAR in context):
 						if (not descriptor(token)):
-							print "%s: Expected second interface descriptor" % inname
+							print "%s: Expected second interface descriptor in architecture '%s'" % (inname, architecture)
 						else:
 							output += "%s" % token
@@ -541,5 +755,5 @@
 					if (TO in context):
 						if (token != "to"):
-							print "%s: Expected to" % inname
+							print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
 						else:
 							output += "%s " % token
@@ -550,5 +764,5 @@
 					
 					if (not descriptor(token)):
-						print "%s: Expected interface descriptor" % inname
+						print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)
 					else:
 						output += "%s " % token
@@ -560,5 +774,5 @@
 					if (FIN in context):
 						if (token != ";"):
-							print "%s: Expected ;" % inname
+							print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
 						else:
 							output += "%s" % token
@@ -570,5 +784,5 @@
 					if (VAR in context):
 						if (not identifier(token)):
-							print "%s: Expected instance name" % inname
+							print "%s: Expected instance name in architecture '%s'" % (inname, architecture)
 						else:
 							output += "%s" % token
@@ -579,5 +793,5 @@
 					
 					if (not identifier(token)):
-						print "%s: Expected frame/architecture type" % inname
+						print "%s: Expected frame/architecture type in architecture '%s'" % (inname, architecture)
 					else:
 						output += "%s " % token
@@ -588,5 +802,5 @@
 				if (token == "}"):
 					if (indent != 1):
-						print "%s: Wrong number of parentheses" % inname
+						print "%s: Wrong number of parentheses in architecture '%s'" % (inname, architecture)
 					else:
 						indent -= 1
@@ -607,5 +821,15 @@
 					continue
 				
-				print "%s: Unknown token %s in architecture" % (inname, token)
+				if (token == "subsume"):
+					output += "\n%s%s " % (tabs(indent), token)
+					context.add(SUBSUME)
+					continue
+				
+				if (token == "delegate"):
+					output += "\n%s%s " % (tabs(indent), token)
+					context.add(DELEGATE)
+					continue
+				
+				print "%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture)
 				continue
 			
@@ -626,5 +850,5 @@
 				
 				if (not word(token)):
-					print "%s: Expected word" % inname
+					print "%s: Expected word in architecture head '%s'" % (inname, architecture)
 				else:
 					output += "%s " % token
@@ -645,9 +869,14 @@
 		if (SYSTEM in context):
 			if (token != "architecture"):
-				print "%s: Expected architecture" % inname
+				print "%s: Expected 'architecture'" % inname
 			else:
 				output += "%s " % token
 			
 			context.add(ARCH)
+			continue
+		
+		if (token == "frame"):
+			output += "\n%s " % token
+			context.add(FRAME)
 			continue
 		
@@ -667,28 +896,38 @@
 			continue
 		
-		print "%s: Unknown token %s" % (inname, token)
+		print "%s: Unknown token '%s'" % (inname, token)
 	
 	inf.close()
-	
-	return output
-
-def open_adl(base, root, inname, outname):
+
+def open_adl(base, root, inname, outdir, outname):
 	"Open Architecture Description file"
 	
-	context.clear()
+	global output
+	global context
+	global architecture
+	global interface
+	global frame
+	global protocol
+	
+	output = ""
+	context = set()
+	architecture = None
 	interface = None
-	architecture = None
+	frame = None
 	protocol = None
 	
-	adl = parse_adl(base, root, inname, False, 0)
-	if (adl.strip() == ""):
-		adl = "/* Empty */\n"
-	
-	if (os.path.isfile(outname)):
-		print "%s: File already exists, overwriting" % outname
-	
-	outf = file(outname, "w")
-	outf.write(adl.strip())
-	outf.close()
+	parse_adl(base, root, inname, False, 0)
+	output = output.strip()
+	
+	if (output != ""):
+		if (os.path.isfile(outname)):
+			print "%s: File already exists, overwriting" % outname
+		
+		outf = file(outname, "w")
+		outf.write(output)
+		outf.close()
+	else:
+		if (os.path.isfile(outname)):
+			print "%s: File already exists, but should be empty" % outname
 
 def recursion(base, root, output, level):
@@ -704,5 +943,5 @@
 			if (fcomp[-1] == ".adl"):
 				output_path = os.path.join(output, cname[-1])
-				open_adl(base, root, canon, output_path)
+				open_adl(base, root, canon, output, output_path)
 		
 		if (os.path.isdir(canon)):
@@ -710,4 +949,7 @@
 
 def main():
+	global iface_protocols
+	global frame_protocols
+	
 	if (len(sys.argv) < 2):
 		usage(sys.argv[0])
@@ -719,5 +961,14 @@
 		return
 	
+	iface_protocols = {}
+	frame_protocols = {}
+	
 	recursion(".", ".", path, 0)
+	
+	for key, value in iface_protocols.items():
+		dump_iface_bp(key, value, path)
+	
+	for key, value in frame_protocols.items():
+		dump_frame_bp(key, value, path)
 
 if __name__ == '__main__':
Index: contrib/arch/kernel/kernel.adl
===================================================================
--- contrib/arch/kernel/kernel.adl	(revision 2a706725a21e1767f49f217b4694ede563b20ee3)
+++ contrib/arch/kernel/kernel.adl	(revision ee5b35ae379e113674cdd8fd1e5e1ba75d7ef2b6)
@@ -12,8 +12,8 @@
 interface kernel_console {
 		/* Enable kernel console */
-		uintptr_t sys_debug_enable_console(void);
+		unative_t sys_debug_enable_console(void);
 		
 		/* Disable kernel console */
-		uintptr_t sys_debug_disable_console(void);
+		unative_t sys_debug_disable_console(void);
 	protocol:
 		?sys_debug_enable_console +
Index: contrib/arch/uspace/srv/devmap/devmap.adl
===================================================================
--- contrib/arch/uspace/srv/devmap/devmap.adl	(revision 2a706725a21e1767f49f217b4694ede563b20ee3)
+++ contrib/arch/uspace/srv/devmap/devmap.adl	(revision ee5b35ae379e113674cdd8fd1e5e1ba75d7ef2b6)
@@ -47,5 +47,5 @@
 		
 		/* Get an array of (device_name, handle) pairs */
-		ipcarg_t device_get_devices(out_copy stream data)
+		ipcarg_t device_get_devices(out_copy stream data);
 		
 		/* Close connection */
Index: contrib/arch/uspace/srv/fs/devfs/devfs.adl
===================================================================
--- contrib/arch/uspace/srv/fs/devfs/devfs.adl	(revision 2a706725a21e1767f49f217b4694ede563b20ee3)
+++ contrib/arch/uspace/srv/fs/devfs/devfs.adl	(revision ee5b35ae379e113674cdd8fd1e5e1ba75d7ef2b6)
@@ -1,5 +1,5 @@
 frame devfs {
 	provides:
-		fs fs
+		fs fs;
 	requires:
 		[/uspace/lib/libc/requires]
Index: contrib/arch/uspace/srv/fs/fat/fat.adl
===================================================================
--- contrib/arch/uspace/srv/fs/fat/fat.adl	(revision 2a706725a21e1767f49f217b4694ede563b20ee3)
+++ contrib/arch/uspace/srv/fs/fat/fat.adl	(revision ee5b35ae379e113674cdd8fd1e5e1ba75d7ef2b6)
@@ -1,5 +1,5 @@
 frame fat {
 	provides:
-		fs fs
+		fs fs;
 	requires:
 		[/uspace/lib/libc/requires]
Index: contrib/arch/uspace/srv/fs/tmpfs/tmpfs.adl
===================================================================
--- contrib/arch/uspace/srv/fs/tmpfs/tmpfs.adl	(revision 2a706725a21e1767f49f217b4694ede563b20ee3)
+++ contrib/arch/uspace/srv/fs/tmpfs/tmpfs.adl	(revision ee5b35ae379e113674cdd8fd1e5e1ba75d7ef2b6)
@@ -1,5 +1,5 @@
 frame tmpfs {
 	provides:
-		fs fs
+		fs fs;
 	requires:
 		[/uspace/lib/libc/requires]
