https://kotlinlang.org logo
#announcements
Title
# announcements
e

edik

08/28/2017, 12:42 PM
Hi guys, given that I needed to declare a fun before referencing it I wondered is the Kotlin grammar LL(k) conformant? Perhaps even LL(1)? in terms of syntax analysis, and is there a grammar reference in some notation available seeing that their isn't a KLS 🙂 ?
k

karelpeeters

08/28/2017, 12:44 PM
Don't know what class it belongs to, I image they went with a handwritten recursive descent parser like many languages.
e

edik

08/28/2017, 12:45 PM
ahhha.. thanks 🙂 Haven't read BNF since the Algol-60 spec... 🙂 🙂
If it's LL(k) I'd guess a recursive descent parser...
Though you absolutely don't need to define a function before you use it, in fact it's often cleaner to use it before you declare it
Also the grammar wouldn't matter for that, stuff like "is this function defined" doesn't fit in a context-free grammer, that's handled in the semantic analysis later.
e

edik

08/28/2017, 12:51 PM
of course you are correct here.. My bad.. it has been some years since my degree 🙂
k

karelpeeters

08/28/2017, 12:51 PM
I just got all this stuff from Wikipedia 😛
e

edik

08/28/2017, 12:52 PM
I might have to delve into the source code 👍
3 Views