public
Description: Hongmini is the programming language to embed in C++ programs.
Homepage:
Clone URL: git://github.com/dahlia/hongmini.git
hongmini / hongmini.cpp
100644 38 lines (34 sloc) 0.91 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <iterator>
#include <sstream>
#include <vector>
#include <string>
#include "hongmini.hpp"
 
template<typename String, typename Iter>
inline String join(const String glue, Iter begin, Iter end) {
  std::basic_stringstream<typename String::value_type> ss;
  for (Iter i(begin); i != end; ++i) {
    if (i != begin) {
      ss << glue;
    }
    ss << *i;
  }
  return ss.str();
}
 
int main() {
  std::cout << "Hongmini Tokenizer" << std::endl;
  while (true) {
    char code[80];
    std::cout << ">>> ";
    std::cin.getline(code, 80);
    std::string codes(code);
    if (codes == "exit") return 0;
    std::vector<std::string> tokens;
    hongmini::tokenize(codes.begin(), codes.end(), std::back_inserter(tokens));
    std::cout << "\""
              << join(std::string("\", \""), tokens.begin(), tokens.end())
              << "\""
              << std::endl;
  }
  return 0;
}