lib, doc, test: csv parser gains "end" command for "if" block
This commit is contained in:
		
							parent
							
								
									3e5f0e8dd5
								
							
						
					
					
						commit
						3c7d5d466d
					
				| @ -222,11 +222,11 @@ validateCsv rules numhdrlines (Right rs) = validate $ applyConditionalSkips $ dr | ||||
|   where | ||||
|     filternulls = filter (/=[""]) | ||||
|     skipCount r = | ||||
|       case getEffectiveAssignment rules r "skip" of | ||||
|         Nothing -> Nothing | ||||
|         Just "" -> Just 1 | ||||
|         Just "end" -> Just maxBound | ||||
|         Just x -> Just (read x) | ||||
|       case (getEffectiveAssignment rules r "end", getEffectiveAssignment rules r "skip") of | ||||
|         (Nothing, Nothing) -> Nothing | ||||
|         (Just _, _) -> Just maxBound | ||||
|         (Nothing, Just "") -> Just 1 | ||||
|         (Nothing, Just x) -> Just (read x) | ||||
|     applyConditionalSkips [] = [] | ||||
|     applyConditionalSkips (r:rest) = | ||||
|       case skipCount r of | ||||
| @ -601,7 +601,8 @@ journalfieldnames = | ||||
|   ,"date" | ||||
|   ,"description" | ||||
|   ,"status" | ||||
|   ,"skip" -- skip is not really a field, but we list it here to allow conditional rules that skip records | ||||
|   ,"skip" -- skip and end are not really fields, but we list it here to allow conditional rules that skip records | ||||
|   ,"end" | ||||
|   ] | ||||
| 
 | ||||
| assignmentseparatorp :: CsvRulesParser () | ||||
|  | ||||
| @ -194,7 +194,7 @@ Note, interpolation strips any outer whitespace, so a CSV value like | ||||
| 
 | ||||
| `if` *`PATTERN`*\ | ||||
| *`PATTERN`*...\ | ||||
|     *`skip end`*... | ||||
|     *`end`*... | ||||
| 
 | ||||
| This applies one or more field assignments, only to those CSV records matched by one of the PATTERNs. | ||||
| The patterns are case-insensitive regular expressions which match anywhere | ||||
| @ -203,7 +203,7 @@ specific field).  When there are multiple patterns they can be written | ||||
| on separate lines, unindented. | ||||
| The field assignments are on separate lines indented by at least one space. | ||||
| 
 | ||||
| Instead of field assignments you can specify `skip N` to skip the next N records (including the one that matchied) or `skip end` to skip the rest of the file. | ||||
| Instead of field assignments you can specify `skip` or `skip 1` to skip this record, `skip N` to skip the next N records (including the one that matchied) or `end` to skip the rest of the file. | ||||
| 
 | ||||
| Examples: | ||||
| ```rules | ||||
|  | ||||
| @ -372,7 +372,7 @@ if HEADER | ||||
| 
 | ||||
| if | ||||
| END OF FILE | ||||
|   skip end | ||||
|   end | ||||
| 
 | ||||
| if MIDDLE | ||||
|   skip 3 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user