-- Parse a conditional and return its left or right branch,
-- depending on the provided flag.
--
-- The flag argument indicates whether the condition is true.
-- Note: Conditional nesting is independent of grouping,
-- so groups are not parsed here.
conditional :: HandleTeXIO m => Bool -> LexerT m [Token]
conditional b = do
  let (l,r) = (b, not b) -- branch expansion modes
  (leftToks, rightToks) <- condBranches (l,r) []
  return $ if b then leftToks else rightToks

-- Parse the two branches of a conditional.
--
-- The flag arguments indicate whether to expand the branches.
conditional :: HandleTeXIO m => Bool -> LexerT m [Token]
conditional b = do
  let (l,r) = (b, not b) -- branch expansion modes
  (leftToks, rightToks) <- condBranches (l,r) []
  return $ if b then leftToks else rightToks

-- Parse the two branches of a conditional.
--
-- The flag arguments indicate whether to expand the branches.
conditional b = do
  let (l,r) = (b, not b) -- branch expansion modes
  (leftToks, rightToks) <- condBranches (l,r) []
  return $ if b then leftToks else rightToks

-- Parse the two branches of a conditional.
--
-- The flag arguments indicate whether to expand the branches.