Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arrays.equals and nullabe TerminalNodes #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

exaV
Copy link

@exaV exaV commented Apr 16, 2018

implemented Arrays.equals for nullable and primitive integer types.

TerminalNodes from ContextTokenGetter are nullable

@ftomassetti
Copy link
Owner

There is a compilation error:

e: /home/travis/build/ftomassetti/antlr-kotlin/antlr-kotlin-examples-jvm/src/test/kotlin/MiniCalcParserTest.kt: (76, 34): Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type TerminalNode?

Copy link
Owner

@ftomassetti ftomassetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things to revise but it seems we are on the good direction

return equals(a!!, b!!)
}

expect class BitSet() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove the constructor from BitSet?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only moved the constructor so it is right after the classname 'BitSet()'. There is no difference semantically.

val a = o as ArrayPredictionContext?
TODO()
//return Arrays.equals(returnStates, a!!.returnStates) && Arrays.equals(parents, a.parents)
o as ArrayPredictionContext
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why casting it if we do not save it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the compiler can infer the type later. IntelliJ uses the same trick when generating equals(). Maybe it's a hack, I'm not sure.

@@ -705,11 +705,11 @@ RuleContextDecl(r) ::= "var <r.name>: <r.ctxName>? = null"
RuleContextListDecl(rdecl) ::= "var <rdecl.name> : MutableList\<<rdecl.ctxName>> = ArrayList\<<rdecl.ctxName>>()"

ContextTokenGetterDecl(t) ::=
"fun <t.name>() : TerminalNode = getToken(<parser.name>.Tokens.<t.name>.id, 0) as TerminalNode"
"fun <t.name>() : TerminalNode? = getToken(<parser.name>.Tokens.<t.name>.id, 0)"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably making these types nullable is causing the compilation issue we see on Travis

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I probably need to update some of the dependent code as well.

sourceSets {
generated {
kotlin.srcDir 'generated-src/antlr/'
}
}
compileKotlin.source sourceSets.generated.kotlin, sourceSets.main.kotlin

clean{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants