{"id":2971,"date":"2013-08-29T12:15:52","date_gmt":"2013-08-29T03:15:52","guid":{"rendered":"http:\/\/peta.okechan.net\/blog\/?p=2971"},"modified":"2013-08-29T12:15:52","modified_gmt":"2013-08-29T03:15:52","slug":"5-2-3-ifthenelse%e3%81%ae%e3%81%9f%e3%82%81%e3%81%ae%e6%a7%8b%e6%96%87%e8%a7%a3%e6%9e%90%e5%99%a8%e6%8b%a1%e5%bc%b5","status":"publish","type":"post","link":"https:\/\/peta.okechan.net\/blog\/archives\/2971","title":{"rendered":"5.2.3. if\/then\/else\u306e\u305f\u3081\u306e\u69cb\u6587\u89e3\u6790\u5668\u62e1\u5f35"},"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\u7b2c5\u7ae0 \u4e07\u83ef\u93e1: \u8a00\u8a9e\u306e\u62e1\u5f35: \u5236\u5fa1\u30d5\u30ed\u30fc<br \/>\n<a href=\"http:\/\/llvm.org\/docs\/tutorial\/LangImpl05.html#parser-extensions-for-if-then-else\" target=\"_blank\">\u7b2c2.3\u7bc0 if\/then\/else\u306e\u305f\u3081\u306e\u69cb\u6587\u89e3\u6790\u5668\u62e1\u5f35<\/a><\/p>\n<p>if\/then\/else\u95a2\u9023\u306e\u30c8\u30fc\u30af\u30f3\u306f\u5b57\u53e5\u89e3\u6790\u5668\u304b\u3089\u3082\u305f\u3089\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u305d\u306e\u305f\u3081\u306eAST\u30ce\u30fc\u30c9\u3082\u3059\u3067\u306b\u3042\u308b\u306e\u3067\u3001\u69cb\u6587\u89e3\u6790\u306e\u30ed\u30b8\u30c3\u30af\u306f\u6bd4\u8f03\u7684\u5358\u7d14\u3067\u3042\u308b\u3002<br \/>\n\u307e\u305a\u3001\u65b0\u3057\u3044\u69cb\u6587\u89e3\u6790\u95a2\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/\/ ifexpr ::= 'if' expression 'then' expression 'else' expression\r\nstatic ExprAST *ParseIfExpr() {\r\n  getNextToken();  \/\/ &quot;if&quot;\u3092\u6d88\u5316\u3059\u308b\u3002\r\n\r\n  \/\/ \u6761\u4ef6\u3002\r\n  ExprAST *Cond = ParseExpression();\r\n  if (!Cond) return 0;\r\n\r\n  if (CurTok != tok_then)\r\n    return Error(&quot;expected then&quot;);\r\n  getNextToken();  \/\/ &quot;then&quot;\u3092\u6d88\u5316\u3059\u308b\u3002\r\n\r\n  ExprAST *Then = ParseExpression();\r\n  if (Then == 0) return 0;\r\n\r\n  if (CurTok != tok_else)\r\n    return Error(&quot;expected else&quot;);\r\n\r\n  getNextToken();\r\n\r\n  ExprAST *Else = ParseExpression();\r\n  if (!Else) return 0;\r\n\r\n  return new IfExprAST(Cond, Then, Else);\r\n}<\/pre>\n<p>\u6b21\u306f\u3001\u30d7\u30e9\u30a4\u30de\u30ea\u5f0f\u306e\u89e3\u6790\u306e\u3068\u3053\u308d\u304b\u3089\u547c\u3073\u51fa\u3059\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">static ExprAST *ParsePrimary() {\r\n  switch (CurTok) {\r\n  default: return Error(&quot;unknown token when expecting an expression&quot;);\r\n  case tok_identifier: return ParseIdentifierExpr();\r\n  case tok_number:     return ParseNumberExpr();\r\n  case '(':            return ParseParenExpr();\r\n  case tok_if:         return ParseIfExpr();\r\n  }\r\n}<\/pre>\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\u7b2c5\u7ae0 \u4e07\u83ef\u93e1: \u8a00\u8a9e\u306e\u62e1\u5f35: \u5236\u5fa1\u30d5\u30ed\u30fc<br \/>\n<a href=\"http:\/\/llvm.org\/docs\/tutorial\/LangImpl05.html#parser-extensions-for-if-then-else\" target=\"_blank\">\u7b2c2.3\u7bc0 if\/then\/else\u306e\u305f\u3081\u306e\u69cb\u6587\u89e3\u6790\u5668\u62e1\u5f35<\/a><\/p>\n<p>if\/then\/else\u95a2\u9023\u306e\u30c8\u30fc\u30af\u30f3\u306f\u5b57\u53e5\u89e3\u6790\u5668\u304b\u3089\u3082\u305f\u3089\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u305d\u306e\u305f\u3081\u306eAST\u30ce\u30fc\u30c9\u3082\u3059\u3067\u306b\u3042\u308b\u306e\u3067\u3001\u69cb\u6587\u89e3\u6790\u306e\u30ed\u30b8\u30c3\u30af\u306f\u6bd4\u8f03\u7684\u5358\u7d14\u3067\u3042\u308b\u3002<br \/>\n\u307e\u305a\u3001\u65b0\u3057\u3044\u69cb\u6587\u89e3\u6790\u95a2\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/\/ ifexpr ::= 'if' expression 'then' expression 'else' expression\r\nstatic ExprAST *ParseIfExpr() {\r\n  getNextToken();  \/\/ &quot;if&quot;\u3092\u6d88\u5316\u3059\u308b\u3002\r\n\r\n  \/\/ \u6761\u4ef6\u3002\r\n  ExprAST *Cond = ParseExpression();\r\n  if (!Cond) return 0;\r\n\r\n  if (CurTok != tok_then)\r\n    return Error(&quot;expected then&quot;);\r\n  getNextToken();  \/\/ &quot;then&quot;\u3092\u6d88\u5316\u3059\u308b\u3002\r\n\r\n  ExprAST *Then = ParseExpression();\r\n  if (Then == 0) return 0;\r\n\r\n  if (CurTok != tok_else)\r\n    return Error(&quot;expected else&quot;);\r\n\r\n  getNextToken();\r\n\r\n  ExprAST *Else = ParseExpression();\r\n  if (!Else) return 0;\r\n\r\n  return new IfExprAST(Cond, Then, Else);\r\n}<\/pre>\n<p>\u6b21\u306f\u3001\u30d7\u30e9\u30a4\u30de\u30ea\u5f0f\u306e\u89e3\u6790\u306e\u3068\u3053\u308d\u304b\u3089\u547c\u3073\u51fa\u3059\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">static ExprAST *ParsePrimary() {\r\n  switch (CurTok) {\r\n  default: return Error(&quot;unknown token when expecting an expression&quot;);\r\n  case tok_identifier: return ParseIdentifierExpr();\r\n  case tok_number:     return ParseNumberExpr();\r\n  case '(':            return ParseParenExpr();\r\n  case tok_if:         return ParseIfExpr();\r\n  }\r\n}<\/pre>\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-2971","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\/2971","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=2971"}],"version-history":[{"count":0,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/2971\/revisions"}],"wp:attachment":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media?parent=2971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/categories?post=2971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/tags?post=2971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}