@@ -35,6 +35,6 @@ |
||
| 35 | 35 | if (str_starts_with($input, $this->text)) { |
| 36 | 36 | return Ok::with($this->text, substr($input, $this->length)); |
| 37 | 37 | } |
| 38 | - return Error::in(substr($input, strspn($input ^ $this->text, "\0"))); |
|
| 38 | + return Error::in(substr($input, strspn($input^$this->text, "\0"))); |
|
| 39 | 39 | } |
| 40 | 40 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | private Parser $parser, |
| 21 | 21 | ) {} |
| 22 | 22 | |
| 23 | - public static function for(Parser|string $refusal, Parser|string $parser): Parser |
|
| 23 | + public static function for (Parser|string $refusal, Parser|string $parser): Parser |
|
| 24 | 24 | { |
| 25 | 25 | return new self(Cast::asParser($refusal), Cast::asParser($parser)); |
| 26 | 26 | } |
@@ -17,8 +17,7 @@ |
||
| 17 | 17 | public static function result(Parser $parser): Parser |
| 18 | 18 | { |
| 19 | 19 | return FullyMap::the($parser, fn(Result $result) => empty($result->data()) ? |
| 20 | - Error::in($result->unparsed()) : |
|
| 21 | - $result |
|
| 20 | + Error::in($result->unparsed()) : $result |
|
| 22 | 21 | ); |
| 23 | 22 | } |
| 24 | 23 | } |
@@ -37,9 +37,9 @@ |
||
| 37 | 37 | string $escape2 = null, |
| 38 | 38 | ): Parser { |
| 39 | 39 | return Between::these($from, $to, Join::the(Repeatable::parser(AllOrNothing::in(Either::of( |
| 40 | - Map::the(($escape2 ?: $escape) . $escape, fn($x) => $escape), // escaped escape |
|
| 41 | - Join::the(Sequence::of(Ignore::the($escape), $to)), // escaped end |
|
| 42 | - Except::for($to, Any::symbol()), // anything else |
|
| 40 | + Map::the(($escape2 ?: $escape) . $escape, fn($x) => $escape), // escaped escape |
|
| 41 | + Join::the(Sequence::of(Ignore::the($escape), $to)), // escaped end |
|
| 42 | + Except::for ($to, Any::symbol()), // anything else |
|
| 43 | 43 | ))))); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -39,7 +39,9 @@ |
||
| 39 | 39 | return Between::these($from, $to, Join::the(Repeatable::parser(AllOrNothing::in(Either::of( |
| 40 | 40 | Map::the(($escape2 ?: $escape) . $escape, fn($x) => $escape), // escaped escape |
| 41 | 41 | Join::the(Sequence::of(Ignore::the($escape), $to)), // escaped end |
| 42 | - Except::for($to, Any::symbol()), // anything else |
|
| 42 | + Except::for($to, Any::symbol()) { |
|
| 43 | + , // anything else |
|
| 43 | 44 | ))))); |
| 45 | + } |
|
| 44 | 46 | } |
| 45 | 47 | } |
@@ -20,8 +20,7 @@ |
||
| 20 | 20 | public static function results(int $n, Parser $parser): Parser |
| 21 | 21 | { |
| 22 | 22 | return FullyMap::the($parser, fn(Result $result) => count($result->data()) > $n ? |
| 23 | - Error::in(implode(array_slice($result->data(), $n)) . $result->unparsed()) : |
|
| 24 | - $result |
|
| 23 | + Error::in(implode(array_slice($result->data(), $n)) . $result->unparsed()) : $result |
|
| 25 | 24 | ); |
| 26 | 25 | } |
| 27 | 26 | } |
@@ -18,8 +18,7 @@ |
||
| 18 | 18 | public static function results(int $n, Parser $parser): Parser |
| 19 | 19 | { |
| 20 | 20 | return FullyMap::the($parser, fn(Result $result) => count($result->data()) < $n ? |
| 21 | - Error::in($result->unparsed()) : |
|
| 22 | - $result |
|
| 21 | + Error::in($result->unparsed()) : $result |
|
| 23 | 22 | ); |
| 24 | 23 | } |
| 25 | 24 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | |
| 64 | 64 | public function except(Parser|string $refusal): Parser |
| 65 | 65 | { |
| 66 | - return Except::for($refusal, $this); |
|
| 66 | + return Except::for ($refusal, $this); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function join(string $glue = ''): Parser |