question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grammar rule 'classDeclaration' error

See original GitHub issue

Description

I litterally just copy pasted the 3 kotlin .g4 files and ran grun to check the generated AST using the MutableStack<E> code from the example here : https://play.kotlinlang.org/byExample/01_introduction/06_Generics And it seems like it can’t match the LCURLY bracket of the classBody rule ? Could anyone confirm please

Output + AST

image image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
belyaev-mikhailcommented, Apr 9, 2021

Literally any feedback for the grammar is appreciated as it shows somebody is actively using it =)

1reaction
belyaev-mikhailcommented, Apr 12, 2021

The Inside_ rules are there to distinguish expressions inside parentheses from free-range ones. The Inside_WHATEVER: WHATEVER -> type(WHATEVER); boilerplate code maps them to their non-inside counterparts so they do not need to be referenced anywhere as the token stream will contain the non-Inside variant.

Why do we need to distinguish expressions inside parentheses? Because inside parentheses you can safely ignore newlines and you cannot do that on the top-level. An example of this is, for example, a * b:

a
* b // you cannot do this in Kotlin
(a
* b) // but you can do this!
Read more comments on GitHub >

github_iconTop Results From Across the Web

ANTLR4 can only parse a class statement, not the whole file
classDeclaration() corresponds to the classDeclaration rule, which presumably represents a class declaration, and not the entire program.
Read more >
TMF (Xtext) » Simple Grammar causes ... - Eclipse Community Forums
InternalTestLangParser.rule__ClassDeclaration__MembersAssignment_4( ... meanwhile I found out how to solve the error by rewriting the grammar but the error ...
Read more >
2.2.2 Coco/R - Grammar: package, annotation and interface ...
Coco/R grammar rules are written after the reserved word PRODUCTIONS. ... ClassDeclaration and InterfaceDeclaration is given dummy tokens for the moment, ...
Read more >
[Boost-users] rule.ipp(173) : error C1128: number of sections ...
It looks like, the compiler complaining about the size of the inline code. ... What is the solution to this issue? If I...
Read more >
SashaMazurovSandbox < Sandbox < TWiki
You will see all changes on a real case for ValueWithErrorGrammar (also, ... parameters as // qi::grammar at the class declaration: qi::rule<Iterator, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found