some further progress... I changed the regex matching to inline in the parser-rule, as follows:
regex_constraint: '/' regex1 '/' | '^' regex2 '^' ;
regex1: ( '_' | '.*' | '\\.' | '\\/' | ~'/' )+ ; // TODO: not clear why first 4 matches are needed, but they work.
This actually does work (i..e now regexes enclosed in // are disambiguated from paths that contain slashes) - I don't yet understand what the lexer is doing behind the scenes when a literal is found in a parse rule, but I assume that if that literal can be found at the current point in the input stream, it trumps any other lexer pattern matching. Anyway, in the above, I originally just had:
regex1: ( '\\/' | ~'/' )+ ;
i.e. just match quoted slashes, or otherwise, non-slashes. But a regex in the text containing '\.' (quoted dot, i.e. literal dot) wouldn't match, so I added '\\.'. Underscores also don't match, hence the underscore; same for the '.*' pattern.
I don't understand what is going on here, but I assume that the ~'/' in a parse rule doesn't match 'any non-slash', but some smaller set of characters.
thoughts?