///////////////////////////////////////////////////////////////////////////
| 703 | |
| 704 | //////////////////////////////////////////////////////////////////////////////// |
| 705 | std::string Eval::dump(std::vector<std::pair<std::string, Lexer::Type>>& tokens) const { |
| 706 | // Set up a color mapping. |
| 707 | std::map<Lexer::Type, Color> color_map; |
| 708 | color_map[Lexer::Type::op] = Color("gray14 on gray6"); |
| 709 | color_map[Lexer::Type::number] = Color("rgb530 on gray6"); |
| 710 | color_map[Lexer::Type::hex] = Color("rgb303 on gray6"); |
| 711 | color_map[Lexer::Type::string] = Color("rgb550 on gray6"); |
| 712 | color_map[Lexer::Type::dom] = Color("rgb045 on gray6"); |
| 713 | color_map[Lexer::Type::identifier] = Color("rgb035 on gray6"); |
| 714 | color_map[Lexer::Type::date] = Color("rgb150 on gray6"); |
| 715 | color_map[Lexer::Type::duration] = Color("rgb531 on gray6"); |
| 716 | |
| 717 | std::string output; |
| 718 | for (auto i = tokens.begin(); i != tokens.end(); ++i) { |
| 719 | if (i != tokens.begin()) output += ' '; |
| 720 | |
| 721 | Color c; |
| 722 | if (color_map[i->second].nontrivial()) |
| 723 | c = color_map[i->second]; |
| 724 | else |
| 725 | c = Color("rgb000 on gray6"); |
| 726 | |
| 727 | output += c.colorize(i->first); |
| 728 | } |
| 729 | |
| 730 | return output; |
| 731 | } |
| 732 | |
| 733 | //////////////////////////////////////////////////////////////////////////////// |
nothing calls this directly
no outgoing calls
no test coverage detected