Skip to content

Commit 0a9fd1a

Browse files
committed
dealing with semi-colon in different contexts
1 parent f4c0c42 commit 0a9fd1a

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/lang/java/syntax/Java18.rsc

+12-10
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ syntax ImportDeclaration = importDeclaration: SingleTypeImportDeclaration
138138
| StaticImportOnDemandDeclaration // import static br.unb.rascal.Foo.*;
139139
;
140140

141-
syntax SingleTypeImportDeclaration = "import" TypeName ";" ;
141+
syntax SingleTypeImportDeclaration = "import" TypeName ";"+ ;
142142

143-
syntax TypeImportOnDemandDeclaration = "import" PackageOrTypeName "." "*" ";" ;
143+
syntax TypeImportOnDemandDeclaration = "import" PackageOrTypeName "." "*" ";"+ ;
144144

145-
syntax SingleStaticImportDeclaration = "import" "static" TypeName "." Identifier ";";
145+
syntax SingleStaticImportDeclaration = "import" "static" TypeName "." Identifier ";"+;
146146

147-
syntax StaticImportOnDemandDeclaration = "import" "static" TypeName "." "*" ";" ;
147+
syntax StaticImportOnDemandDeclaration = "import" "static" TypeName "." "*" ";"+ ;
148148

149149

150150
syntax TypeDeclaration = ClassDeclaration ";"*
@@ -173,7 +173,7 @@ syntax Superclass = "extends" ClassType ;
173173

174174
syntax Superinterfaces = "implements" {InterfaceType ","}+ ;
175175

176-
syntax ClassBody = classBody : "{" ClassBodyDeclaration* decls "}" ;
176+
syntax ClassBody = classBody : "{" ClassBodyDeclaration* decls "}" ";"? ;
177177

178178
syntax ClassBodyDeclaration = ClassMemberDeclaration
179179
| InstanceInitializer
@@ -239,7 +239,7 @@ syntax UnannArrayType = UnannPrimitiveType Dims
239239
// |UnannTypeVariable Dims
240240
;
241241

242-
syntax MethodDeclaration = methodDeclaration: MethodModifier* MethodHeader MethodBody ";"?;
242+
syntax MethodDeclaration = methodDeclaration: MethodModifier* MethodHeader MethodBody ;
243243

244244
syntax MethodModifier = Annotation
245245
| "public"
@@ -320,27 +320,28 @@ syntax ExceptionType = ClassType
320320
;
321321

322322

323-
syntax MethodBody = Block
323+
syntax MethodBody = Block ";"*
324324
| ";"
325325
;
326326

327327
syntax InstanceInitializer = Block ;
328328

329-
syntax StaticInitializer = "static" Block ;
329+
syntax StaticInitializer = "static" Block ";"* ;
330330

331331
syntax ConstructorDeclaration = ConstructorModifier* ConstructorDeclarator Throws? ConstructorBody ;
332332

333333
syntax ConstructorModifier = Annotation
334334
| "public"
335335
| "protected"
336336
| "private"
337+
| "strictfp"
337338
;
338339

339340
syntax ConstructorDeclarator = TypeParameters? SimpleTypeName "(" FormalParameterList? ")" ;
340341

341342
syntax SimpleTypeName = Identifier ;
342343

343-
syntax ConstructorBody = "{" ExplicitConstructorInvocation? BlockStatements? "}" ;
344+
syntax ConstructorBody = "{" ExplicitConstructorInvocation? BlockStatements? "}" ";"* ;
344345

345346
syntax ExplicitConstructorInvocation = TypeArguments? "this" "(" ArgumentList? ")" ";"
346347
| TypeArguments? "super" "(" ArgumentList? ")" ";"
@@ -412,6 +413,7 @@ syntax AnnotationTypeMemberDeclaration = AnnotationTypeElementDeclaration
412413
| ConstantDeclaration
413414
| ClassDeclaration
414415
| InterfaceDeclaration
416+
// | InterfaceMemberDeclaration
415417
// | ";"
416418
;
417419

@@ -460,7 +462,7 @@ syntax VariableInitializerList = { VariableInitializer "," }+ ;
460462
* Productions from §14 (Blocks and Statements)
461463
*/
462464

463-
syntax Block = "{" BlockStatements? "}" ;
465+
syntax Block = "{" BlockStatements? "}" ;
464466

465467

466468
syntax BlockStatements = BlockStatement BlockStatement* ;

src/tests/Parser.rsc

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ void parseAllFiles(bool verbose, loc baseDir) {
3232
}
3333
println("... found an error at line <l.begin.line>, column <l.begin.column> ");
3434
nok = nok + 1.0;
35+
}
36+
catch : {
37+
print("[parsing file:] " + s.path);
38+
nok = nok + 1.0;
3539
}
3640
}
3741
real res = ok / (nok + ok);

0 commit comments

Comments
 (0)