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

Add full support for comments

Open daniel-sc opened this issue 6 years ago • 3 comments
trafficstars

Currently comments are removed and do not show up in the AST. For certain use cases (e.g. building a converter from bash to win batch scripts) it'd be useful to have the comments as specific AST elements.

daniel-sc avatar Oct 15 '19 15:10 daniel-sc

Comments are usually only preserved in the concrete syntax tree, and get stripped before producing an AST. I don't think preserving comments should be a goal of this project; we really only want an AST so we can then execute the command in vorpaljs/cash. Preserving comments and whitespace are huge headaches.

https://github.com/nfischer/shelljs-transpiler is a similar project with basic support for comments, although I know there's good chunks of bash missing from that grammar (mainly because that project has to parse and transpile, which slows down progress a bit).

nfischer avatar Oct 18 '19 05:10 nfischer

Comments can be consider like any other token... Main problem with them, they can appear everywhere.

piranna avatar Oct 21 '19 09:10 piranna

What about shebang? #!/usr/bin/node If comments are stripped this at least should be preserved.

jcubic avatar Jul 21 '21 13:07 jcubic