lib: refactor parsing of bracketed posting dates
This commit is contained in:
		
							parent
							
								
									fcc10f018d
								
							
						
					
					
						commit
						17b11aaf1e
					
				| @ -872,7 +872,7 @@ followingcommentandtagsp mdefdate = do | |||||||
|   -- Reparse the comment for any bracketed style posting dates. |   -- Reparse the comment for any bracketed style posting dates. | ||||||
|   -- Use the transaction date for defaults, if provided. |   -- Use the transaction date for defaults, if provided. | ||||||
|   eBracketedDates <- fmap sequence |   eBracketedDates <- fmap sequence | ||||||
|            $ traverse (runErroringJournalParserAt (postingdatesp mdefdate)) |            $ traverse (runErroringJournalParserAt (bracketedpostingdatesp mdefdate)) | ||||||
|                       commentLines |                       commentLines | ||||||
|   bracketedDates <- case eBracketedDates of |   bracketedDates <- case eBracketedDates of | ||||||
|     Right dss -> pure $ concat dss |     Right dss -> pure $ concat dss | ||||||
| @ -1002,19 +1002,18 @@ tagswithvaluepositions = do | |||||||
| 
 | 
 | ||||||
| --- ** posting dates | --- ** posting dates | ||||||
| 
 | 
 | ||||||
| -- | Parse all posting dates found in a string. Posting dates can be | -- | Parse all bracketed posting dates found in a string. The dates are | ||||||
| -- expressed with date/date2 tags and/or bracketed dates.  The dates | -- parsed fully to give useful errors. Missing years can be inferred only | ||||||
| -- are parsed fully to give useful errors. Missing years can be | -- if a default date is provided. | ||||||
| -- inferred only if a default date is provided. |  | ||||||
| -- | -- | ||||||
| postingdatesp :: Monad m => Maybe Day -> ErroringJournalParser m [(TagName,Day)] | bracketedpostingdatesp | ||||||
| postingdatesp mdefdate = do |   :: Monad m => Maybe Day -> ErroringJournalParser m [(TagName,Day)] | ||||||
|   -- pdbg 0 $ "postingdatesp" | bracketedpostingdatesp mdefdate = do | ||||||
|   let p = bracketeddatetagsp mdefdate |   -- pdbg 0 $ "bracketedpostingdatesp" | ||||||
|       nonp = |   skipMany $ notChar '[' | ||||||
|          many (notFollowedBy p >> anyChar) |   fmap concat | ||||||
|          -- anyChar `manyTill` (lookAhead (try (p >> return ()) <|> eof)) |     $ sepEndBy (try (bracketeddatetagsp mdefdate) <|> char '[' *> pure []) | ||||||
|   concat <$> many (try (nonp >> p)) |                (skipMany $ notChar '[') | ||||||
| 
 | 
 | ||||||
| --- ** bracketed dates | --- ** bracketed dates | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user