metalua-parser icon indicating copy to clipboard operation
metalua-parser copied to clipboard

Better documentation for AST format

Open agladysh opened this issue 10 years ago • 6 comments

Right now it takes some thought and specialized debug printing to guess, how exactly a given AST node data is laid out.

It would be cool if the documentation would give more detailed examples for AST nodes — both for Lua code and for resulting data, including corner-cases.

Since debug printing actually solves this, this is a low priority nice-to-have request :-)

agladysh avatar Dec 23 '13 21:12 agladysh

The proper way to address this is through a sample which pretty-prints the AST corresponding to any given code fragment. But it would force to embed more dependencies (at least the table pretty printer). On Dec 23, 2013 10:20 PM, "Alexander Gladysh" [email protected] wrote:

Right now it takes some thought and specialized debug printing to guess, how exactly a given AST node data is laid out.

It would be cool if the documentation would give more detailed examples for AST nodes — both for Lua code and for resulting data, including corner-cases.

Since debug printing actually solves this, this is a low priority nice-to-have request :-)

— Reply to this email directly or view it on GitHubhttps://github.com/fab13n/metalua-parser/issues/7 .

fab13n avatar Dec 23 '13 21:12 fab13n

While it would be nice to have such tool, I'm not sure if it is the proper way. You can't beat the formal documentation in this case, IMHO :-)

BTW, I think that it is OK for examples to have extra dependencies — as long as the main rockspec doesn't install them.

On Tue, Dec 24, 2013 at 1:32 AM, Fleutot [email protected] wrote:

The proper way to address this is through a sample which pretty-prints the AST corresponding to any given code fragment. But it would force to embed more dependencies (at least the table pretty printer). On Dec 23, 2013 10:20 PM, "Alexander Gladysh" [email protected] wrote:

Right now it takes some thought and specialized debug printing to guess, how exactly a given AST node data is laid out.

It would be cool if the documentation would give more detailed examples for AST nodes — both for Lua code and for resulting data, including corner-cases.

Since debug printing actually solves this, this is a low priority nice-to-have request :-)

— Reply to this email directly or view it on GitHub< https://github.com/fab13n/metalua-parser/issues/7> .

— Reply to this email directly or view it on GitHubhttps://github.com/fab13n/metalua-parser/issues/7#issuecomment-31145058 .

agladysh avatar Dec 23 '13 21:12 agladysh

Added a pretty-printing library, for proper rendering of ASTs. I think it's arguably one of the basic tools needed for AST manipulations. I Will document & port unit tests, create a script that translates Lua chunk sources into rendered AST.

fab13n avatar Dec 27 '13 21:12 fab13n

Remember "json library" argument at the Workshop? :-)

Everybody already has own pretty-printing library.

Me too — and I want to keep using mine, not yours. But I do not oppose your decision too strongly, it is not that much code.

agladysh avatar Dec 27 '13 21:12 agladysh

You know the http client syndrome? The simpler a task seems, the more its implementation attempts suck in practice.

Last time I checked, no pretty printer handled cycles, line returns, indentation etc. properly.

Maybe it should be offered as a separate rock? On Dec 27, 2013 10:52 PM, "Alexander Gladysh" [email protected] wrote:

Remember "json library" argument at the Workshop? :-)

Everybody already has own pretty-printing library.

— Reply to this email directly or view it on GitHubhttps://github.com/fab13n/metalua-parser/issues/7#issuecomment-31281761 .

fab13n avatar Dec 28 '13 05:12 fab13n

Good idea.

On Sat, Dec 28, 2013 at 9:19 AM, Fleutot [email protected] wrote:

You know the http client syndrome? The simpler a task seems, the more its implementation attempts suck in practice.

Last time I checked, no pretty printer handled cycles, line returns, indentation etc. properly.

Maybe it should be offered as a separate rock? On Dec 27, 2013 10:52 PM, "Alexander Gladysh" [email protected] wrote:

Remember "json library" argument at the Workshop? :-)

Everybody already has own pretty-printing library.

— Reply to this email directly or view it on GitHub< https://github.com/fab13n/metalua-parser/issues/7#issuecomment-31281761> .

— Reply to this email directly or view it on GitHubhttps://github.com/fab13n/metalua-parser/issues/7#issuecomment-31290793 .

agladysh avatar Dec 28 '13 06:12 agladysh