Giter VIP home page Giter VIP logo

Comments (6)

 avatar commented on July 17, 2024 1

Ok, got it working now - I used

[\\]

instead.

According to http://flex.sourceforge.net/manual/Patterns.html#Patterns, Flex used backslashes for escaping, like Perl/JavaScript. The forward slashes are indeed for positive lookaheads, so it looks like they've been correctly mapped. My guess would be that the backslashes are checked individually, replacing successive pairs of backslashes for one, until the final one is replaced by the character following it - so they all disappear.

Cheers,

Marcus.

from jison.

zaach avatar zaach commented on July 17, 2024

Hey simpl,

I'm surprised about #2 -- I'd expect some tests to fail. I'll adress that and #1.

For #3, the Flex (Bison's scanner generator) syntax is a forward slash (/). I'll probably allow both so people coming from either style aren't thrown off. This is essentially the reason I don't copy the regex directly, because I want to support Flex' syntax too.

Thanks for the report. The regex syntax has been out of mind for a while but obviously needs some updates.

from jison.

 avatar commented on July 17, 2024

I just realized that Github ate my backslashes too. Sorry about that.

I'm trying the forward slashes now, but again it doesn't appear to be doing what I want. Forward slashes appear to translate to ?=, i.e. positive lookaheads.

Is it possible to get a double-backslash in the resulting JavaScript regex (i.e. matching a single literal backslash)? If so, could you tell me how.

I think that it would be a good idea to allow both Flex and JavaScript regexes. You could perhaps have a setting somewhere to let the users choose between the two. Also, if you do that, then you might want to mention the version of the regex that is being matched in any error messages.

Thanks,

Marcus.

from jison.

 avatar commented on July 17, 2024

When trying to input the following regex:

[']([^\\']+|[\\](\n|.))*?[']        return 'SINGLE_STR';

I get the error:

Error: Parse error on line 80:
...\n|.))*?[']         return 'SINGLE_STR';
-----------------------^
Expecting '|', ')'

Even though it's properly balanced in terms of parentheses.

What I really want to enter is:

'([^\\']+|\\(\n|.))*?'

But as mentioned before, the single quotes don't place nicely.

I don't know if this will be useful to you or not.

Cheers,

Marcus.

from jison.

zaach avatar zaach commented on July 17, 2024

These should be adressed as of v0.2.9. Try your original quotes and backslash regex again, though quotes need a slash in front.

from jison.

 avatar commented on July 17, 2024

Thanks for fixing this.

Will let you know if there are any more problems.

from jison.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.