camdencheek / tree-sitter-dockerfile

A tree-sitter grammar for Dockerfile
MIT License
71 stars 20 forks source link

simply comments by adding to extras #42

Closed nverno closed 11 months ago

nverno commented 11 months ago

This simplifies comment handling by adding to extras. So, cases like these are also handled

FROM \
 # some image
 image

COPY . \
     # to app
     ./app/ 

There is one test that doesn't pass after the change, but it is only a case where the comment node is nested inside the shell command rather than preceding it.

There seem to be some issues with the grammar, though, for example,

RUN # comment
    # comment
    echo foo

is parsed OK despite first comment not ending with a line continuation, so perhaps the line-continuation / comment precedences need to be changed?