def :: Monad m => LexerT m [Token]
def = do
  (CtrlSeq name active) <- ctrlseqNoExpand <?> "macro name"
  context <- macroContextDefinition <?> "macro context definition"
  body <- grouped tokensNoExpand
  let key = (name, active)
  modifyState (registerLocalMacroCmd
               (key, MacroCmdUser key (def2xparse context) body))
  return []

-- Parse a macro context definition. Similar to 'tokens', but
-- must not contain 'Bgroup' (so do not include 'group' parser).
def :: Monad m => LexerT m [Token]
def = do
  (CtrlSeq name active) <- ctrlseqNoExpand <?> "macro name"
  context <- macroContextDefinition <?> "macro context definition"
  body <- grouped tokensNoExpand
  let key = (name, active)
  modifyState (registerLocalMacroCmd
               (key, MacroCmdUser key (def2xparse context) body))
  return []

-- Parse a macro context definition. Similar to 'tokens', but
-- must not contain 'Bgroup' (so do not include 'group' parser).
def = do
  (CtrlSeq name active) <- ctrlseqNoExpand <?> "macro name"
  context <- macroContextDefinition <?> "macro context definition"
  body <- grouped tokensNoExpand
  let key = (name, active)
  modifyState (registerLocalMacroCmd
               (key, MacroCmdUser key (def2xparse context) body))
  return []

-- Parse a macro context definition. Similar to 'tokens', but
-- must not contain 'Bgroup' (so do not include 'group' parser).