Skip to content

Making position a type member in parsers.scala #89

Open
@smartnose

Description

@smartnose

Hi,

The parser combinators works wonderfully, except for a minor tweak I'd like to add: I would like to constrain the type of position data structure in my parser pipeline.

At the moment, parsers.scala will use the base type Position, and leave the specific position type to Readers. The downstream operation will need to perform pattern matching to cast the position data into specific type, e.g. OffsetPosition. This gets tedious if I already know that my parser will only use one specific Position type

I propose to make position a type member in a similar fashion to Elem and Input. Existing code base can be kept in-tact by adding

type Pos = Position. 

If needed, a user can constrain the position type to be more specific by overriding the type member;
e.g.

override type Pos = OffsetPosition

I will send out a pull request on the proposed change. Please take a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions