Skip to content

Parsing bytestrings and token values #1526

@createyourpersonalaccount

Description

I tried using the calculator example with use_bytes=True but it wouldn't parse a NUMBER:

ValueError: could not convert string to float: Token('NUMBER', b'1')

I had to modify

number = float
to:

    number = lambda _, token = float(token.value)

even though Token.value specifies that it is redundant to write token.value because it's always equal to token.

Using Lark 1.2.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions