jison icon indicating copy to clipboard operation
jison copied to clipboard

Use URLs as terms

Open juniorjp opened this issue 8 years ago • 1 comments

I'm trying to define the following regex as a term:

/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/   return 'TERM'

But it's not working. Any way to accomplish this?

juniorjp avatar Jun 29 '17 17:06 juniorjp

This is an error report from bleeding edge GerHobbelt/jison, which gives a hint what's wrong:

JisonLexerError: Lexical error on line 7: unsupported lexer input: ":" while lexing rules
       (i.e. jison lex regexes).

       NOTE: When you want the input ":" to be interpreted as a literal part
       of a lex rule regex, you MUST enclose it in double or single quotes,
       e.g. as shown in this error message just before. If not, then know
       that this is not accepted as a regex operator here in
       jison-lex rules.

       Offending input:
    ...tp|https)[:]\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!...
    -----------------------^ 

Note that the first 'literal' : has already been "patched" in a different way suitable for any regex. 😉

GerHobbelt avatar Jul 31 '17 01:07 GerHobbelt