<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Hi Ed,
<div><br>
</div>
<div>Thanks for your email. Whilst I can imagine that such a thing would be useful, I’m afraid that we make no claims that the grammar in the JLS is suitable for plugging directly into a parser generator or any other tool. Indeed there are places in the JLS
 where the grammar is used to capture semantic rather than syntactic issues, and places where we impose semantic rather than syntactic restrictions. </div>
<div><br>
</div>
<div>Thanks,</div>
<div>Gavin</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<blockquote type="cite">
<div>On 14 Jun 2023, at 10:08, Doorn, Ed van <ed.vandoorn@ou.nl> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div class="elementToProof" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
Part of my research is detecting design patterns in Java sources.</div>
<div class="elementToProof" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
Therefore it is necessary to parse Java sources</div>
<div class="elementToProof" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
I used the grammar specified in <a href="https://docs.oracle.com/javase/specs/jls/se20/html/index.html" id="LPlnk584635">https://docs.oracle.com/javase/specs/jls/se20/html/index.html</a>.</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
First, I made the grammar useful for the bottom-up parser generator cup (<a href="http://www2.cs.tum.edu/projects/cup/" id="LPlnk249011">http://www2.cs.tum.edu/projects/cup/</a>)</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
This resulted in more than 100 shifts/reduce and reduce/reduce conflicts.</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
Reduce/reduce conflicts and suggest grammar mistakes.</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
Second, I made the grammar useful for the top-down parser generator Grammatica (<a href="https://grammatica.percederberg.net/">https://grammatica.percederberg.net</a>).</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
This resulted in many errors because the LL () grammar is not valid.</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
An example:</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
The production rule for ClassOrInterfaceType and ClassType is:</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<span class="lhs ContentPasted3" style="font-family: monospace; font-size: 12px; font-style: italic; background-color: rgb(211, 211, 211);">ClassOrInterfaceType:</span>
<div class="rhs" style="margin-left: 1em; font-family: monospace; font-size: 12px; font-style: italic; background-color: rgb(211, 211, 211);">
<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-4.html#jls-ClassType" title="ClassType" class="ContentPasted3" data-loopstyle="link">ClassType</a><br class="ContentPasted3">
<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-4.html#jls-InterfaceType" title="InterfaceType" class="ContentPasted3">InterfaceType</a></div>
<br>
</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<span class="lhs ContentPasted2" style="font-family: monospace; font-size: 12px; font-style: italic; background-color: rgb(211, 211, 211);">ClassType:</span>
<div class="rhs ContentPasted2" style="margin-left: 1em; font-family: monospace; font-size: 12px; font-style: italic; background-color: rgb(211, 211, 211);">
{<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-9.html#jls-Annotation" title="Annotation" class="ContentPasted2" data-loopstyle="link">Annotation</a>}<span class="ContentPasted2"> </span><a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-3.html#jls-TypeIdentifier" title="TypeIdentifier" class="ContentPasted2">TypeIdentifier</a><span class="ContentPasted2"> </span>[<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-4.html#jls-TypeArguments" title="TypeArguments" class="ContentPasted2">TypeArguments</a>]<br class="ContentPasted2">
<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-6.html#jls-PackageName" title="PackageName" class="ContentPasted2">PackageName</a><span class="ContentPasted2"> </span><code class="literal ContentPasted2" style="font-style: normal;">.</code><span class="ContentPasted2"> </span>{<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-9.html#jls-Annotation" title="Annotation" class="ContentPasted2">Annotation</a>}<span class="ContentPasted2"> </span><a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-3.html#jls-TypeIdentifier" title="TypeIdentifier" class="ContentPasted2">TypeIdentifier</a><span class="ContentPasted2"> </span>[<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-4.html#jls-TypeArguments" title="TypeArguments" class="ContentPasted2">TypeArguments</a>]<br class="ContentPasted2">
<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-4.html#jls-ClassOrInterfaceType" title="ClassOrInterfaceType" class="ContentPasted2">ClassOrInterfaceType</a><span class="ContentPasted2"> </span><code class="literal ContentPasted2" style="font-style: normal;">.</code><span class="ContentPasted2"> </span>{<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-9.html#jls-Annotation" title="Annotation" class="ContentPasted2">Annotation</a>}<span class="ContentPasted2"> </span><a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-3.html#jls-TypeIdentifier" title="TypeIdentifier" class="ContentPasted2">TypeIdentifier</a><span class="ContentPasted2"> </span>[<a href="https://docs.oracle.com/javase/specs/jls/se20/html/jls-4.html#jls-TypeArguments" title="TypeArguments" class="ContentPasted2">TypeArguments</a>]</div>
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
This results in an infinite loop: ClassOrInterfaceType produces a ClassType and  ClassType produces </div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
ClassOrInterfaceType .....</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
Some production rules have more than one alternative which starts with @</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
which is not valid LL and can not be solved by looking ahead with more tokens.</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
Is a valid bottom-up grammar e.g. LALR(1) of top-down grammar LL(k) available?<br>
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
ANTLR provides a LL() grammar for Java 9, that is of course out of date.</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
With regards,</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
Ed van Doorn</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>