Comments (5)
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.
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.
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.
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.
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)
- Making a comment by using regular expression HOT 5
- earley very, very slow HOT 24
- Cant read `meta` from Tree or Token? HOT 5
- How to define lark grammar for best parsing performance HOT 8
- Unable to parse Arabic text HOT 3
- Incorrect start_pos / end_pos in the tree HOT 8
- Add `outlines` in the list of projects using Lark HOT 2
- Lark.open_from_package() does not support namespace packages HOT 2
- Stand-alone program cannot be run HOT 4
- Issue of installing lark in Python HOT 1
- Pipe in terminal regex not working as expected HOT 1
- Transformer Not Applying Expected Transformations in Lark Parser HOT 3
- Deprecation Warning HOT 6
- accepts() vs choices() in InteractiveParser HOT 10
- No such file or directory: 'COMMON.lark' HOT 4
- Grammar Syntax For Unordered Groups HOT 1
- Is it possible to parse parts of the input? HOT 12
- Forgiving syntax HOT 3
- Post 1388 changes HOT 4
- Dynamic Earley: Incorrect value for SymbolNode.end
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lark.