Ver Fonte

procedure ending ident is optional in Eberon

Vladislav Folts há 10 anos atrás
pai
commit
3ec2ef1f97

+ 1 - 1
src/eberon/eberon_grammar.js

@@ -52,7 +52,7 @@ function makeDesignator(ident, qualident, selector, actualParameters){
 function makeProcedureDeclaration(ident, procedureHeading, procedureBody){
     return context(and(procedureHeading, ";",
                        procedureBody,
-                       and(ident, optional(and(".", ident)))),
+                       optional(and(ident, optional(and(".", ident))))),
                    EbContext.ProcOrMethodDecl);
 }
 

+ 1 - 2
test/test_unit.js

@@ -1196,8 +1196,7 @@ return {
          "PROCEDURE p(a: INTEGER); BEGIN p(a) END p",
          "PROCEDURE p(a: INTEGER; b: BOOLEAN); BEGIN p(a, b) END p",
          "PROCEDURE p(): ProcType; RETURN p END p"),
-    fail(["PROCEDURE p; END", "not parsed"],
-         ["PROCEDURE p1; END p2",
+    fail(["PROCEDURE p1; END p2",
           "mismatched procedure names: 'p1' at the begining and 'p2' at the end"],
          ["PROCEDURE p(a: INTEGER); VAR a: INTEGER END p", "'a' already declared"],
          ["PROCEDURE p(a: INTEGER); BEGIN p() END p", "1 argument(s) expected, got 0"],

+ 5 - 1
test/test_unit_eberon.js

@@ -1030,5 +1030,9 @@ exports.suite = {
                 fail(["a.clear(0)", "0 argument(s) expected, got 1"])
             )
         }
-    }
+    },
+"syntax relaxation": testWithGrammar(
+    grammar.declarationSequence, 
+    pass("PROCEDURE p; END;")
+    )
 };

+ 5 - 0
test/test_unit_oberon.js

@@ -101,4 +101,9 @@ exports.suite = {
     pass(),
     fail(["PROCEDURE p(s: ARRAY OF CHAR); BEGIN s := \"abc\" END p", "cannot assign to read-only variable"])
     ),
+"procedure": testWithGrammar(
+    grammar.procedureDeclaration,
+    pass(),
+    fail(["PROCEDURE p; END", "not parsed"])
+    )
 };