Talk:Strip block comments: Difference between revisions

Content added Content deleted
(→‎Badly defined task: new section)
(→‎Badly defined task: I just took it as read.)
Line 48: Line 48:


Stripping comments generally requires knowledge of the language involved. Simply taking out COMMENT_BEGIN up to COMMENT_END won't garantee what's left still conform to syntax (due to nested comment, markers being part of a literal string, etc), the only proper way is by parsing the text according the syntax, which is no doubt too much work. As an example, the C code can't strip its own source properly, which is pretty comedic. --[[User:Ledrug|Ledrug]] 06:57, 12 August 2011 (UTC)
Stripping comments generally requires knowledge of the language involved. Simply taking out COMMENT_BEGIN up to COMMENT_END won't garantee what's left still conform to syntax (due to nested comment, markers being part of a literal string, etc), the only proper way is by parsing the text according the syntax, which is no doubt too much work. As an example, the C code can't strip its own source properly, which is pretty comedic. --[[User:Ledrug|Ledrug]] 06:57, 12 August 2011 (UTC)

:I guess you have to think of it in the context where stripping out those comments in the prescribed fashion leaves behind viable text?
:I have used domain-specific languages where the comment syntax was purposely defined so that simple scripts could strip them out successfully. They didn't allow nested comments and had a rule where either the whole of the comment where to be treated as a single space or the whole of the comment where to be treated as deleted and could merge text either-side of it to form a token. --[[User:Paddy3118|Paddy3118]] 07:18, 12 August 2011 (UTC)