\startluacode
     thirddata          = thirddata or { }
     local comments     = { filters = { } }
     thirddata.comments = comments

     local textlineactions = resolvers.openers.helpers.textlineactions
     local sequencers      = utilities.sequencers
     local constants       = interfaces.constants

     local gsub, find, format = string.gsub, string.find, string.format

     function comments.install(name,settings)
         local settings = utilities.parsers.settings_to_hash(settings)
         local start = string.escapedpattern(settings[constants.start] or "")
         local stop  = string.escapedpattern(settings[constants.stop] or "")
         local any   = ".-"
         if start ~= "" and stop ~= "" then
            local strip_inline = function(s) return gsub(s, start .. any .. stop, "", 1) end
            local strip_start  = function(s) return gsub(s, start .. any,         "", 1) end
            local strip_stop   = function(s) return gsub(s, "^"   .. any .. stop, "", 1) end 
            local insideComment = false 
            comments.filters[name] = function(s)
                local filter = comments.filters[name]
                if s == "" then
                    return s
                elseif insideComment then
                    if find(s,stop) then
                        insideComment = false
                        return filter(strip_stop(s))
                    else
                        return ""
                    end
                elseif find(s,start) then
                    if find(s, stop) then
                        return filter(strip_inline(s))
                    else
                        insideComment = true 
                        return strip_start(s)
                    end
                else
                    return s
                end
             end
             sequencers.appendaction(textlineactions,"after",format("thirddata.comments.filters.%s",name))
             comments.disable(name)
         end
     end

     function comments.enable(name)
        sequencers.enableaction(textlineactions,format("thirddata.comments.filters.%s",name))
     end

     function comments.disable(name)
        sequencers.disableaction(textlineactions,format("thirddata.comments.filters.%s",name))
     end

\stopluacode

\unprotect

\unexpanded\def\installcomments{\dodoubleargument\doinstallcomments}

\def\doinstallcomments[#1][#2]%
    {\ctxlua{thirddata.comments.install(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}}

\unexpanded\def\enablecomments[#1]%
   {\ctxlua{thirddata.comments.enable (\!!bs#1\!!es)}}

\unexpanded\def\disablecomments[#1]%
   {\ctxlua{thirddata.comments.disable(\!!bs#1\!!es)}}

\protect

\installcomments[test] [start=/*,stop=*/]

\starttext
\enablecomments[test]

\section{Test of /*inline*/ comments}
/* Test for multiline comments
 * to see if they work
 */

Another test for /* inline comments */ with multiple /* commented lines
that span /* false nested comments as well */ to see if it works

\stoptext
