From ed.vandoorn at ou.nl Wed Jun 14 09:08:18 2023 From: ed.vandoorn at ou.nl (Doorn, Ed van) Date: Wed, 14 Jun 2023 09:08:18 -0000 Subject: unclear grammar java 20 Message-ID: Part of my research is detecting design patterns in Java sources. Therefore it is necessary to parse Java sources I used the grammar specified in https://docs.oracle.com/javase/specs/jls/se20/html/index.html. First, I made the grammar useful for the bottom-up parser generator cup (http://www2.cs.tum.edu/projects/cup/) This resulted in more than 100 shifts/reduce and reduce/reduce conflicts. Reduce/reduce conflicts and suggest grammar mistakes. Second, I made the grammar useful for the top-down parser generator Grammatica (https://grammatica.percederberg.net). This resulted in many errors because the LL () grammar is not valid. An example: The production rule for ClassOrInterfaceType and ClassType is: ClassOrInterfaceType: ClassType InterfaceType ClassType: {Annotation} TypeIdentifier [TypeArguments] PackageName . {Annotation} TypeIdentifier [TypeArguments] ClassOrInterfaceType . {Annotation} TypeIdentifier [TypeArguments] This results in an infinite loop: ClassOrInterfaceType produces a ClassType and ClassType produces ClassOrInterfaceType ..... Some production rules have more than one alternative which starts with @ which is not valid LL and can not be solved by looking ahead with more tokens. Is a valid bottom-up grammar e.g. LALR(1) of top-down grammar LL(k) available? ANTLR provides a LL() grammar for Java 9, that is of course out of date. With regards, Ed van Doorn -------------- next part -------------- An HTML attachment was scrubbed... URL: From pravin at zensoftech.co.in Fri Jun 23 09:37:21 2023 From: pravin at zensoftech.co.in (Pravin) Date: Fri, 23 Jun 2023 09:37:21 -0000 Subject: typo in JLS 20 Message-ID: <188e79d6a4b.21efb348623976.900052122439105888@zensoftech.co.in> Hello sir/madam, In the last para on page 44. the following sentence Supplementary characters must be represented either as a surrogate pair within a char sequence, or as an integer, depending on the API they are used with. may be replaced with Supplementary characters must be represented either as a surrogate pair within a java.lang.CharSequence, or as an integer, depending on the API they are used with. regards, Pravin -------------- next part -------------- An HTML attachment was scrubbed... URL: