declareDocumentEnvironment :: HandleTeXIO m => MacroDefinitionMode -> LexerT m [Token]
declareDocumentEnvironment defMode = do
  name <- grouped tokensNoExpand <?> "environment name"
  context <- argspec <?> "environment argspec"
  startCode <- grouped tokensNoExpand <?> "environment start code"
  endCode <- grouped tokensNoExpand <?> "environment end code"
  modifyState $ registerMacroEnv defMode
    (name, MacroEnv name context startCode endCode)
  return []

-- Parse a full xparse-style argument specification.
declareDocumentEnvironment :: HandleTeXIO m => MacroDefinitionMode -> LexerT m [Token]
declareDocumentEnvironment defMode = do
  name <- grouped tokensNoExpand <?> "environment name"
  context <- argspec <?> "environment argspec"
  startCode <- grouped tokensNoExpand <?> "environment start code"
  endCode <- grouped tokensNoExpand <?> "environment end code"
  modifyState $ registerMacroEnv defMode
    (name, MacroEnv name context startCode endCode)
  return []

-- Parse a full xparse-style argument specification.
declareDocumentEnvironment defMode = do
  name <- grouped tokensNoExpand <?> "environment name"
  context <- argspec <?> "environment argspec"
  startCode <- grouped tokensNoExpand <?> "environment start code"
  endCode <- grouped tokensNoExpand <?> "environment end code"
  modifyState $ registerMacroEnv defMode
    (name, MacroEnv name context startCode endCode)
  return []

-- Parse a full xparse-style argument specification.