Skip to content

Hide state from user API #80

@sergei-shabanau

Description

@sergei-shabanau

Currently state is exposed in grammars

sealed abstract class Grammar[-SI, +SO, +E, A]

This results in state container (a Tuple) being allocated and returned at each step of execution

case Grammar.GADT.Produce(a)      => (s: S, i: Input) => (s, Right((i, a)))

which is a huge performance overhead.

What if state is only returned at the very end?
So instead of

def parser[S, E, A](grammar: Grammar[S, S, E, A]): (S, Input) => (S, E \/ (Input, A))

we have

def parser[E, A](grammar: Grammar[E, A]): Input => (State, E \/ (Input, A))

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions