jgosmann / bite-parser Goto Github PK
View Code? Open in Web Editor NEWAsynchronous parser taking incremental bites out of your byte input stream.
Home Page: https://jgosmann.github.io/bite-parser/docs/en/stable/
License: MIT License
Asynchronous parser taking incremental bites out of your byte input stream.
Home Page: https://jgosmann.github.io/bite-parser/docs/en/stable/
License: MIT License
Produce more helpful errors.
E.g. show which variant was tried to be parsed and failed.
Currently no error is produced at runtime when accidentally passing str
instead of bytes
, for example when using Literal('foo')
instead of Literal(b'foo')
, but parsing does not work. This should either raise an error or be handled gracefully (e.g. by encoding the string to bytes with ascii
encoding).
It seems i cannot do some elementary parsing
is it me ? or ?
#!/bin/env python
import asyncio
from bite import Parser, CharacterSet, Combine, Group, Literal, parse_bytes, Suppress, Opt, ZeroOrMore
upper_case= CharacterSet(bytes(range(ord(b'A'),1+ord(b'Z'))))
lower_case= CharacterSet(bytes(range(ord(b'a'),1+ord(b'z'))))
digit = CharacterSet(b'0123456789')
digits = digit[1, ...]
integer = Combine(digits)
letter=lower_case|upper_case
char=letter|digit
ident = Combine(letter + (char | '_')[0, ...])
obj = parse_bytes( ident, "un")
result = asyncio.run( obj )
print(result
Input: 'un'
^ location of error
The naming of parse nodes (from the parsers) is somewhat inconsistent and random at the moment. This should be made consistent. Also, names should not try to represent the sub-parse-tree, but make it easy to find specific nodes. Thus, it might be sufficient to just use the type of parser.
I think it would be a bit simpler to track a single extent
(as 2-tuple) than two separate values in the ParseNode
s.
Enable useful debug output that clarifies why and how parsing is failing.
When the buffer is a bytearray
(instead of bytes
) the wrong location will be marked when an UnmetExpectationError
is printed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.