1

Continuing from this GitHub issue:

I need to match on indent or dedent, and I'm using Earley. Earley has no built-in support for indentation, but I'd like to be able to use indentation instead of braces in my language.

Example input:

func foo(a: A, b: B): C =
  theresSomeIndentRequiredHere(a, b)

func noMoreIndentMeansNoMoreFoo: D = ???

This would parse theresSomeIndentRequiredHere as part of foo, but noMoreindentMeansNoMoreFoo would not get parsed as part of foo.

How can I do this without losing a ton of speed?

Aly
  • 847
  • 1
  • 6
  • 30
  • 1
    If it's speed you're after, you should not be using an Earley parser. Are you doing something fancy with an ambiguous grammar that you need an Earley parser for? – luqui Mar 30 '20 at 06:34
  • 4
    Also consider starting off by writing a correct algorithm, without worrying about its performance. Then measure it: if it's unacceptably slow, implement it again: it will be easier for having done it once the easy way already. – amalloy Mar 30 '20 at 08:04
  • @luqui I am not, actually. What should I be using then? – Aly Mar 30 '20 at 18:32
  • I rechecked a comparison of parsing libraries, specifically the one in Megaparsec's readme. I think initially I read "Megaparsec is faster" as the opposite. That readme recommends attoparsec for speed, but I probably should just use Megaparsec. Even still, is there a good solution to this problem, with respect to Earley? – Aly Mar 30 '20 at 18:54

0 Answers0