isSliced
indicates if the current parser is surround by a
slice
combinator.
isSliced
indicates if the current parser is surround by a
slice
combinator. This lets us avoid building up values that
will end up getting thrown away.
There are several convenience functions on ParseState
to make
implementing some of the combinators easier.
The result of a parse--a Parser[A]
returns a Result[A]
.
The result of a parse--a Parser[A]
returns a Result[A]
.
There are three cases:
As usual, we define some helper functions on Result
.
Defining functions on Result
gives us better type
information--there are cases (see map
and map2
below) where
Scala will not appropriately refine type information when
pattern matching on Result
.
Returns -1 if s.startsWith(s2), otherwise returns the first index where the two strings differed.
Returns -1 if s.startsWith(s2), otherwise returns the first index where the two strings differed. If s2 is longer than s1, returns s.length.