Comments (1)
This is not exactly a bug in Parsley, it just works different compared to PyMeta2. The meaning of the two string quotes (', ") should be described better in the documentation. Se below for a possible parser improvement as well.
In the test code, I try to match using " - ". The double quoted string is matched as a Token, and Parsley helpfully removes any whitespace that may come before it, effectively matching the pattern (' '* ' - '). This will of course never match. The correct pattern to use in this case is ' - ', which is matched against the exact string.
It works in PyMeta2 because " - " is not matched as a Token, but as a string. The PyMeta2 parser will parse ' - ' successfully, but it will never match, as it is handled by the exactly matcher, which only compares the first character on the input stream against the string. A pattern that works both in Parsley and PyMeta2 would have to be written as (' ' '-' ' '). (PyMeta2 has a token matcher as well, but I am unsure if it can be invoked.)
Maybe the Parsley grammar should fail to parse Tokens that start with whitespace. PyMeta2 on the other hand should fail on anything longer than a single character within single quotes.
from parsley.
Related Issues (20)
- mutual left recursion not supported
- Documentation inaccurately describes "letter"
- Support Unicode categories and properties
- Support custom rule functions
- PyPI urls point at launchpad
- given bindings with inputs
- Parse error reported in the wrong place HOT 1
- Different behavior for single and double quotes HOT 1
- parsley.makeGrammar("death = ('a' | ws)*", {})('a ').death() # never returns? HOT 1
- ability to emit warnings and halt compilation
- docs could use more examples
- Freeze
- pass current line and column to action HOT 1
- Documentation/example for "!(pythonExpression): Invoke a Python expression as an action." missing
- expr1 | expr2 not working as expected
- Collect tokens from stream as well as rule return values
- ParseError should be hashable
- Rule arguments are wrapped in tuples
- Input matches rule A, but A|B fails to match HOT 3
- Tests deprication warnings
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 parsley.