Jelajahi Sumber

Allow consecutive import sections

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8213 8c9fc860-2736-0410-a75d-ab315db34111
negelef 7 tahun lalu
induk
melakukan
51c1e799d4
2 mengubah file dengan 7 tambahan dan 7 penghapusan
  1. 5 5
      source/FoxParser.Mod
  2. 2 2
      source/Oberon.Compilation.Test

+ 5 - 5
source/FoxParser.Mod

@@ -10,7 +10,7 @@ CONST
 	(** the parser reflects the following EBNF:
 
 		Module = ('module' | 'cellnet' [Flags]) Identifier ['in' Identifier]';' 
-								[ImportList] DeclarationSequence [Body] 
+								{ImportList} DeclarationSequence [Body] 
 								'end' Identifier '.'.
 		   
 		ImportList = 'import' Import { ',' Import } ';'.
@@ -1547,7 +1547,7 @@ TYPE
 			RETURN pointerType
 		END ObjectType;
 		
-		(** CellType = 'cell' [Flags] [PortList] [';'] DeclarationSequence [Body] 'end' [Identifier]
+		(** CellType = 'cell' [Flags] [PortList] [';'] {ImportList} DeclarationSequence [Body] 'end' [Identifier]
               | 'object'. **)
 		PROCEDURE CellType(position: Position;  name: SyntaxTree.Identifier; parentScope: SyntaxTree.Scope; isCellNet: BOOLEAN): SyntaxTree.Type;
 		VAR
@@ -1584,7 +1584,7 @@ TYPE
 			IF Optional( Scanner.Semicolon ) THEN END;
 
 			
-			IF Optional(Scanner.Import) THEN ImportList(cellScope) END;
+			WHILE Optional(Scanner.Import) DO ImportList(cellScope) END;
 			DeclarationSequence( cellScope);
 			IF Peek(Scanner.Begin) OR Peek(Scanner.Code) THEN
 				cellScope.SetBodyProcedure(BodyProcedure(cellScope));
@@ -2370,7 +2370,7 @@ TYPE
 		END ImportList;
 
 		(** Module = ('module' | 'cellnet' [Flags]) Identifier ['in' Identifier]';' 
-										[ImportList] DeclarationSequence [Body] 
+										{ImportList} DeclarationSequence [Body] 
 										'end' Identifier '.'.
 		**)
 
@@ -2411,7 +2411,7 @@ TYPE
 					recentComment := NIL;
 				END;
 
-				IF Optional(Scanner.Import) THEN ImportList(moduleScope) END;
+				WHILE Optional(Scanner.Import) DO ImportList(moduleScope) END;
 				DeclarationSequence( moduleScope);
 				IF Peek(Scanner.Begin) OR Peek(Scanner.Code) THEN
 					moduleScope.SetBodyProcedure(BodyProcedure(moduleScope)); (* insert empty body procedure if necessary *)

+ 2 - 2
source/Oberon.Compilation.Test

@@ -227,7 +227,7 @@ positive: multiple module import
 	IMPORT A := Dummy, B := Dummy, C := Dummy, D := Dummy;
 	END Test.
 
-negative: multiple import lists
+positive: multiple import lists
 
 	MODULE Test;
 	IMPORT A := Dummy;
@@ -952,7 +952,7 @@ negative: procedure with parameter missing type
 
 # intermixed section types
 
-negative: import section before import section
+positive: import section before import section
 
 	MODULE Test;
 	IMPORT A := Dummy;