logos icon indicating copy to clipboard operation
logos copied to clipboard

Help needed: matching Python-like multiline strings

Open elenakrittik opened this issue 2 years ago • 4 comments

Every single regex i could find uses either globals flags or lookaround, neither of which are supported by logos (to my knowledge, at least). Syntax like [^(""")] (NOT group of symbols) is not supported by regex itself, though even if it was i'm pretty sure it'll fall into the lookahead category and therefore would still not be supported by logos. CAD97's C-style block comment regex is pretty much incompatible with Python-like block comments, where comment start and comment end are all the same characters. I imagine this can be possible with a lot of boilerplate around extras, or via postprocessing, but before going with these i'd like to ask if anyone encountered the same problem and got a solution. Any help is greatly appreciated!

elenakrittik avatar Jul 28 '23 20:07 elenakrittik

Hello! I am afraid it is not possible by just using regexes. This is a bit the limitation of not using look-around and so on: you gain performances at the cost of fewer features. But I think it's relatively easy to implement a callback function with Extras that handle triple quotes.

jeertmans avatar Aug 02 '23 15:08 jeertmans

Hello! I am afraid it is not possible by just using regexes. This is a bit the limitation of not using look-around and so on: you gain performances at the cost of fewer features. But I think it's relatively easy to implement a callback function with Extras that handle triple quotes.

can you give an example?

hyperswine avatar Sep 03 '23 16:09 hyperswine

I think there are some examples if you search the issues or the examples directory… but I don’t have one example to show right now unfortunately :/

jeertmans avatar Sep 05 '23 12:09 jeertmans

I haven't done that yet, but it seems like using a sublexer (see #61) for this would be the best way.

elenakrittik avatar Sep 05 '23 18:09 elenakrittik