File tree Expand file tree Collapse file tree 2 files changed +4
-22
lines changed
Expand file tree Collapse file tree 2 files changed +4
-22
lines changed Original file line number Diff line number Diff line change @@ -166,23 +166,10 @@ def combine_dict(self, combine_fn: Callable) -> Parser:
166166
167167 def concat (self ) -> Parser :
168168 """
169- Returns a parser that concatenates together the previously produced values.
170-
171- This parser will join the values using the type of the input stream, so
172- when feeding bytes to the parser, the items to be joined must also be bytes.
169+ Returns a parser that concatenates together (as a string) the previously
170+ produced values.
173171 """
174-
175- @Parser
176- def parser (stream : bytes | str , index : int ) -> Result :
177- joiner = type (stream )()
178- result = self (stream , index )
179- if result .status :
180- next_parser : Parser = success (joiner .join (result .value ))
181- return next_parser (stream , result .index ).aggregate (result )
182- else :
183- return result
184-
185- return parser
172+ return self .map ("" .join )
186173
187174 def then (self , other : Parser ) -> Parser :
188175 """
Original file line number Diff line number Diff line change @@ -157,16 +157,11 @@ def test_combine_dict_skip_underscores(self):
157157 ).combine_dict (Pair )
158158 self .assertEqual (parser .parse ("ABC 123" ), Pair (word = "ABC" , number = 123 ))
159159
160- def test_concat_str (self ):
160+ def test_concat (self ):
161161 parser = letter .many ().concat ()
162162 self .assertEqual (parser .parse ("" ), "" )
163163 self .assertEqual (parser .parse ("abc" ), "abc" )
164164
165- def test_concat_bytes (self ):
166- parser = any_char .many ().concat ()
167- self .assertEqual (parser .parse (b"" ), b"" )
168- self .assertEqual (parser .parse (b"abc" ), b"abc" )
169-
170165 def test_generate (self ):
171166 x = y = None
172167
You can’t perform that action at this time.
0 commit comments