MCPcopy Create free account
hub / github.com/NanoMichael/MicroTeX / processEscape

Method processEscape

src/core/parser.cpp:496–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496sptr<Atom> TeXParser::processEscape() throw(ex_parse) {
497 _spos = _pos;
498 wstring command = getCommand();
499
500 if (command.length() == 0) return sptr<Atom>(new EmptyAtom());
501
502 string cmd;
503 wide2utf8(command.c_str(), cmd);
504 auto it = MacroInfo::_commands.find(command);
505 if (it != MacroInfo::_commands.end()) return processCommands(command);
506
507 try {
508 return TeXFormula::get(command)->_root;
509 } catch (ex_formula_not_found& e) {
510 try {
511 return SymbolAtom::get(cmd);
512 } catch (ex_symbol_not_found& ex) {}
513 }
514
515 // not a valid command or symbol or predefined TeXFormula found
516 if (!_isPartial)
517 throw ex_parse("Unknown symbol or command or predefined TeXFormula: '" + cmd + "'");
518 sptr<Atom> rm(new RomanAtom(TeXFormula(L"\\backslash " + command)._root));
519 return sptr<Atom>(new ColorAtom(rm, TRANS, RED));
520}
521
522sptr<Atom> TeXParser::processCommands(const wstring& command) throw(ex_parse) {
523 MacroInfo* mac = MacroInfo::_commands[command];

Callers

nothing calls this directly

Calls 3

wide2utf8Function · 0.85
ex_parseClass · 0.85
TeXFormulaClass · 0.70

Tested by

no test coverage detected