kotlinx / ast

Generic AST parsing library for kotlin multiplatform
Apache License 2.0
324 stars 22 forks source link

KotlinGrammarAntlrKotlinParser very slow for files with json-strings #50

Closed fab1an closed 2 years ago

fab1an commented 3 years ago

Creating a file like this:

package testpackage.

val LARGE_JSON = """
     <very large json with 77000 lines>
"""

Running

val source = AstSource.String("", stringSource)
val kotlinFile = KotlinGrammarAntlrKotlinParser.parseKotlinFile(source)

takes very long on a file like this. If I replace the JSON in the string with base64, it will be much faster. Does the grammar somehow inspect the braces inside the templating?

fab1an commented 3 years ago

Any news on this?

drieks commented 3 years ago

Hi @fab1an,

sorry for the missed answer. I think this is related to #3. Sadly I have currently no time to work on this :-/

fab1an commented 3 years ago

@drieks What I find interesting is that parsing json inside a string is very slow (maybe due to templating literals), whereas parsing a garbage-base64 string is fast.

drieks commented 2 years ago

Duplicate of #3