---------- Builtin macros: meaning

-- Assign new meaning to a control sequence.
letmeaning :: Monad m => LexerT m [Token]
letmeaning = do
  (CtrlSeq name active) <- ctrlseqNoExpand <?> "macro name"
  equals
  m <- meaningCtrlSeq <|> meaningChar
  let val = case m of
        MeaningChar ch cc -> MacroCmdChar ch cc
        MeaningMacro cmd -> cmd
        MeaningUndef -> MacroCmdPrim "undefined"
  let key = (name, active)
  modifyState (registerLocalMacroCmd (key, val))
  return []

-- Show the current meaning of a control sequence or a character.
letmeaning :: Monad m => LexerT m [Token]
letmeaning = do
  (CtrlSeq name active) <- ctrlseqNoExpand <?> "macro name"
  equals
  m <- meaningCtrlSeq <|> meaningChar
  let val = case m of
        MeaningChar ch cc -> MacroCmdChar ch cc
        MeaningMacro cmd -> cmd
        MeaningUndef -> MacroCmdPrim "undefined"
  let key = (name, active)
  modifyState (registerLocalMacroCmd (key, val))
  return []

-- Show the current meaning of a control sequence or a character.
letmeaning = do
  (CtrlSeq name active) <- ctrlseqNoExpand <?> "macro name"
  equals
  m <- meaningCtrlSeq <|> meaningChar
  let val = case m of
        MeaningChar ch cc -> MacroCmdChar ch cc
        MeaningMacro cmd -> cmd
        MeaningUndef -> MacroCmdPrim "undefined"
  let key = (name, active)
  modifyState (registerLocalMacroCmd (key, val))
  return []

-- Show the current meaning of a control sequence or a character.