Skip to content

Commit

Permalink
Global options should silently fail so that relationships can come be…
Browse files Browse the repository at this point in the history
…fore entities.
  • Loading branch information
BurntSushi committed Jan 16, 2014
1 parent b3ebee2 commit 9a5b79a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,16 @@ rel = do
, card1 = t1, card2 = t2, roptions = opts }

globalOptions :: GlobalOptions -> Parser GlobalOptions
globalOptions gopts = option "" ident >>= \n ->
if null n then
return gopts
else do
globalOptions gopts =
option gopts $ try $ do
n <- ident
opts <- options
case n of
"title" -> emptiness >> globalOptions (gopts { gtoptions = opts})
"header" -> emptiness >> globalOptions (gopts { ghoptions = opts})
"entity" -> emptiness >> globalOptions (gopts { geoptions = opts})
"relationship" -> emptiness >> globalOptions (gopts { groptions = opts})
_ -> unexpected (printf ("Global option group '%s' is not valid. (Valid "
++ "groups are title, header, entity, "
++ "relationship.)") (unpack n))
_ -> fail "not a valid directive"

options :: Parser (M.Map String Option)
options =
Expand Down

0 comments on commit 9a5b79a

Please sign in to comment.