Comments are part of the syntax and should be parsed as such however.  
Personally I'd opt for an OCaml-style handling of comments where the 
comments get turned into a meta attribute on the related tag, which for 
elixir could be as simple as wrapping the related comment part in something 
like `{:__block__, [comment: "...", line: ..., ...]. [original]}` for any 
potentially multiple lines worth of comments.  With this the comments get 
directly 'assigned' to something (in OCaml it's the next following 
expression), which might have meaning to some tools, say documentation or 
some tests or so.

On Sunday, September 16, 2018 at 11:35:50 AM UTC-6, José Valim wrote:
>
> This is really, really hard to do because it would overcomplicate the 
> language grammar, as it would have to take comments into account at every 
> step. I am not even sure if it is possible. If someone wants to try it out 
> though. :)
>
> That's why most tools end-up handling comments on the side, separated from 
> parsing.
>
> *José Valim*
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Director of R&D
>
> On Sun, Sep 16, 2018 at 6:59 PM, Steve Morin <steve...@gmail.com 
> <javascript:>> wrote:
>
>> Wanted to see what peoples thoughts are about adding comments to the 
>> AST.  
>>
>> One use-case is to be able to parse and manipulate Source files outside 
>> of just macros but in that case you would want to be able to preserve 
>> comments.  
>>
>> E.g. Read a source file, manipulate it, write that source file back to a 
>> file.  
>>
>> This would allow people/tooling to use elixir to parse and manipulate 
>> source files.
>>
>> If this might disturb existing consumers of the AST maybe this could be 
>> added as a option to existing Macro functions so that I could be turned on 
>> for people with this use-case. 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "elixir-lang-core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to elixir-lang-co...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/elixir-lang-core/955237D8-31DE-448C-9777-1104F1175DC7%40gmail.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/89df003f-33a3-4913-9756-7b3c29f736d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to