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

Running at command line or as gradle task #44

Open
saintjab opened this issue Jun 29, 2021 · 1 comment
Open

Running at command line or as gradle task #44

saintjab opened this issue Jun 29, 2021 · 1 comment
Labels
feedback waiting for feedback question Further information is requested

Comments

@saintjab
Copy link

Hi, thanks for this tool. This is really a question and not an issue as am not conversant with ASTs. Is this something that can be run from the command line or as gradle task? If possible (gradle better), could you give me some pointers? At the moment am running this as a unit test and printing the output to a file to be checked later. Ideally, I want to create a gradle task pointing to a dir to load all files in there and print this AST output to a file for analysis later on.

@saintjab saintjab changed the title Running at command line Running at command line or as gradle task Jun 29, 2021
@drieks
Copy link
Collaborator

drieks commented Jun 29, 2021

Hi @saintjab,

the unittest for kotlinx.ast are implemented in this way, a normal unittest that will read a file, parse the ast and then it will dump it.

You can find this test files here:
https://github.com/kotlinx/ast/tree/master/grammar-kotlin-parser-test/src/commonMain/resources/testdata

*.kt.txt is the given test data
*.raw.ast.txt the the raw ast as returned by antlr
*.raw.info.txt contains line numbers
*.summary.ast.txt the ast after calling summary
*.summary.info.txt line numbers after calling sumary

The test is implemented here: https://github.com/kotlinx/ast/blob/master/grammar-kotlin-parser-antlr-java/src/test/kotlin/kotlinx/ast/grammar/kotlin/target/antlr/java/test/KotlinGrammarAntlrJavaParserTestDataTest.kt
But you have to look into the base classes if you want to see how it is working.
Different antlr version are tested, so there is one test per parser (antlr java, antlr kotlin, antlr optimized) and grammar (for example the kotlin parser)

It is possible to used it from gradle, but you have to implement everything ourselves. I'm using a kotlin main function to call my private code parser project from the command line. I think this is the easiest way.

@drieks drieks added feedback waiting for feedback github_actions Pull requests that update Github_actions code question Further information is requested and removed github_actions Pull requests that update Github_actions code labels Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback waiting for feedback question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants