Giter Club home page Giter Club logo

bite-parser's Issues

Improve errors

Produce more helpful errors.
E.g. show which variant was tried to be parsed and failed.

When passing str where bytes is expected, fail fast or handle gracefully

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).

is it an issue ?

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(b'ABCDEFGHIJKLMNOPQRSTUVWXZ')

lower_case= CharacterSet(b'abcdefghijklmnopqrstuvwxz')

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

Come up with consistent naming strategy

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.

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.