Changeset 30714 in project
 Timestamp:
 04/16/14 00:16:14 (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/comparse
r30713 r30714 99 99 touching the remainder is needed quite frequently, Comparse provides 100 100 the {{result}} parser combinator which does just that. Using it we can 101 write {{doubleitem}} more convenientlylike this:101 write {{doubleitem}} like this: 102 102 103 103 … … 131 131 <procedure>(result value)</procedure> 132 132 133 Returns a parser which always succeeds, leaves the input untouched and134 returns {{value}}.133 Returns a parser which always succeeds, returning {{value}} as the 134 parse result and the untouched input as the remainder. 135 135 136 136 … … 143 143 144 144 A parser which consumes and returns the first item of {{input}}, 145 i.e. it returns that item and the tail of {{input}}. Fails if 146 {{input}} is empty. 145 i.e. it returns that item as the parse result and the tail of 146 {{input}} as the remainder. Fails if {{input}} is empty. 147 148 149 <procedure>(endofinput input)</procedure> 150 151 A parser which returns {{#t}} as the parse result and the untouched 152 {{input}} as the remainder if {{input}} is empty. 147 153 148 154 … … 244 250 of the preceding parser, respectively, and returns the result of 245 251 {{content}} with the remainder of {{close}}. 252 253 254 <procedure>(maybe parser)</procedure> 255 256 Returns a parser which applies {{parser}} to the input and returns its 257 result and remainder if it succeeds. Otherwise it returns {{#f}} as 258 the parse result and the untouched input as the remainder. 259 260 261 <procedure>(zeroormore parser)</procedure> 262 263 Returns a parser which applies {{parser}} to its input. If that fails, 264 it returns {{()}} as the parse result and the untouched input as the 265 remainder. Otherwise it applies {{parser}} again to the remainder of 266 the previous application and so forth, collecting all parse result in 267 a list. That list is then returned as the parse result and the 268 remainder of the last successful application of {{parser}} as the 269 remainder. 270 271 272 <procedure>(oneormore parser)</procedure> 273 274 Returns a parser which applies {{parser}} to its input. If that fails, 275 it also fails. Otherwise it applies {{parser}} again to the remainder 276 of the previous application and so forth, collecting all parse result 277 in a list. That list is then returned as the parse result and the 278 remainder of the last successful application of {{parser}} as the 279 remainder. 246 280 247 281
Note: See TracChangeset
for help on using the changeset viewer.