{"id":18630,"date":"2019-07-29T15:39:08","date_gmt":"2019-07-29T06:39:08","guid":{"rendered":"https:\/\/labs.gree.jp\/blog\/?p=18630"},"modified":"2019-07-29T15:53:24","modified_gmt":"2019-07-29T06:53:24","slug":"post18630","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2019\/07\/18630\/","title":{"rendered":"\u811a\u672c\u3092json\u306b\u30d1\u30fc\u30b9\u3057\u3066\u307f\u308b"},"content":{"rendered":"<p>\u3054\u3076\u3055\u305f\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u3061\u3087\u3073\u3048\u3067\u3059\u3002<br \/>\n\u4eca\u65e5\u306f\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u3092\u30d1\u30fc\u30b9\u3057\u3066json\u306e\u69cb\u6587\u30c7\u30fc\u30bf\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h1>\u80cc\u666f<\/h1>\n<p>\u7269\u8a9e\u3092\u9032\u3081\u308b\u30bf\u30a4\u30d7\u306e\u30b2\u30fc\u30e0\u3092\u4f5c\u308b\u4e0a\u3067\u3001\u306a\u3093\u304b\u3057\u3089\u306e\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u30b2\u30fc\u30e0\u5411\u3051\u306e\u6f14\u51fa\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u306b\u5909\u63db\u3059\u308b\u30bf\u30b9\u30af\u3068\u3044\u3046\u306e\u304c\u5927\u62b5\u306e\u5834\u5408\u3042\u3063\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p>\u5c0f\u3055\u3081\u306e\u30b2\u30fc\u30e0\u3067\u3042\u308c\u3070\u4f55\u3067\u3082\u597d\u304d\u3084\u308c\u3070\u3088\u3044\u306e\u3067\u3059\u304c\u3001\u3042\u308b\u7a0b\u5ea6\u306e\u898f\u6a21\u304c\u3042\u308b\u30b2\u30fc\u30e0\u306e\u5834\u5408\u3001\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u30c7\u30fc\u30bf\u3060\u3051\u3067\u3082\u5168\u90e8\u8aad\u3080\u3060\u3051\u3067\u6570\u65e5\u304b\u304b\u3063\u3066\u3057\u307e\u3046\u5206\u91cf\u304c\u6700\u7d42\u7684\u306b\u51fa\u6765\u4e0a\u304c\u308b\u306e\u3067\u4f55\u304b\u3057\u3089\u306e\u524d\u51e6\u7406\u7cfb\u7d71\u3068\u30e1\u30f3\u30c6\u66f4\u65b0\u3057\u3084\u3059\u3044\u30c7\u30fc\u30bf\u3068\u3044\u3046\u3082\u306e\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u5f8c\u51e6\u7406\u306e\u5909\u63db\u306e\u6e96\u5099\u3092\u3084\u308b\u306b\u306f\u3069\u3046\u30a2\u30d7\u30ed\u30fc\u30c1\u3059\u308c\u3070\u3044\u3044\u304b\u3001\u3068\u3044\u3046\u3068\u3053\u308d\u3067\u4eca\u56de\u306f\u554f\u984c\u3092\u30b7\u30f3\u30d7\u30eb\u306b\u3057\u3066\u30d7\u30ec\u30fc\u30f3\u306a\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u69cb\u6587\u6728\u3092\u4f5c\u3063\u3066excel\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u66f8\u304d\u51fa\u3057\u307e\u3067\u3084\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<h1>\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u306e\u30c7\u30fc\u30bf\u306f\u3069\u308c\u304f\u3089\u3044\u306b\u306a\u308b\u306e\u304b<\/h1>\n<p>\u5168\u90e8\u8aad\u3080\u3060\u3051\u3067\u6570\u65e5\u3063\u3066\u5177\u4f53\u7684\u306b\u3069\u3093\u3060\u3051\u306e\u5206\u91cf\u3088\u3001\u3068\u3044\u3046\u611f\u3058\u306a\u306e\u3067\u5177\u4f53\u7684\u306a\u6570\u5b57\u3092\u51fa\u3057\u3066\u307f\u308b\u3068\u3001\u4f8b\u3048\u30701\u7ae08\u8a71\u3042\u308b\u3068\u3057\u3066\u300110\u7ae0\u3042\u308b\u5834\u5408\u3002<\/p>\n<p>10\u7ae0 * 8\u8a71 * \u4f53\u611f\u7684\u306a\u4fc2\u6570(\u76db\u308a\u4e0a\u304c\u308a\u3067\u5897\u3048\u305f\u308a\u3059\u308b\u306e\u3067)\u30671.5\u304b\u3051\u3066\u7d04100\u30d5\u30a1\u30a4\u30eb\u3002<\/p>\n<p>\u3053\u308c\u306b\u52a0\u3048\u3001\u30b5\u30d6\u30b7\u30ca\u30ea\u30aa\u3084\u7d30\u304b\u3044\u30b7\u30e7\u30c3\u30c8\u306e\u304a\u8a71\u306a\u3069\u3092\u542b\u3081\u308b\u3068\u3060\u3044\u305f\u30443\uff5e500\u30d5\u30a1\u30a4\u30eb\u7a0b\u5ea6\u306b\u5897\u3048\u307e\u3059\u3002<\/p>\n<p>\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u5411\u3051\u30b2\u30fc\u30e0\u306e\u5834\u5408\u3001\u6587\u5b57\u6570\u306f\u304a\u304a\u3088\u305d1\u30d5\u30a1\u30a4\u30eb\u3042\u305f\u308a1000\uff5e2000\u6587\u5b57\u3050\u3089\u3044\u304c\u591a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u611f\u899a\u7684\u306a\u5e73\u5747\u30671\u30d5\u30a1\u30a4\u30eb2000\u6587\u5b57\u3068\u3057\u305f\u5834\u5408\u3001300\u30d5\u30a1\u30a4\u30eb\u3042\u308b\u306860\u4e07\u6587\u5b57\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>60\u4e07\u3068\u3044\u3046\u6570\u5b57\u306f\u6587\u5eab\u672c\u306b\u6982\u7b97\u3059\u308b\u3068\u7d044\uff5e5\u518a\u5206\u306e\u60c5\u5831\u91cf\u304c\u3042\u308a\u307e\u3059\u3002\u30b2\u30fc\u30e0\u5185\u5bb9\u306b\u3088\u3063\u3066\u591a\u5c11\u306e\u5e45\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u6982\u306d\u6587\u5eab\u672c\u6570\u518a\u5206\u304f\u3089\u3044\u306e\u60c5\u5831\u91cf\u3092\u6271\u3046\u3068\u601d\u3063\u3066\u304a\u304f\u3068\u5927\u304d\u306a\u30ba\u30ec\u306f\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u5927\u91cf\u306e\u6587\u7ae0\u304b\u3089\u30b2\u30fc\u30e0\u306b\u7d44\u307f\u8fbc\u3080\u6700\u7d42\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u5909\u3048\u3066\u3044\u304f\u5f8c\u5de5\u7a0b\u304c\u5fc5\u8981\u3068\u306a\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u3092\u624b\u4f5c\u696d\u3067\u3084\u308b\u3068\u306a\u308b\u3068\u30b3\u30d4\u30da\u306e\u5f80\u5fa9\u3067\u3060\u3044\u3076\u305f\u308b\u3044\u3067\u3059\u3002<\/p>\n<p>\u52ff\u8ad6\u3001\u6f14\u51fa\u5b9f\u88c5\u306f\u305d\u306e\u6027\u8cea\u4e0a\u624b\u4f5c\u696d\u306a\u3093\u3067\u3059\u304c\u3001\u305d\u306e\u4e0b\u6e96\u5099\u304f\u3089\u3044\u306f\u81ea\u52d5\u5316\u3057\u305f\u3044\u3082\u3093\u3067\u3059\u3002<\/p>\n<h1>\u811a\u672c\uff5e\u7d44\u307f\u8fbc\u307f\u307e\u3067\u306e\u30ef\u30fc\u30af\u30d5\u30ed\u30fc<\/h1>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u5165\u308b\u524d\u306b\u3001\u30b2\u30fc\u30e0\u3092\u4f5c\u308b\u4e0a\u3067\u306e\u811a\u672c\u304b\u3089\u7d44\u307f\u8fbc\u307f\u307e\u3067\u306e\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u3092\u3056\u3063\u3068\u66f8\u304d\u4e0b\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n\u7269\u8a9e\u3001\u4e16\u754c\u89b3\u3001\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u8a2d\u5b9a\u306a\u3069\u306f\u6e08\u3093\u3067\u3044\u308b\u3068\u3044\u3046\u72b6\u6cc1\u3067\u306f\u6982\u306d\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<p>\u30fb\u30d7\u30e9\u30f3\u30ca\u30fc\/\u811a\u672c\u5bb6: \u30d7\u30ed\u30c3\u30c8<br \/>\n\u30fb\u811a\u672c\u5bb6: \u521d\u7a3f<br \/>\n\u30fb\u30d7\u30e9\u30f3\u30ca\u30fc\/\u811a\u672c\u5bb6: \u8abf\u6574\u3001\u8868\u73fe\u30c1\u30a7\u30c3\u30af\u3001\u6f14\u6253\u3061<br \/>\n\u30fb\u811a\u672c\u5bb6: \u4fee\u6b63\u7a3f<br \/>\n\u30fb\u30d7\u30e9\u30f3\u30ca\u30fc\/\u811a\u672c\u5bb6: \u8abf\u6574\u3001\u8868\u73fe\u30c1\u30a7\u30c3\u30af\u3001\u6f14\u6253\u3061<br \/>\n\u30fb\u811a\u672c\u5bb6: \u6539\u8a02\u7a3f<br \/>\n\u30fb\u30d7\u30e9\u30f3\u30ca\u30fc: \u6f14\u51fa\u4eee\u7d44\u307f<br \/>\n\u30fb\u30d7\u30ed\u30b0\u30e9\u30de\u30fc: \uff08\u6f14\u51fa\u306b\u8db3\u308a\u306a\u3044\u6a5f\u80fd\u3065\u304f\u308a\uff09<br \/>\n(\u2193\u304b\u3089\u306f\u4fee\u6b63\u3059\u308b\u3068\u3084\u308a\u76f4\u3057\u304c\u591a\u304f\u306a\u308a\u307e\u3059)<br \/>\n\u30fb\u811a\u672c\u5bb6: \u6700\u7d42\u7a3f<br \/>\n\u30fb\u30d7\u30e9\u30f3\u30ca\u30fc: \u6f14\u51fa\u672c\u7d44<br \/>\n\u30fb\u811a\u672c\u5bb6\/\u30d7\u30e9\u30f3\u30ca\u30fc: \u8abf\u6574<br \/>\n\u30fbQA: \u30d5\u30a3\u30fc\u30c9\u30d0\u30c3\u30af<br \/>\n\u30fb\u811a\u672c\u5bb6\/\u30d7\u30e9\u30f3\u30ca\u30fc: \u6700\u7d42\u8abf\u6574<\/p>\n<p>\u3060\u3044\u3076\u7aef\u6298\u3063\u305f\u308a\u3001\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u7684\u306b\u306f\u591a\u5c11\u305a\u308c\u304c\u3042\u308a\u307e\u3059\u304c1\u8a71\u3064\u304f\u308b\u306b\u3082\u305d\u308c\u306a\u308a\u306e\u5de5\u7a0b\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h1>\u811a\u672c\u306e\u69cb\u6587<\/h1>\n<p>\u4eca\u56de\u306e\u8a18\u4e8b\u3067\u306f\u811a\u672c\u30c7\u30fc\u30bf\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u30d1\u30fc\u30b9\u3057\u3088\u3046\u3001\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3059\u304c\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u306f\u3069\u3046\u3044\u3063\u305f\u898f\u5247\u306a\u306e\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u8abf\u3079\u305f\u6240\u3001\u30ed\u30fc\u30ab\u30eb\u30eb\u30fc\u30eb\u7b49\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u65e5\u672c\u306e\u5834\u5408\u5927\u307e\u304b\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306a\u5f62\u5f0f\u306e\u30c6\u30ad\u30b9\u30c8\u306a\u3088\u3046\u3067\u3059\u3002<\/p>\n<pre><code>\u25bd\u3000\u67f1 (\u306f\u3057\u3089\u3002\u25cb\u3068\u304b\u2605\u3068\u304b\u3001\u672c\u8cea\u7684\u306b\u306f\u7269\u8a9e\u306e\u5834\u9762\u304c\u5909\u308f\u3063\u305f\u308a\u3059\u308b\u3068\u304d\u306b\u4f7f\u3044\u307e\u3059\u3002\n\u3000\u3000\u30ed\u30fc\u30ab\u30eb\u30eb\u30fc\u30eb\u306b\u3088\u3063\u3066\u8a18\u53f7\u3067\u610f\u5473\u5408\u3044\u304c\u5909\u308f\u308a\u307e\u3059)\n\n\u3000\u3000\u30c8\u66f8\u304d(\u5168\u89d2\u7a7a\u767d2\u6bb5\u4e0b\u3052\u3067\u753b\u9762\u306e\u8aac\u660e\u3092\u66f8\u3044\u305f\u308a\u3057\u307e\u3059)\n\u3000\u3000\u66f0\u304f\u3001\uff5e\u3068\u7247\u624b\u3092\u4e0a\u3052\u3002\u3063\u3066\u6f14\u51fa\u6307\u793a\u7b49\u3067\u304b\u304b\u308c\u3066\u3044\u305f\u6163\u7fd2\u304b\u3089\u30c8\u66f8\u304d\u3068\u547c\u3070\u308c\u308b\u3093\u3059\u306d\u3002\n\n\u30ad\u30e3\u30e9\u540d\u3000\u300c\u30bb\u30ea\u30d5\u300d\n\u30ad\u30e3\u30e9\u540d\u3000\u300c\u30bb\u30ea\u30d5\u300d\n\u30ad\u30e3\u30e9\u540d\u3000\u300c\u30bb\u30ea\u30d5\n\u3000\u3000\u3000\u3000\u3000\u3000\u6b21\u306e\u884c\u306b\u307e\u305f\u3050\u5834\u5408\u306f\u30bb\u30ea\u30d5\u306e\u982d\u3092\u5408\u308f\u305b\u307e\u3059\u300d\n\u30ad\u30e3\u30e9\u540dA\u30fb\u30ad\u30e3\u30e9\u540dB\u3000\u300c\u30bb\u30ea\u30d5\u300d\n\u30ad\u30e3\u30e9\u540d\u3000\u300c\u30bb\u30ea\u30d5\u300d\n\n\uff03 \u30b3\u30e1\u30f3\u30c8\u3002\u811a\u672c\u3067\u306f\u4f7f\u3044\u307e\u305b\u3093\u304c\u30d7\u30ed\u30b0\u30e9\u30de\u7684\u306b\u306f\u6b32\u3057\u304f\u306a\u308b\u3084\u3064\u3067\u3059\u3002\n\uff03\u3000\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u306e\u5834\u5408\u5168\u89d2\u304c\u597d\u307e\u308c\u307e\u3059(\u5909\u63db\u5909\u3048\u308b\u306e\u9762\u5012\u3067\u3059\u3057\u306d\uff09\n<\/code><\/pre>\n<p>\u5185\u5bb9\u7684\u306b\u306f\u72b6\u6cc1\u8aac\u660e\u3084\u3001\u8ab0\u304c\u4f55\u3092\u558b\u3063\u3066\u3044\u308b\u306e\u304b\u3068\u3044\u3046\u306e\u304c\u5206\u304b\u308b\uff08\u307b\u307c\uff09\u5b9a\u5f62\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n<br \/>\n\u5f62\u5f0f\u3082\u308f\u304b\u308a\u307e\u3057\u305f\u3057\u3001\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u30d1\u30fc\u30b9\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<h1>\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307f\u308b<\/h1>\n<p>\u3056\u3063\u304f\u308a\u3068\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3001\u52d5\u3051\u3070OK\u306e\u7cbe\u795e\u3067lexer\u5074\u306b\u3042\u308b\u7a0b\u5ea6\u60c5\u5831\u57cb\u3081\u8fbc\u307f\u3064\u3064\u3001parser\u5074\u306f\u697d\u3092\u3059\u308b\u3068\u3044\u3046\u611f\u3058\u3067\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u5b9f\u884c\u304c\u3057\u3084\u3059\u3044\u3088\u3046\u306bJavaScript\u3067\u66f8\u3044\u3066\u3044\u307e\u3059\u306e\u3067\u304a\u624b\u5143\u306enode.js\u7b49\u3067\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u5c1a\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u306fUTF8\u56fa\u5b9a\u3068\u4eee\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >\"use strict\";\n\nvar TokenType = {\n    \/\/ \u30c7\u30d0\u30c3\u30b0\u6642\u306b\u8aad\u307f\u3065\u3089\u3044\u306e\u3067\u6587\u5b57\u5217\u3067\u7f6e\u3044\u3068\u304f\n    HASHIRA: \"HASHIRA\",\n    TOGAKI_BEGIN: \"TOGAKI_BEGIN\",\n    TOGAKI_END: \"TOGAKI_END\",\n    NAME: \"NAME\",\n    TEXT: \"TEXT\",\n    LEFT_BRACKET: \"LEFT_BRACKET\",\n    RIGHT_BRACKET: \"RIGHT_BRACKET\",\n    SPACE: \"SPACE\",\n    LINEFEED: \"LINEFEED\",\n    COMMENT: \"COMMENT\",\n    EOF: \"EOF\",\n}\n \nvar LexerState = {\n    DEFAULT: 0,\n    TOGAKI: 1,\n    QUOTE: 2,\n}\n \nclass Token {\n    constructor(inType, inValue, inOffset, inLength) {\n        this.type = inType;\n        this.value = inValue;\n        this.offset = inOffset;\n        this.length = inLength;\n    }\n    \n    toString() {\n        return `[${this.type} ${this.value}]\\n`;\n    }\n}\n \nclass Lexer {\n    \n    peek() {\n        if (this.current+1 &gt;= this.tokens.length) {\n            return new Token(TokenType.EOF);\n        }\n \n        return this.tokens[this.current+1];\n    }\n \n    skip_space() {\n        let i = this.current;\n        for (; i &lt; this.tokens.length; i++) {\n            if (this.tokens[i].type == TokenType.SPACE || this.tokens[i].type == TokenType.LINEFEED) {\n                this.current++;\n                continue;\n            } else {\n                break;\n            }\n        }\n    }\n \n    assume(type) {\n        if (this.current &gt;= this.tokens.length) {\n            return new Token(TokenType.EOF);\n        }\n \n        if (this.tokens[this.current].type == type) {\n            return true;\n        }\n        return false;\n    }\n \n    cur() {\n        if (this.current &gt;= this.tokens.length) {\n            return new Token(TokenType.EOF);\n        }\n \n        return this.tokens[this.current];\n    }\n \n    next() {\n        this.current++;\n        if (this.current+1 &gt;= this.tokens.length) {\n            return new Token(TokenType.EOF);\n        }\n \n        return this.tokens[this.current];\n    }   \n \n    consume() {\n        this.current++;\n        if (this.current+1 &gt;= this.tokens.length) {\n            return;\n        }\n    }   \n \n    constructor(text) {\n        this.tokens = [];\n        this.current = 0;\n \n        let length = text.length;\n        let offset = 0;\n        let state = LexerState.DEFAULT;\n        let is_line_head = true;\n \n        for (var i = 0; i &lt; length;) {\n            let v = this.is_linefeed(text, i);\n            if (v &gt; 0) {\n                this.push_token(new Token(TokenType.LINEFEED, text.substr(i, v), i, v));\n                i += v;\n                is_line_head = true;\n                continue;\n            }\n \n            let character = text[i];\n            \n            if (state == LexerState.DEFAULT) {\n \n                if (is_line_head &amp;&amp; this.is_comment(character)) {\n                    for (var j = i + 1; j &lt; length; j++) {\n                        let x = this.is_linefeed(text, j);\n                        if (x &gt; 0) {\n                            this.push_token(new Token(TokenType.COMMENT, text.substr(i+1, j - x - 1).trim(), i + 1, j - x - 1));\n                            i = j - x;\n                            break;\n                        }\n                    }\n                } else if (this.is_space(character)) {\n                    if (is_line_head &amp;&amp; this.is_space(text[i+1])) {\n                        \/\/ \u30c8\u66f8\u304d\u3067\u3042\u308b\n                        state = LexerState.TOGAKI;\n                        i += 2;\n                        this.push_token(new Token(TokenType.TOGAKI_BEGIN, null, i-2, 2));\n                        continue;\n                    } else {\n                        for (var j = i; j &lt; length; j++) {\n                            let second = text[j];\n                            if (!this.is_space(second)) {\n                                i = j;\n                                break;\n                            }\n                        }\n                    }\n \n                    let value = text.substr(i, j - i);\n                    this.push_token(new Token(TokenType.SPACE, value, i, j - i));\n                    continue;\n                } else if (is_line_head &amp;&amp; this.is_hashira(character)) {\n                    this.push_token(new Token(TokenType.HASHIRA, character, i, 1));\n \n                    for (var j = i + 1; j &lt; length; j++) {\n                        let x = this.is_linefeed(text, j);\n                        if (x &gt; 0) {\n                            this.push_token(new Token(TokenType.TEXT, text.substr(i+1, j - i - x).trim(), i + 1, j - i - x));\n                            i = j;\n                            break;\n                        }\n                    }\n                    continue;\n                } else if (character == \"\u300c\") {\n                    this.push_token(new Token(TokenType.LEFT_BRACKET, \"\u300c\", i, 1));\n                    i++;\n                    state = LexerState.QUOTE;\n                    continue;\n                } else if (is_line_head) {\n                    for (var j = i; j &lt; length; j++) {\n                        if (this.is_space(text[j])) {\n                            this.push_token(new Token(TokenType.NAME, text.substr(i, j - i), i , j - i));\n                            i = j - 1;\n                            break;\n                        }\n                    }\n    \n                    is_line_head = false;\n                    continue;\n                } \n            } else if (state == LexerState.TOGAKI) {\n                for (var j= i; j &lt; length; j++) {\n                    let x = this.is_linefeed(text, j);\n                    if (x &gt; 0) {\n                        this.push_token(new Token(TokenType.TEXT, text.substr(i, j - i), i, j - i));\n                        i = j;\n                        break;\n                    }\n                }\n \n                if (this.is_space(text[i]) &amp;&amp; this.is_space(text[i+1])) {\n                    continue;\n                }\n                this.push_token(new Token(TokenType.TOGAKI_END, null, i, 0));\n                state = LexerState.DEFAULT;\n                continue;\n            } else if (state == LexerState.QUOTE) {\n                if (is_line_head &amp;&amp; this.is_space(character)) {\n                    let j = i;\n                    while (this.is_space(text[j]) &amp;&amp; j &lt; length) {\n                        j++;\n                    }\n                    this.push_token(new Token(TokenType.SPACE, text.substr(i, j - i), i , j -i));\n                    i = j;\n                    is_line_head = false;\n                    continue;\n                } else {\n                    for (var j= i; j &lt; length; j++) {\n                        if (text[j] == \"\u300d\") {\n                            this.push_token(new Token(TokenType.TEXT, text.substr(i, j - i), i, j - i));\n                            this.push_token(new Token(TokenType.RIGHT_BRACKET, \"\u300d\", j, 1));\n                            i = j;\n                            state = LexerState.DEFAULT;\n                            break;\n                        } else {\n                            let x = this.is_linefeed(text, j);\n                            if (x &gt; 0) {\n                                this.push_token(new Token(TokenType.TEXT, text.substr(i, j - i), i, j - i));\n                                this.push_token(new Token(TokenType.LINEFEED, text.substr(j, x), j, x));\n                                is_line_head = true;\n                                i = j + x;\n                                break;\n                            }\n                        }\n \n                    }\n                    continue;   \n                }\n            }\n \n            i++;\n            is_line_head = false;\n        }\n    }\n    \n    dump() {\n        for (var i= 0; i &lt; this.tokens.length; i++) {\n            console.log(this.tokens[i]);\n        }\n    }\n    \n    push_token(token) {\n        this.tokens.push(token);\n    }\n    \n    is_linefeed(text, offset) {\n        if (text[offset] == \"\\r\") {\n            if (text[offset+1] == \"\\n\") {\n                return 2;\n            }\n            return 1;\n        } else if (text[offset] == \"\\n\") {\n            return 1;\n        }\n        return -1;\n    }\n \n    is_hashira(value) {\n        if (value == \"\u25bd\" || value == \"\u25cb\" || value == \"\u2605\" || value == \"\u25b3\") {\n            return true;\n        }\n        return false;\n    }\n    \n    is_comment(value) {\n        \/\/ \u5168\u89d2\uff03\u3082\u3057\u304f\u306f\u534a\u89d2#\n        if (value == \"\uff03\" || value == \"#\") {\n            return true;\n        }\n        return false;\n    }\n    \n    is_space(value) {\n        \/\/ \u5168\u89d2\u7a7a\u767d\u3082\u3057\u304f\u306f\u534a\u89d2\u7a7a\u767d\n        if (value == \"\u3000\" || value == \" \") {\n            return true;\n        }\n        return false;\n    }\n \n}\n \nclass Parser {\n\n    constructor(lex) {\n        this.lex = lex;\n    }\n \n    internal_parse(result, level) {\n        let end = false;\n        while(true) {\n            let next = this.lex.cur();\n            if (end) {\n                break;\n            }\n \n            switch (next.type) {\n                case TokenType.LINEFEED:\n                case TokenType.SPACE:\n                    this.lex.consume();\n                break;\n                case TokenType.NAME:\n                    let name = next;\n                    this.lex.consume();\n                    this.lex.skip_space();\n \n                    if (this.lex.assume(TokenType.LEFT_BRACKET)) {\n                        this.lex.consume();\n                        let tmp = [];\n                        while (!this.lex.assume(TokenType.RIGHT_BRACKET)) {\n                            tmp.push(this.lex.cur());\n                            this.lex.consume();\n                        }\n                        result.push({type: \"QUOTE\", \n                            name: name.value, \n                            text: tmp.filter(x =&gt; x.type == TokenType.TEXT).map(x =&gt; x.value),\n                            length: tmp.filter(x =&gt; x.type == TokenType.TEXT).reduce((x, y) =&gt; x + y.value.length, 0)\n                        });\n                    }  else {\n                        throw new Error(this.lex.tokens[this.lex.current]);\n                    }\n                    break;\n                case TokenType.HASHIRA:\n                    if (next.value == \"\u2605\" &amp;&amp; level &gt; 0) {\n                        return;\n                    }\n                    if (next.value == \"\u25b3\" &amp;&amp; level &gt; 0) {\n                        return;\n                    }\n \n                    let p = {type: \"HASHIRA\", value: next.value, text: this.lex.next().value, children: []};\n                    result.push(p);\n                    this.lex.consume();\n                    this.internal_parse(p.children, level+1);\n                break;\n                case TokenType.COMMENT:\n                    this.lex.consume();\n                    break;\n                case TokenType.TOGAKI_BEGIN:\n                {\n                    this.lex.consume();\n                    let tmp = [];\n                    while (true) {\n                        this.lex.skip_space();\n                        if (!this.lex.assume(TokenType.TOGAKI_END)) {\n                            tmp.push(this.lex.cur());\n                            this.lex.consume();\n                        }\n                        this.lex.consume();\n                        this.lex.skip_space();\n \n                        if (this.lex.assume(TokenType.TOGAKI_BEGIN)) {\n                            this.lex.consume();\n                            continue;\n                        }\n                        result.push({type: \"TOGAKI\", text: tmp.map(x =&gt; x.value)});\n                        break;\n                    }\n                }\n                break;\n                case TokenType.TOGAKI_END:\n                case TokenType.RIGHT_BRACKET:\n                case TokenType.LEFT_BRACKET:\n                    this.lex.consume();\n                    break;\n                case TokenType.EOF:\n                    end = true;\n                    break;\n                default:\n                    this.lex.consume();\n                    break;\n            }\n        }\n    }\n    \n    parse() {\n        let result = [];\n        this.internal_parse(result, 0); \n        return result;\n    }    \n}\n\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\nlet data = `\n\u2605 \u30bb\u30af\u30b7\u30e7\u30f3\uff11\n \n# \u884c\u3053\u3081\u3093\u3068\n \n\u25bd \u304a\u663c\u524d\u306e\u30aa\u30d5\u30a3\u30b9\n \n\u3000\u3000\u3061\u3087\u3073\u3048\u3001\u30a4\u30b9\u306b\u3046\u306a\u3060\u308c\u306a\u304c\u3089\n \n\u3061\u3087\u3073\u3048\u3000\u300c\u3042\u30fc\u3002\u304a\u306a\u304b\u3059\u3044\u305f\u300d\n\u3061\u3083\u307f\u3000\u3000\u300c\u305d\u3046\u3060\u306d\u3002\u308f\u305f\u3057\u3082\u30fc\u304a\u306a\u304b\u3059\u3044\u3061\u3083\u3063\u305f\u300d\n\u3061\u3087\u3073\u3048\u3000\u300c\u4e45\u3057\u3076\u308a\u306b\u713c\u304d\u8089\u3067\u3082\u3044\u304b\u306d\uff1f\u300d\n \n\u3000\u3000\u3061\u3083\u307f\u3002\u7a93\u3092\u898b\u306a\u304c\u3089\u304b\u3089\u8003\u3048\u8fbc\u3080\n \n\u3061\u3083\u307f\u3000\u3000\u300c\u3046\u30fc\u3093\u3002\u4eca\u65e5\u96e8\u3060\u3057\u3001\u5098\u3055\u3055\u306a\u3044\u3067\u3044\u3051\u308b\u3068\u3053\u308d\u306b\u3057\u306a\u3044\uff1f\u300d\n\u3061\u3087\u3073\u3048\u3000\u300c\u78ba\u304b\u306b\u305d\u3063\u3061\u306e\u307b\u3046\u304c\u697d\u3060\u308f\n\u3000\u3000\u3000\u3000\u3000\u3000\u3093\u3058\u3083\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u3067\u3082\u3044\u3053\u3046\u3088\u300d\n\u3061\u3083\u307f\u3000\u3000\u300c\u305d\u3046\u306d\u3002\u6700\u8fd1\u3044\u3063\u3066\u306a\u304b\u3063\u305f\u3057\u884c\u304d\u307e\u3057\u3087\u3002\u30a8\u30ec\u30d9\u30fc\u30bf\u30fc\u30db\u30fc\u30eb\u3067\u5f85\u3061\u5408\u308f\u305b\u3067\u3044\u3044\uff1f\u300d\n\u3061\u3087\u3073\u3048\u3000\u300c\u308a\u3087\u3046\u304b\u3044\u30fc\u300d\n \n##################################################################\n \n\u2605 \u30bb\u30af\u30b7\u30e7\u30f32\n \n\u25bd \u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u30b7\u30e7\u30c3\u30d7\u306b\u3066\n \n\u3000\u3000\u5e83\u3044\u5e97\u5185\u306b\u3001\u5143\u6c17\u306e\u826f\u3044\u5e97\u54e1\u9054\u306e\u58f0\u304c\u97ff\u304f\n \n\u5e97\u54e1\u9054\u3000\u3000\u300c\u30a4\u30e9\u30c3\u30c3\u30b7\u30e3\u30fc\u30a4\u300d\n \n\u3061\u3087\u3073\u3048\u3000\u300c\u3042\u3044\u304b\u308f\u3089\u305a\u5143\u6c17\u3044\u3063\u3071\u3044\u306a\u611f\u3058\u3060\u300d\n\u3061\u3083\u307f\u3000\u3000\u300c\u305d\u3046\u306d\u30fc\u300d\n\u5e97\u54e1\uff11\u3000\u3000\u300c\u3054\u6ce8\u6587\u306f\u306a\u3093\u306b\u306a\u3055\u3044\u307e\u3059\u304b\uff1f\u300d\n\u3061\u3087\u3073\u3048\u3000\u300c\u3093\u3058\u3083\u3002\u30b3\u30fc\u30e9\u3068\u30c1\u30fc\u30ba\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u3067\u300d\n\u3061\u3083\u307f\u3000\u3000\u300c\u79c1\u306f\u30a6\u30fc\u30ed\u30f3\u8336\u3068\u30a2\u30dc\u30ab\u30c9\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u304a\u9858\u3044\u3057\u307e\u3059\u300d\n\u5e97\u54e1\uff11\u3000\u3000\u300c\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u30fc\u300d\n \n\u25b3 \u304a\u3057\u307e\u3044\n`;\nlet lex = new Lexer(data);\n\/\/console.log(lex.tokens);\n \nlet parser = new Parser(lex);\nlet result = parser.parse();\nconsole.log(require('util').inspect(result, false, null));\n \nconsole.log(\"#stats:\")\nconsole.log(\"  actors: \" + getUniqueNames(result));\nconsole.log(\"  length: \" + getTotalLength(result));\nconsole.log(\"  estimate_length: \" + (getTotalLength(result) * 0.1) + \" seconds\");\n \nconsole.log(\"\");\nconsole.log(\"#quotes:\")\nlet tmp = getCharacterQuoteLength(result);\nfor (var name in tmp) {\n    console.log(`${name}: \u30bb\u30ea\u30d5\u6570:${tmp[name].count} \u30c8\u30fc\u30bf\u30eb:${tmp[name].total}`);\n}\n \nfunction getUniqueNames(result) {\n    let hash = new Set();\n    for (var i = 0; i &lt; result.length; i++) {\n        let tmp = result[i];\n        for (var j = 0; j &lt; tmp.children.length; j++) {\n            let tmp2 = tmp.children[j];\n            for (var k = 0; k &lt; tmp2.children.length; k++) {\n                if (tmp2.children[k].type == \"QUOTE\") {\n                    hash.add(tmp2.children[k].name);\n                }\n            }\n        }\n    }\n \n    return Array.from(hash).sort();\n}\n \n \n\/\/\u30ad\u30e3\u30e9\u3054\u3068\u306e\u30bb\u30ea\u30d5\u6570\uff08\u7d71\u8a08\u3060\u3059\u3068\u7d30\u304b\u3044\u30df\u30b9\u306e\u6c17\u3065\u304d\u3068\u304b\u6d41\u308c\u3092\u9055\u3063\u305f\u9762\u3067\u307f\u308c\u308b\u306e\u3067\u30aa\u30b9\u30b9\u30e1\uff09\nfunction getCharacterQuoteLength(result) {\n    let hash = {};\n    for (var i = 0; i &lt; result.length; i++) {\n        let tmp = result[i];\n        for (var j = 0; j &lt; tmp.children.length; j++) {\n            let tmp2 = tmp.children[j];\n            for (var k = 0; k &lt; tmp2.children.length; k++) {\n                if (tmp2.children[k].type == \"QUOTE\") {\n                    if (!(tmp2.children[k].name in hash)) {\n                        hash[tmp2.children[k].name] = {\n                            total: 0,\n                            count: 0\n                        };\n                    }\n \n                    hash[tmp2.children[k].name].total += tmp2.children[k].length;\n                    hash[tmp2.children[k].name].count++;\n                }\n            }\n        }\n    }\n \n    return hash;\n}\n \nfunction getTotalLength(result) {\n    let sum = 0;\n    for (var i = 0; i &lt; result.length; i++) {\n        let tmp = result[i];\n        for (var j = 0; j &lt; tmp.children.length; j++) {\n            let tmp2 = tmp.children[j];\n            for (var k = 0; k &lt; tmp2.children.length; k++) {\n                if (tmp2.children[k].type == \"QUOTE\") {\n                    sum += tmp2.children[k].length;\n                }\n            }\n        }\n    }\n \n    return sum;\n}<\/pre>\n<p>\u3068\u3001\u3053\u3093\u306a\u6240\u3067\u3057\u3087\u3046\u304b\u3002\u3042\u304f\u307e\u3067\u524d\u51e6\u7406\u7cfb\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u5b9f\u969b\u306b\u30b2\u30fc\u30e0\u306b\u7d44\u307f\u8fbc\u307e\u308c\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u52d5\u3051\u3070OK\u3068\u3044\u3046\u65b9\u91dd\u3067\u66f8\u3044\u3066\u5927\u4e08\u592b\u304b\u3068\u3002<\/p>\n<p>\u4eca\u56de\u306e\u8a18\u4e8b\u3067\u306f\u811a\u672c\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u67f1\u306e\u4e00\u90e8\u8a18\u53f7\u306f\u7279\u6b8a\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f<br \/>\n\u30fb\u2605\u306f\u30d5\u30a1\u30a4\u30eb\u5206\u5272\u7528\u306e\u76ee\u5370\u3068\u3057\u307e\u3059<br \/>\n\u30fb\u25b3\u306f\u7d42\u4e86\u306e\u76ee\u5370\u3068\u3057\u307e\u3059<\/p>\n<h1>\u5b9f\u884c<\/h1>\n<p>\u305d\u308c\u3067\u306f\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002\u666e\u6bb5\u79c1\u306fnode\u306ev12\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3082\u3057\u304b\u3057\u305f\u3089\u304a\u624b\u6301\u3061\u306e\u74b0\u5883\u3067\u52d5\u304b\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u30fb\u30fb\u30fb<\/p>\n<pre><code>[ { type: 'HASHIRA',\n    value: '\u2605',\n    text: '\u30bb\u30af\u30b7\u30e7\u30f3\uff11',\n    children:\n     [ { type: 'HASHIRA',\n         value: '\u25bd',\n         text: '\u304a\u663c\u524d\u306e\u30aa\u30d5\u30a3\u30b9',\n         children:\n          [ { type: 'TOGAKI', text: [ '\u3061\u3087\u3073\u3048\u3001\u30a4\u30b9\u306b\u3046\u306a\u3060\u308c\u306a\u304c\u3089' ] },\n            { type: 'QUOTE', name: '\u3061\u3087\u3073\u3048', text: [ '\u3042\u30fc\u3002\u304a\u306a\u304b\u3059\u3044\u305f' ], length: 9 },\n            { type: 'QUOTE',\n              name: '\u3061\u3083\u307f',\n              text: [ '\u305d\u3046\u3060\u306d\u3002\u308f\u305f\u3057\u3082\u30fc\u304a\u306a\u304b\u3059\u3044\u3061\u3083\u3063\u305f' ],\n              length: 19 },\n            { type: 'QUOTE',\n              name: '\u3061\u3087\u3073\u3048',\n              text: [ '\u4e45\u3057\u3076\u308a\u306b\u713c\u304d\u8089\u3067\u3082\u3044\u304b\u306d\uff1f' ],\n              length: 14 },\n            { type: 'TOGAKI', text: [ '\u3061\u3083\u307f\u3002\u7a93\u3092\u898b\u306a\u304c\u3089\u304b\u3089\u8003\u3048\u8fbc\u3080' ] },\n            { type: 'QUOTE',\n              name: '\u3061\u3083\u307f',\n              text: [ '\u3046\u30fc\u3093\u3002\u4eca\u65e5\u96e8\u3060\u3057\u3001\u5098\u3055\u3055\u306a\u3044\u3067\u3044\u3051\u308b\u3068\u3053\u308d\u306b\u3057\u306a\u3044\uff1f' ],\n              length: 27 },\n            { type: 'QUOTE',\n              name: '\u3061\u3087\u3073\u3048',\n              text: [ '\u78ba\u304b\u306b\u305d\u3063\u3061\u306e\u307b\u3046\u304c\u697d\u3060\u308f', '\u3093\u3058\u3083\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u3067\u3082\u3044\u3053\u3046\u3088' ],\n              length: 28 },\n            { type: 'QUOTE',\n              name: '\u3061\u3083\u307f',\n              text: [ '\u305d\u3046\u306d\u3002\u6700\u8fd1\u3044\u3063\u3066\u306a\u304b\u3063\u305f\u3057\u884c\u304d\u307e\u3057\u3087\u3002\u30a8\u30ec\u30d9\u30fc\u30bf\u30fc\u30db\u30fc\u30eb\u3067\u5f85\u3061\u5408\u308f\u305b\u3067\u3044\u3044\uff1f' ],\n              length: 39 },\n            { type: 'QUOTE', name: '\u3061\u3087\u3073\u3048', text: [ '\u308a\u3087\u3046\u304b\u3044\u30fc' ], length: 6 } ] } ] },\n  { type: 'HASHIRA',\n    value: '\u2605',\n    text: '\u30bb\u30af\u30b7\u30e7\u30f32',\n    children:\n     [ { type: 'HASHIRA',\n         value: '\u25bd',\n         text: '\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u30b7\u30e7\u30c3\u30d7\u306b\u3066',\n         children:\n          [ { type: 'TOGAKI', text: [ '\u5e83\u3044\u5e97\u5185\u306b\u3001\u5143\u6c17\u306e\u826f\u3044\u5e97\u54e1\u9054\u306e\u58f0\u304c\u97ff\u304f' ] },\n            { type: 'QUOTE', name: '\u5e97\u54e1\u9054', text: [ '\u30a4\u30e9\u30c3\u30c3\u30b7\u30e3\u30fc\u30a4' ], length: 8 },\n            { type: 'QUOTE',\n              name: '\u3061\u3087\u3073\u3048',\n              text: [ '\u3042\u3044\u304b\u308f\u3089\u305a\u5143\u6c17\u3044\u3063\u3071\u3044\u306a\u611f\u3058\u3060' ],\n              length: 16 },\n            { type: 'QUOTE', name: '\u3061\u3083\u307f', text: [ '\u305d\u3046\u306d\u30fc' ], length: 4 },\n            { type: 'QUOTE',\n              name: '\u5e97\u54e1\uff11',\n              text: [ '\u3054\u6ce8\u6587\u306f\u306a\u3093\u306b\u306a\u3055\u3044\u307e\u3059\u304b\uff1f' ],\n              length: 14 },\n            { type: 'QUOTE',\n              name: '\u3061\u3087\u3073\u3048',\n              text: [ '\u3093\u3058\u3083\u3002\u30b3\u30fc\u30e9\u3068\u30c1\u30fc\u30ba\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u3067' ],\n              length: 18 },\n            { type: 'QUOTE',\n              name: '\u3061\u3083\u307f',\n              text: [ '\u79c1\u306f\u30a6\u30fc\u30ed\u30f3\u8336\u3068\u30a2\u30dc\u30ab\u30c9\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u304a\u9858\u3044\u3057\u307e\u3059' ],\n              length: 24 },\n            { type: 'QUOTE',\n              name: '\u5e97\u54e1\uff11',\n              text: [ '\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u30fc' ],\n              length: 12 } ] } ] },\n  { type: 'HASHIRA', value: '\u25b3', text: '\u304a\u3057\u307e\u3044', children: [] } ]\n#stats:\n  actors: \u3061\u3083\u307f,\u3061\u3087\u3073\u3048,\u5e97\u54e1\u9054,\u5e97\u54e1\uff11\n  length: 238\n  estimate_length: 23.8 seconds\n\n#quotes:\n\u3061\u3087\u3073\u3048: \u30bb\u30ea\u30d5\u6570:6 \u30c8\u30fc\u30bf\u30eb:91\n\u3061\u3083\u307f: \u30bb\u30ea\u30d5\u6570:5 \u30c8\u30fc\u30bf\u30eb:113\n\u5e97\u54e1\u9054: \u30bb\u30ea\u30d5\u6570:1 \u30c8\u30fc\u30bf\u30eb:8\n\u5e97\u54e1\uff11: \u30bb\u30ea\u30d5\u6570:2 \u30c8\u30fc\u30bf\u30eb:26\n<\/code><\/pre>\n<p>\u3068\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u30d1\u30fc\u30b9\u3057\u3064\u3064\u7c21\u5358\u306a\u7d71\u8a08\u60c5\u5831\u304c\u3060\u305b\u307e\u3057\u305f\u3002\u7d71\u8a08\u60c5\u5831\u3092\u51fa\u3059\u3068\u4e9b\u7d30\u306a\u30df\u30b9\u7b49\u628a\u63e1\u3057\u3084\u3059\u3044\u306e\u3067\u3064\u3044\u3067\u306b\u4f5c\u3063\u3068\u304f\u3068\u826f\u3044\u611f\u3058\u3067\u3059\u3002<\/p>\n<h1>Excel\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u5c55\u958b<\/h1>\n<p>parse\u3064\u3044\u3067\u306b\u9069\u5f53\u306bExcel\u30d5\u30a1\u30a4\u30eb\u3078\u5c55\u958b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code>npm install -g xlsx\n<\/code><\/pre>\n<p>\u4f9d\u5b58\u30e9\u30a4\u30d6\u30e9\u30ea\u306exlsx\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3064\u3064\u4e0b\u8a18\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >\"use strict\";\n\nlet result = [ { type: 'HASHIRA',\n    value: '\u2605',\n    text: '\u30bb\u30af\u30b7\u30e7\u30f3\uff11',\n    children:\n     [ { type: 'HASHIRA',\n         value: '\u25bd',\n         text: '\u304a\u663c\u524d\u306e\u30aa\u30d5\u30a3\u30b9',\n         children:\n          [ { type: 'TOGAKI', text: [ '\u3061\u3087\u3073\u3048\u3001\u30a4\u30b9\u306b\u3046\u306a\u3060\u308c\u306a\u304c\u3089' ] },\n            { type: 'QUOTE', name: '\u3061\u3087\u3073\u3048', text: [ '\u3042\u30fc\u3002\u304a\u306a\u304b\u3059\u3044\u305f' ], length: 9 },\n            { type: 'QUOTE',\n              name: '\u3061\u3083\u307f',\n              text: [ '\u305d\u3046\u3060\u306d\u3002\u308f\u305f\u3057\u3082\u30fc\u304a\u306a\u304b\u3059\u3044\u3061\u3083\u3063\u305f' ],\n              length: 19 },\n            { type: 'QUOTE',\n              name: '\u3061\u3087\u3073\u3048',\n              text: [ '\u4e45\u3057\u3076\u308a\u306b\u713c\u304d\u8089\u3067\u3082\u3044\u304b\u306d\uff1f' ],\n              length: 14 },\n            { type: 'TOGAKI', text: [ '\u3061\u3083\u307f\u3002\u7a93\u3092\u898b\u306a\u304c\u3089\u304b\u3089\u8003\u3048\u8fbc\u3080' ] },\n            { type: 'QUOTE',\n              name: '\u3061\u3083\u307f',\n              text: [ '\u3046\u30fc\u3093\u3002\u4eca\u65e5\u96e8\u3060\u3057\u3001\u5098\u3055\u3055\u306a\u3044\u3067\u3044\u3051\u308b\u3068\u3053\u308d\u306b\u3057\u306a\u3044\uff1f' ],\n              length: 27 },\n            { type: 'QUOTE',\n              name: '\u3061\u3087\u3073\u3048',\n              text: [ '\u78ba\u304b\u306b\u305d\u3063\u3061\u306e\u307b\u3046\u304c\u697d\u3060\u308f', '\u3093\u3058\u3083\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u3067\u3082\u3044\u3053\u3046\u3088' ],\n              length: 28 },\n            { type: 'QUOTE',\n              name: '\u3061\u3083\u307f',\n              text: [ '\u305d\u3046\u306d\u3002\u6700\u8fd1\u3044\u3063\u3066\u306a\u304b\u3063\u305f\u3057\u884c\u304d\u307e\u3057\u3087\u3002\u30a8\u30ec\u30d9\u30fc\u30bf\u30fc\u30db\u30fc\u30eb\u3067\u5f85\u3061\u5408\u308f\u305b\u3067\u3044\u3044\uff1f' ],\n              length: 39 },\n            { type: 'QUOTE', name: '\u3061\u3087\u3073\u3048', text: [ '\u308a\u3087\u3046\u304b\u3044\u30fc' ], length: 6 } ] } ] },\n  { type: 'HASHIRA',\n    value: '\u2605',\n    text: '\u30bb\u30af\u30b7\u30e7\u30f32',\n    children:\n     [ { type: 'HASHIRA',\n         value: '\u25bd',\n         text: '\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u30b7\u30e7\u30c3\u30d7\u306b\u3066',\n         children:\n          [ { type: 'TOGAKI', text: [ '\u5e83\u3044\u5e97\u5185\u306b\u3001\u5143\u6c17\u306e\u826f\u3044\u5e97\u54e1\u9054\u306e\u58f0\u304c\u97ff\u304f' ] },\n            { type: 'QUOTE', name: '\u5e97\u54e1\u9054', text: [ '\u30a4\u30e9\u30c3\u30c3\u30b7\u30e3\u30fc\u30a4' ], length: 8 },\n            { type: 'QUOTE',\n              name: '\u3061\u3087\u3073\u3048',\n              text: [ '\u3042\u3044\u304b\u308f\u3089\u305a\u5143\u6c17\u3044\u3063\u3071\u3044\u306a\u611f\u3058\u3060' ],\n              length: 16 },\n            { type: 'QUOTE', name: '\u3061\u3083\u307f', text: [ '\u305d\u3046\u306d\u30fc' ], length: 4 },\n            { type: 'QUOTE',\n              name: '\u5e97\u54e1\uff11',\n              text: [ '\u3054\u6ce8\u6587\u306f\u306a\u3093\u306b\u306a\u3055\u3044\u307e\u3059\u304b\uff1f' ],\n              length: 14 },\n            { type: 'QUOTE',\n              name: '\u3061\u3087\u3073\u3048',\n              text: [ '\u3093\u3058\u3083\u3002\u30b3\u30fc\u30e9\u3068\u30c1\u30fc\u30ba\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u3067' ],\n              length: 18 },\n            { type: 'QUOTE',\n              name: '\u3061\u3083\u307f',\n              text: [ '\u79c1\u306f\u30a6\u30fc\u30ed\u30f3\u8336\u3068\u30a2\u30dc\u30ab\u30c9\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u304a\u9858\u3044\u3057\u307e\u3059' ],\n              length: 24 },\n            { type: 'QUOTE',\n              name: '\u5e97\u54e1\uff11',\n              text: [ '\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u30fc' ],\n              length: 12 } ] } ] },\n  { type: 'HASHIRA', value: '\u25b3', text: '\u304a\u3057\u307e\u3044', children: [] } ];\n\nconst XLSX = require(\"xlsx\");\nlet wb = XLSX.utils.book_new();\nlet ws_data = [];\nws_data.push([\"name\", \"quote\"]);\nfor (var n in result) {\n    for (var x in result[n].children) {\n        let tmp = result[n].children[x].children;\n        for (var j in tmp) {\n            if (tmp[j].type == \"QUOTE\") {\n                ws_data.push([tmp[j].name, tmp[j].text.join(\"\\n\")]);\n            } else if (tmp[j].type == \"TOGAKI\") {\n                ws_data.push([]);\n                ws_data.push([\"#\", tmp[j].text.join(\"\\n\")]);\n                ws_data.push([]);\n            }\n        }\n    }\n}\n\nvar ws = XLSX.utils.aoa_to_sheet(ws_data);\nXLSX.utils.book_append_sheet(wb, ws, \"Sheet1\");\nXLSX.writeFile(wb, \"sample.xlsx\");\n<\/pre>\n<p>\u5b9f\u884c\u3057\u3066\u51fa\u6765\u4e0a\u304c\u3063\u305fsample.xlsx\u3092\u958b\u3044\u3066\u307f\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u306b\u4ed5\u4e0a\u304c\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2019\/07\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8_072919_031340_PM.jpg\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2019\/07\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8_072919_031340_PM.jpg\" alt=\"\" width=\"733\" height=\"493\" class=\"alignnone size-full wp-image-18945 \" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2019\/07\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8_072919_031340_PM.jpg 733w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2019\/07\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8_072919_031340_PM-276x186.jpg 276w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2019\/07\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8_072919_031340_PM-595x400.jpg 595w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/a><\/p>\n<p>\u69cb\u6587\u60c5\u5831\u304cjson\u306b\u306a\u3063\u3066\u3044\u308c\u3070\u5f8c\u5de5\u7a0b\u306f\u697d\u306b\u51e6\u7406\u3067\u304d\u307e\u3059\u306d\u3002\u4eca\u56de\u306fJavaScript\u3067\u66f8\u304d\u307e\u3057\u305f\u304c\u304a\u597d\u304d\u306a\u8a00\u8a9e\u3092\u4f7f\u3046\u3067\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u82e5\u5e72\u4eca\u56de\u306e\u30b3\u30fc\u30c9\u306e\u306f\u3084\u3063\u3064\u3051\u611f\u304c\u6f02\u3044\u307e\u3059\u304c\u3001\u5b9f\u969b\u30b2\u30fc\u30e0\u4f5c\u3063\u3066\u904b\u7528\u3057\u305f\u308a\u3057\u3066\u3044\u308b\u3068\u3001\u30b5\u30d6\u306e\u30c4\u30fc\u30eb\u7684\u306a\u3082\u306e\u306f\u3067\u304d\u308b\u3060\u3051\u5e73\u6613\u306a\u8a2d\u8a08\u3067\u3001\u305d\u3093\u306a\u30e1\u30f3\u30c6\u3057\u306a\u304f\u3066\u3082\u3042\u308b\u7a0b\u5ea6\u52d5\u3044\u3066\u304f\u308c\u3066\u3001\u304b\u3064\u30b2\u30fc\u30e0\u306e\u8868\u73fe\u306b\u5408\u308f\u305b\u3066\u30d3\u30eb\u30c9\u306a\u3057\u3067\u624b\u65e9\u304fpatch\u5f53\u3066\u3089\u308c\u308b\u65b9\u304c\u65e5\u3005\u306e\u904b\u7528\u697d\u3060\u306a\u3001\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h1>\u811a\u672c\u306e\u904b\u7528\u3092\u898b\u636e\u3048\u3066<\/h1>\n<p>\u73fe\u5834\u3067\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u7d20\u306e\u307e\u307e\u3001\u3068\u3044\u3046\u306e\u306f\u5c11\u306a\u3044\u306e\u3067\u30c6\u30ad\u30b9\u30c8\u306b\u7279\u6b8a\u30bf\u30b0\u57cb\u3081\u8fbc\u307f\u578b\u3060\u3063\u305f\u308a\u3001\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u76f4\u3060\u3063\u305f\u308a\u3059\u308b\u3093\u3067\u3059\u304c\u57fa\u672c\u306e\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u3092\u81ea\u529b\u3067\u30d1\u30fc\u30b9\u3067\u304d\u308b\u3060\u3051\u306e\u30b3\u30fc\u30c9\u529b\u304c\u3042\u308c\u3070\u3042\u3068\u306f\u3069\u3046\u306b\u3067\u3082\u6599\u7406\u3067\u304d\u307e\u3059\u306d\u3002<br \/>\n\u5b9f\u969b\u3068\u3042\u308b\u30b2\u30fc\u30e0\u3067\u3082\u66f8\u5f0f\u306f\u9055\u3044\u307e\u3059\u304c\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u6f14\u51fa\u30c6\u30f3\u30d7\u30ec\u30c7\u30fc\u30bf\u3078\u306e\u5c55\u958b\u306a\u3069\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u7d4c\u7531\u3067\u3084\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u958b\u767a\u304c\u9032\u3093\u3067\u3044\u304f\u3068\u3001\u811a\u672c\u30c7\u30fc\u30bf\u95a2\u9023\u3060\u3051\u3067\u3082\u30a2\u30ec\u30b3\u30ec\u3084\u308a\u305f\u3044\u3053\u3068\u304c\u51fa\u3066\u304d\u307e\u3059\u3002<br \/>\u4f8b\u3048\u3070<\/p>\n<p>\u30fb\u30b2\u30fc\u30e0\u7528\u306e\u6f14\u51fa\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u51fa\u3057\u305f\u3044(\u4eca\u56de\u306e\u30b1\u30fc\u30b9)<br \/>\n\u30fb\u811a\u672c\u306e\u6bb5\u968e\u3067\u8aa4\u5b57\u8131\u5b57\u30c1\u30a7\u30c3\u30af\u3092\u59cb\u3081\u3068\u3057\u305f\u8868\u73fe\u30c1\u30a7\u30c3\u30af\u3092\u3057\u305f\u3044\/\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044<br \/>\n\u30fb\u7d71\u8a08\u30c7\u30fc\u30bf\u3092\u51fa\u3057\u305f\u3044<br \/>\n\u30fb\u6821\u6b63\u7528\u306e\u5370\u5237\u3057\u305f\u3044<br \/>\n\u30fb\u30dc\u30a4\u30b9\u53ce\u9332\u7528\u306e\u53f0\u672c\u4f5c\u308a\u305f\u3044<br \/>\n\u30fbdiff\u3068\u308a\u305f\u3044<\/p>\n<p>\u69cb\u6587\u6728\u30c7\u30fc\u30bf\u3092\u4f5c\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u5358\u54c1\u3067\u306f\u3042\u307e\u308a\u610f\u5473\u306e\u306a\u3044\u3082\u306e\u3067\u3059\u304c\u3001\u6e96\u5099\u3092\u3057\u3066\u3044\u304f\u3068\u3053\u3046\u3044\u3063\u305f\u8981\u671b\u3078\u306e\u5fdc\u7528\u306f\u697d\u306b\u3067\u304d\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h1>\u3042\u3068\u304c\u304d\uff08\u3068\u514d\u8cac\uff09<\/h1>\n<p>\u30fb\u547c\u79f0\u3084\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u306b\u3064\u3044\u3066\u306f\u30c1\u30fc\u30e0\u3084\u7d44\u7e54\u306b\u3088\u3063\u3066\u9055\u3046\u306e\u3067\u5e73\u6613\u306a\u8868\u73fe\u306b\u843d\u3068\u3057\u3066\u3042\u308a\u307e\u3059<br \/>\n\u30fb\uff08\u597d\u307f\u306e\u7bc4\u56f2\u3060\u3068\u601d\u3046\u306e\u3067\uff09\u30c6\u30ad\u30b9\u30c8\u30c7\u30fc\u30bf\/\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306a\u3069\u306f\u30c1\u30fc\u30e0\u306b\u3042\u3063\u305f\u3082\u306e\u3092\u4f7f\u3046\u306e\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059<br \/>\n\u30fb\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u8aac\u660e\u7528\u306b\u66f8\u3044\u305f\u3082\u306e\u306a\u306e\u3067\u30b1\u30fc\u30b9\u51e6\u7406\u304c\u7518\u304b\u3063\u305f\u308a\u3057\u307e\u3059\u3002\u3042\u304f\u307e\u3067\u3054\u81ea\u8eab\u306e\u8cac\u4efb\u306e\u7bc4\u56f2\u5185\u3067\u3054\u5229\u7528\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\uff5e<\/p>\n<h1>\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/h1>\n<p><a href=\"https:\/\/kyakuhonkakikata.com\/rulesofscreenplay\">\u811a\u672c\u306e\u66f8\u304d\u65b9: \u811a\u672c\u306e\u30eb\u30fc\u30eb<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3054\u3076\u3055\u305f\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u3061\u3087\u3073\u3048\u3067\u3059\u3002 \u4eca\u65e5\u306f\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u3092\u30d1\u30fc\u30b9\u3057\u3066json\u306e\u69cb\u6587\u30c7\u30fc\u30bf\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002 \u80cc\u666f \u7269\u8a9e\u3092\u9032\u3081\u308b\u30bf\u30a4\u30d7\u306e\u30b2\u30fc\u30e0\u3092\u4f5c\u308b\u4e0a\u3067\u3001\u306a\u3093\u304b\u3057\u3089\u306e\u811a\u672c\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u30b2\u30fc\u30e0\u5411\u3051\u306e\u6f14\u51fa\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306a [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-18630","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/18630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=18630"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/18630\/revisions"}],"predecessor-version":[{"id":18966,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/18630\/revisions\/18966"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=18630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=18630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=18630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}