{"id":2914,"date":"2013-08-20T16:30:51","date_gmt":"2013-08-20T07:30:51","guid":{"rendered":"http:\/\/peta.okechan.net\/blog\/?p=2914"},"modified":"2013-08-20T16:30:51","modified_gmt":"2013-08-20T07:30:51","slug":"2-7-%e3%83%89%e3%83%a9%e3%82%a4%e3%83%90","status":"publish","type":"post","link":"https:\/\/peta.okechan.net\/blog\/archives\/2914","title":{"rendered":"2.7. \u30c9\u30e9\u30a4\u30d0"},"content":{"rendered":"<p><a href=\"https:\/\/peta.okechan.net\/blog\/archives\/2836\" title=\"LLVM\u306b\u3088\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306e\u5b9f\u88c5\">LLVM\u306b\u3088\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306e\u5b9f\u88c5\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u65e5\u672c\u8a9e\u8a33<\/a><br \/>\n\u7b2c2\u7ae0 \u4e07\u83ef\u93e1: \u69cb\u6587\u89e3\u6790\u5668\u3068AST\u306e\u5b9f\u88c5<br \/>\n<a href=\"http:\/\/llvm.org\/docs\/tutorial\/LangImpl02.html#the-driver\" target=\"_blank\">\u7b2c7\u7bc0 \u30c9\u30e9\u30a4\u30d0<\/a><\/p>\n<p>\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u3053\u308c\u307e\u3067\u4f5c\u6210\u3057\u305f\u69cb\u6587\u89e3\u6790\u306e\u305f\u3081\u306e\u30d1\u30fc\u30c4\u3092\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30c7\u30a3\u30b9\u30d1\u30c3\u30c1\u30eb\u30fc\u30d7\u304b\u3089\u5358\u306b\u547c\u3073\u51fa\u3059\u3060\u3051\u3067\u3042\u308b\u3002<br \/>\n\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30eb\u30fc\u30d7\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u3068\u3066\u3082\u8208\u5473\u6df1\u3044\u90e8\u5206\u3001\u3068\u3044\u3046\u308f\u3051\u3067\u306f\u306a\u3044\u3002<br \/>\n\u4ee5\u4e0b\u306f\u3001&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u69cb\u6587\u89e3\u6790\uff08Top-Level Parsing\uff09&#8221;\u90e8\u5206\u306e\u5168\u30b3\u30fc\u30c9\u3067\u3042\u308b\u3002<br \/>\n<em>\u8a33\u6ce8: \u3053\u3053\u3067\u306e&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb&#8221;\u3068\u3001\u3053\u308c\u4ee5\u964d\u306e&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb&#8221;\u306f\u610f\u5473\u304c\u9055\u3046\u3068\u601d\u308f\u308c\u308b\u3002<br \/>\n\u3053\u3053\u3067\u306e&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb&#8221;\u306f\u3001\u4e07\u83ef\u93e1\u30b3\u30f3\u30d1\u30a4\u30e9\u3067\u3042\u308bC++\u306e\u30b3\u30fc\u30c9\u306b\u304a\u3051\u308b&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u201d\u3092\u6307\u3057\u3001\u3053\u308c\u4ee5\u964d\u306e&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb&#8221;\u306f\u3001\u4e07\u83ef\u93e1\u8a00\u8a9e\u3067\u66f8\u304b\u308c\u308b\u30b3\u30fc\u30c9\u306b\u304a\u3051\u308b\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u3092\u6307\u3059\u3068\u601d\u308f\u308c\u308b\u3002<\/em><\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/\/ top ::= definition | external | expression | ';'\r\nstatic void MainLoop() {\r\n  while (1) {\r\n    fprintf(stderr, &quot;ready&gt; &quot;);\r\n    switch (CurTok) {\r\n    case tok_eof:    return;\r\n    case ';':        getNextToken(); break;  \/\/ \u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u7121\u8996\u3059\u308b\u3002\r\n    case tok_def:    HandleDefinition(); break;\r\n    case tok_extern: HandleExtern(); break;\r\n    default:         HandleTopLevelExpression(); break;\r\n    }\r\n  }\r\n}<\/pre>\n<p>\u3053\u306e\u306a\u304b\u3067\u4e00\u756a\u8208\u5473\u6df1\u3044\u90e8\u5206\u306f\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u7121\u8996\u3059\u308b\u3068\u3044\u3046\u4e8b\u3067\u3042\u308b\u3002<br \/>\n\u306a\u305c\u3053\u3093\u306a\u3053\u3068\u3092\u3059\u308b\u306e\u304b\uff1f<br \/>\n\u305d\u306e\u4e3b\u306a\u7406\u7531\u306f\u3001\u4f8b\u3048\u3070&#8221;4 + 5&#8243;\u3068\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u306b\u5165\u529b\u3057\u305f\u5834\u5408\u3001\u5165\u529b\u304c\u5b8c\u4e86\u3057\u305f\u306e\u304b\u305d\u3046\u3067\u306a\u3044\u306e\u304b\u69cb\u6587\u89e3\u6790\u5668\u306f\u77e5\u308b\u3053\u3068\u304c\u51fa\u6765\u306a\u3044\u304b\u3089\u3067\u3042\u308b\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u5f0f\u306e\u7d42\u308f\u308a\u304c&#8221;4 + 5&#8243;\u306e\u5834\u5408\u3001\u305d\u306e\u5f8c\u306b&#8221;def foo\u2026&#8221;\u3068\u66f8\u304f\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<br \/>\n\u3082\u3057\u304f\u306f\u3001&#8221;4 + 5&#8243;\u306e\u5f8c\u306b&#8221;* 6&#8243;\u3068\u5f0f\u3092\u7d9a\u3051\u308b\u3053\u3068\u3082\u51fa\u6765\u308b\u3002<br \/>\n\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u3067\u30bb\u30df\u30b3\u30ed\u30f3\u304c\u4f7f\u3048\u308c\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u306f&#8221;4 + 5;&#8221;\u3068\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u3001\u69cb\u6587\u89e3\u6790\u5668\u306f\u305d\u3053\u3067\u5f0f\u304c\u7d42\u4e86\u3057\u3066\u308b\u3053\u3068\u3092\u77e5\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<br \/>\n<em>\u8a33\u6ce8: \u3061\u3087\u3063\u3068\u3053\u3053\u5206\u304b\u308a\u3065\u3089\u3044\u3068\u601d\u3046\u306e\u3067\u88dc\u8db3\u3002<br \/>\n\u69cb\u6587\u89e3\u6790\u5668\u304c\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u7121\u8996\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306b\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u66f8\u3044\u3066\u3082\u826f\u3044\u3068\u3044\u3046\u4e8b\u306b\u306a\u308b\u3002<br \/>\n\u5b57\u53e5\u89e3\u6790\u5668\u3067\u306fisspace\u95a2\u6570\u306b\u3088\u3063\u3066\u7a7a\u767d\u6587\u5b57\uff08\u6539\u884c\u3092\u542b\u3080\uff09\u304c\u7121\u8996\u3055\u308c\u308b\uff08\u666e\u901a\u306e\u7a7a\u767d\u3068\u540c\u3058\u6271\u3044\uff09\u306e\u3067\u3001\u6539\u884c\u306b\u3088\u3063\u3066\u5f0f\u306e\u7d42\u308f\u308a\u3092\u7279\u5b9a\u51fa\u6765\u306a\u3044\u3002<br \/>\n\u4e07\u83ef\u93e1\u3067\u306f\u3001\u5f0f\u306e\u5f8c\u306b\u95a2\u6570\u5b9a\u7fa9\u7b49\u304c\u7d9a\u304f\u5834\u5408\u3001\u5f0f\u306e\u884c\u672b\u306e\u30bb\u30df\u30b3\u30ed\u30f3\u306f\u5fc5\u9808\u3067\u306f\u306a\u3044\u304c\u3001\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u4f7f\u3046\u3053\u3068\u306b\u3088\u3063\u3066\u5f0f\u306e\u7d42\u308f\u308a\u3092\u660e\u793a\u7684\u306b\u30b3\u30f3\u30d1\u30a4\u30e9\u306b\u4f1d\u3048\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p><a href=\"https:\/\/peta.okechan.net\/blog\/archives\/2836\" title=\"LLVM\u306b\u3088\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306e\u5b9f\u88c5\">LLVM\u306b\u3088\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306e\u5b9f\u88c5\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u65e5\u672c\u8a9e\u8a33<\/a><br \/>\n\u7b2c2\u7ae0 \u4e07\u83ef\u93e1: \u69cb\u6587\u89e3\u6790\u5668\u3068AST\u306e\u5b9f\u88c5<br \/>\n<a href=\"http:\/\/llvm.org\/docs\/tutorial\/LangImpl02.html#the-driver\" target=\"_blank\">\u7b2c7\u7bc0 \u30c9\u30e9\u30a4\u30d0<\/a><\/p>\n<p>\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u3053\u308c\u307e\u3067\u4f5c\u6210\u3057\u305f\u69cb\u6587\u89e3\u6790\u306e\u305f\u3081\u306e\u30d1\u30fc\u30c4\u3092\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30c7\u30a3\u30b9\u30d1\u30c3\u30c1\u30eb\u30fc\u30d7\u304b\u3089\u5358\u306b\u547c\u3073\u51fa\u3059\u3060\u3051\u3067\u3042\u308b\u3002<br \/>\n\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30eb\u30fc\u30d7\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u3068\u3066\u3082\u8208\u5473\u6df1\u3044\u90e8\u5206\u3001\u3068\u3044\u3046\u308f\u3051\u3067\u306f\u306a\u3044\u3002<br \/>\n\u4ee5\u4e0b\u306f\u3001&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u69cb\u6587\u89e3\u6790\uff08Top-Level Parsing\uff09&#8221;\u90e8\u5206\u306e\u5168\u30b3\u30fc\u30c9\u3067\u3042\u308b\u3002<br \/>\n<em>\u8a33\u6ce8: \u3053\u3053\u3067\u306e&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb&#8221;\u3068\u3001\u3053\u308c\u4ee5\u964d\u306e&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb&#8221;\u306f\u610f\u5473\u304c\u9055\u3046\u3068\u601d\u308f\u308c\u308b\u3002<br \/>\n\u3053\u3053\u3067\u306e&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb&#8221;\u306f\u3001\u4e07\u83ef\u93e1\u30b3\u30f3\u30d1\u30a4\u30e9\u3067\u3042\u308bC++\u306e\u30b3\u30fc\u30c9\u306b\u304a\u3051\u308b&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u201d\u3092\u6307\u3057\u3001\u3053\u308c\u4ee5\u964d\u306e&#8221;\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb&#8221;\u306f\u3001\u4e07\u83ef\u93e1\u8a00\u8a9e\u3067\u66f8\u304b\u308c\u308b\u30b3\u30fc\u30c9\u306b\u304a\u3051\u308b\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u3092\u6307\u3059\u3068\u601d\u308f\u308c\u308b\u3002<\/em><\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/\/ top ::= definition | external | expression | ';'\r\nstatic void MainLoop() {\r\n  while (1) {\r\n    fprintf(stderr, &quot;ready&gt; &quot;);\r\n    switch (CurTok) {\r\n    case tok_eof:    return;\r\n    case ';':        getNextToken(); break;  \/\/ \u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u7121\u8996\u3059\u308b\u3002\r\n    case tok_def:    HandleDefinition(); break;\r\n    case tok_extern: HandleExtern(); break;\r\n    default:         HandleTopLevelExpression(); break;\r\n    }\r\n  }\r\n}<\/pre>\n<p>\u3053\u306e\u306a\u304b\u3067\u4e00\u756a\u8208\u5473\u6df1\u3044\u90e8\u5206\u306f\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u7121\u8996\u3059\u308b\u3068\u3044\u3046\u4e8b\u3067\u3042\u308b\u3002<br \/>\n\u306a\u305c\u3053\u3093\u306a\u3053\u3068\u3092\u3059\u308b\u306e\u304b\uff1f<br \/>\n\u305d\u306e\u4e3b\u306a\u7406\u7531\u306f\u3001\u4f8b\u3048\u3070&#8221;4 + 5&#8243;\u3068\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u306b\u5165\u529b\u3057\u305f\u5834\u5408\u3001\u5165\u529b\u304c\u5b8c\u4e86\u3057\u305f\u306e\u304b\u305d\u3046\u3067\u306a\u3044\u306e\u304b\u69cb\u6587\u89e3\u6790\u5668\u306f\u77e5\u308b\u3053\u3068\u304c\u51fa\u6765\u306a\u3044\u304b\u3089\u3067\u3042\u308b\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u5f0f\u306e\u7d42\u308f\u308a\u304c&#8221;4 + 5&#8243;\u306e\u5834\u5408\u3001\u305d\u306e\u5f8c\u306b&#8221;def foo\u2026&#8221;\u3068\u66f8\u304f\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<br \/>\n\u3082\u3057\u304f\u306f\u3001&#8221;4 + 5&#8243;\u306e\u5f8c\u306b&#8221;* 6&#8243;\u3068\u5f0f\u3092\u7d9a\u3051\u308b\u3053\u3068\u3082\u51fa\u6765\u308b\u3002<br \/>\n\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u3067\u30bb\u30df\u30b3\u30ed\u30f3\u304c\u4f7f\u3048\u308c\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u306f&#8221;4 + 5;&#8221;\u3068\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u3001\u69cb\u6587\u89e3\u6790\u5668\u306f\u305d\u3053\u3067\u5f0f\u304c\u7d42\u4e86\u3057\u3066\u308b\u3053\u3068\u3092\u77e5\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<br \/>\n<em>\u8a33\u6ce8: \u3061\u3087\u3063\u3068\u3053\u3053\u5206\u304b\u308a\u3065\u3089\u3044\u3068\u601d\u3046\u306e\u3067\u88dc\u8db3\u3002<br \/>\n\u69cb\u6587\u89e3\u6790\u5668\u304c\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u7121\u8996\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306b\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u66f8\u3044\u3066\u3082\u826f\u3044\u3068\u3044\u3046\u4e8b\u306b\u306a\u308b\u3002<br \/>\n\u5b57\u53e5\u89e3\u6790\u5668\u3067\u306fisspace\u95a2\u6570\u306b\u3088\u3063\u3066\u7a7a\u767d\u6587\u5b57\uff08\u6539\u884c\u3092\u542b\u3080\uff09\u304c\u7121\u8996\u3055\u308c\u308b\uff08\u666e\u901a\u306e\u7a7a\u767d\u3068\u540c\u3058\u6271\u3044\uff09\u306e\u3067\u3001\u6539\u884c\u306b\u3088\u3063\u3066\u5f0f\u306e\u7d42\u308f\u308a\u3092\u7279\u5b9a\u51fa\u6765\u306a\u3044\u3002<br \/>\n\u4e07\u83ef\u93e1\u3067\u306f\u3001\u5f0f\u306e\u5f8c\u306b\u95a2\u6570\u5b9a\u7fa9\u7b49\u304c\u7d9a\u304f\u5834\u5408\u3001\u5f0f\u306e\u884c\u672b\u306e\u30bb\u30df\u30b3\u30ed\u30f3\u306f\u5fc5\u9808\u3067\u306f\u306a\u3044\u304c\u3001\u30bb\u30df\u30b3\u30ed\u30f3\u3092\u4f7f\u3046\u3053\u3068\u306b\u3088\u3063\u3066\u5f0f\u306e\u7d42\u308f\u308a\u3092\u660e\u793a\u7684\u306b\u30b3\u30f3\u30d1\u30a4\u30e9\u306b\u4f1d\u3048\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/em><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[466,467],"class_list":["post-2914","post","type-post","status-publish","format-standard","hentry","category-tech","tag-kaleidoscope","tag-llvm"],"_links":{"self":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/2914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/comments?post=2914"}],"version-history":[{"count":0,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/2914\/revisions"}],"wp:attachment":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media?parent=2914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/categories?post=2914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/tags?post=2914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}