Giter Club home page Giter Club logo

Comments (5)

erezsh avatar erezsh commented on July 30, 2024

These errors occur due to this change in Python3.6: https://bugs.python.org/issue27364

Try the latest master. It should fix it.

And change COMMENT to COMMENT : /#[^\n]*/

from lark.

erezsh avatar erezsh commented on July 30, 2024

Oh, and you need to change flags too. For example,

LONG_STRING : /(?i)(?s)whatever/

becomes

LONG_STRING : /whatever/is

I will also update the python grammar soon.

from lark.

erezsh avatar erezsh commented on July 30, 2024

I corrected the regexps in the Python grammars. Please use them, instead of the old ones that you have copied. Let me know if that solves your problem.

Thanks for choosing Lark ;)

from lark.

autocorr avatar autocorr commented on July 30, 2024

Excellent, thank you for the prompt response! :) I've installed the master branch, but ran into an issue that I thought would be helpful to describe. I've solved my original problem by using the old rules, commenting out the new rules, and throwing a filter on the deprecation warnings for the time being (the intention being that I'll put them in when it works in the next release). So I'll close the issue.

When using the new rules on master, it returns an AssertionError:

  File "/home/brian/.local/lib/python3.5/site-packages/lark/load_grammar.py", line 371, in expansions
    assert all(i.flags is None for i in exps)

when I enter debug mode, exps contains the (escaped) contents of the two string rules:

['(?i)[ubf]?r?("(?!"").*?(?<!\\\\)(\\\\\\\\)*?"|\\\'(?!\\\'\\\').*?(?<!\\\\)(\\\\\\\\)*?\\\')', '(?s)(?i)[ubf]?r?(""".*?(?<!\\\\)(\\\\\\\\)*?"""|\\\'\\\'\\\'.*?(?<!\\\\)(\\\\\\\\)*?\\\'\\\'\\\')']

Also, I think that a few of the rules for numeric literals are off for Python 3. Binary numbers aren't included such as 0b10, I don't think that the o is optional for octal (03 vs 0o3), and the l for long doesn't seem to work (10l). The last two I tested in the REPL and returned errors on v3.6. I think the correct rules would be:

DEC_NUMBER : /[1-9]\d*/i
HEX_NUMBER : /0x[\da-f]*/i
OCT_NUMBER : /0o[0-7]*/i
BIN_NUMBER : /0b[0-1]*/i
FLOAT_NUMBER : /((\d+\.\d*|\.\d+)(e[-+]?\d+)?|\d+(e[-+]?\d+))/i
IMAG_NUMBER : /\d+j|${FLOAT_NUMBER}j/i

from lark.

erezsh avatar erezsh commented on July 30, 2024

When using the new rules on master, it returns an AssertionError:

Try the latest master version. You might find the error a bit more informative!

I think that a few of the rules for numeric literals are off for Python 3.

Yes, you're right! I copied the literals from Python 2, but obviously there have been a few changes. I'll update the Python3 grammar.

from lark.

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.