Kotlin / kotlin-spec

Kotlin Language Specification:
https://kotlinlang.org/spec
Apache License 2.0
387 stars 80 forks source link

Grammar: KotlinParser.g4:311:0: rule statements contains a closure with at least one alternative that can match EOF #103

Closed bennyhuo closed 2 years ago

bennyhuo commented 2 years ago

I seems to be related to this declaration:

statements
    : (statement (semis statement)*)? semis?
    ;

After I cloned the project, I ran ./gradlew :grammar:generateGrammarSource and got this error. Parser cannot be generated.

bennyhuo commented 2 years ago

This is caused by a newer version of antlr lib.

antlr - The Antlr libraries to be used for this project.
\--- org.antlr:antlr4:4.+ -> 4.10.1

Force the version to 4.4.0 solve the problem.

KvanTTT commented 2 years ago

The diagnositcs was introduced to prevent stackoverflow on EOF closures: https://github.com/antlr/antlr4/issues/3359 I'll fix the grammar ASAP.

KvanTTT commented 2 years ago

@petukhovv what the meaning of EOF inside semi and semis? I suggest removing since root rules kotlinFile and script already have EOF at the end. It looks excessive.

belyaev-mikhail commented 2 years ago

It is not. Please run grammar tests before suggesting such changes.

belyaev-mikhail commented 2 years ago

On the second thought, it may be ok since we don't anymore have any rules that end with semi without ?

All that do contain a raw SEMICOLON token