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 |   where | ||||||
|     filternulls = filter (/=[""]) |     filternulls = filter (/=[""]) | ||||||
|     skipCount r = |     skipCount r = | ||||||
|       case getEffectiveAssignment rules r "skip" of |       case (getEffectiveAssignment rules r "end", getEffectiveAssignment rules r "skip") of | ||||||
|         Nothing -> Nothing |         (Nothing, Nothing) -> Nothing | ||||||
|         Just "" -> Just 1 |         (Just _, _) -> Just maxBound | ||||||
|         Just "end" -> Just maxBound |         (Nothing, Just "") -> Just 1 | ||||||
|         Just x -> Just (read x) |         (Nothing, Just x) -> Just (read x) | ||||||
|     applyConditionalSkips [] = [] |     applyConditionalSkips [] = [] | ||||||
|     applyConditionalSkips (r:rest) = |     applyConditionalSkips (r:rest) = | ||||||
|       case skipCount r of |       case skipCount r of | ||||||
| @ -601,7 +601,8 @@ journalfieldnames = | |||||||
|   ,"date" |   ,"date" | ||||||
|   ,"description" |   ,"description" | ||||||
|   ,"status" |   ,"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 () | assignmentseparatorp :: CsvRulesParser () | ||||||
|  | |||||||
| @ -194,7 +194,7 @@ Note, interpolation strips any outer whitespace, so a CSV value like | |||||||
| 
 | 
 | ||||||
| `if` *`PATTERN`*\ | `if` *`PATTERN`*\ | ||||||
| *`PATTERN`*...\ | *`PATTERN`*...\ | ||||||
|     *`skip end`*... |     *`end`*... | ||||||
| 
 | 
 | ||||||
| This applies one or more field assignments, only to those CSV records matched by one of the PATTERNs. | 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 | 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. | on separate lines, unindented. | ||||||
| The field assignments are on separate lines indented by at least one space. | 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: | Examples: | ||||||
| ```rules | ```rules | ||||||
|  | |||||||
| @ -372,7 +372,7 @@ if HEADER | |||||||
| 
 | 
 | ||||||
| if | if | ||||||
| END OF FILE | END OF FILE | ||||||
|   skip end |   end | ||||||
| 
 | 
 | ||||||
| if MIDDLE | if MIDDLE | ||||||
|   skip 3 |   skip 3 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user