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)
- 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
- Inconsistent parse results from simple ambiguous grammar HOT 4
- Superfluous identical ambiguities in Earley HOT 3
- Porting from pyparsing match_previous_literal HOT 4
- _TERMINAL appears in tree HOT 1
- Lexer matches shorter literals before longer literals HOT 1
- Priorities not working within recursive rules
- Error in parsing datetime strings HOT 1
- Ambiguities and Priorities in 1.2.1 earley HOT 6
- tests/test_cache.py and Python >= 3.12: SyntaxWarning: invalid escape sequence '\w'
- Terminal collision when importing the same terminal from different grammars
- Generate counter-examples for conflicts in LALR parsing HOT 3
- Escape double quote not working HOT 2
- Extending python grammar HOT 2
- Confusing Error on simple example. HOT 2
- Resolution order changed HOT 2
- v_args seems to be ignored for subclass of Visitor class HOT 3
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.