{"id":3131,"date":"2022-06-24T22:09:44","date_gmt":"2022-06-24T19:09:44","guid":{"rendered":"https:\/\/demensdeum.com\/blog\/?p=3131"},"modified":"2024-12-16T22:32:20","modified_gmt":"2024-12-16T19:32:20","slug":"pattern-interpreter","status":"publish","type":"post","link":"https:\/\/demensdeum.com\/blog\/ja\/2022\/06\/24\/pattern-interpreter\/","title":{"rendered":"\u30d1\u30bf\u30fc\u30f3\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc"},"content":{"rendered":"<h3>\u542b\u307e\u308c\u308b\u3082\u306e<\/h3>\n<p>\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc \u30d1\u30bf\u30fc\u30f3\u306f\u3001\u52d5\u4f5c\u30c7\u30b6\u30a4\u30f3 \u30d1\u30bf\u30fc\u30f3\u3092\u6307\u3057\u307e\u3059\u3002\u3053\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001AST \u30c4\u30ea\u30fc\u3092\u64cd\u4f5c\u3057\u3066\u72ec\u81ea\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002AST \u30c4\u30ea\u30fc\u306e\u9802\u70b9\u306f\u3001\u8a00\u8a9e\u306e\u6a5f\u80fd\u3092\u63d0\u4f9b\u3059\u308b Interpret \u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u7d42\u7aef\u5f0f\u3068\u975e\u7d42\u7aef\u5f0f\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u7d42\u7aef\u5f0f &#8211; \u4f8b: \u6587\u5b57\u5217\u5b9a\u6570 &#8211; \u300cHello World\u300d<\/li>\n<li>\u975e\u7d42\u7aef\u5f0f &#8211; \u305f\u3068\u3048\u3070\u3001Print(&#8220;Hello World&#8221;) \u306b\u306f\u3001Print \u3068\u7d42\u7aef\u5f0f &#8220;Hello World&#8221; \u304b\u3089\u306e\u5f15\u6570\u304c\u542b\u307e\u308c\u307e\u3059<\/li>\n<\/ul>\n<p>\u9055\u3044\u306f\u4f55\u3067\u3059\u304b?\u9055\u3044\u306f\u3001\u89e3\u91c8\u306f\u7d42\u7aef\u5f0f\u3067\u7d42\u4e86\u3057\u307e\u3059\u304c\u3001\u975e\u7d42\u7aef\u5f0f\u306e\u5834\u5408\u306f\u3001\u5165\u529b\u3055\u308c\u308b\u3059\u3079\u3066\u306e\u9802\u70b9\/\u5f15\u6570\u306b\u308f\u305f\u3063\u3066\u6df1\u304f\u7d99\u7d9a\u3055\u308c\u308b\u3053\u3068\u3067\u3059\u3002 AST \u30c4\u30ea\u30fc\u304c\u975e\u7d42\u7aef\u5f0f\u306e\u307f\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u6c7a\u3057\u3066\u5b8c\u4e86\u3057\u307e\u305b\u3093\u3002\u3069\u306e\u30d7\u30ed\u30bb\u30b9\u306b\u3082\u7279\u5b9a\u306e\u6709\u9650\u6027\u304c\u5fc5\u8981\u3067\u3059\u3002\u3053\u306e\u6709\u9650\u6027\u304c\u7d42\u7aef\u5f0f\u306e\u6b63\u4f53\u3067\u3042\u308a\u3001\u901a\u5e38\u3001\u7d42\u7aef\u5f0f\u306b\u306f\u6587\u5b57\u5217\u306a\u3069\u306e\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u307e\u3059\u3002<\/p>\n<p>AST \u30c4\u30ea\u30fc\u306e\u4f8b\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3143\" src=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2022\/06\/ast.png\" alt=\"\" width=\"512\" height=\"578\" srcset=\"https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2022\/06\/ast.png 512w, https:\/\/demensdeum.com\/blog\/wp-content\/uploads\/2022\/06\/ast-266x300.png 266w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><br \/>\nDcoetzee\u3001CC0\u3001\u30a6\u30a3\u30ad\u30e1\u30c7\u30a3\u30a2 \u30b3\u30e2\u30f3\u30ba\u7d4c\u7531<\/p>\n<p>\u3054\u89a7\u306e\u3068\u304a\u308a\u3001\u7d42\u7aef\u5f0f\u306f\u5b9a\u6570\u3068\u5909\u6570\u3067\u3042\u308a\u3001\u6b8b\u308a\u306f\u975e\u7d42\u7aef\u5f0f\u3067\u3059\u3002<\/p>\n<h3>\u542b\u307e\u308c\u306a\u3044\u3082\u306e<\/h3>\n<p>\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u306e\u5b9f\u88c5\u306b\u306f\u3001AST \u30c4\u30ea\u30fc\u306b\u5165\u529b\u3055\u308c\u305f\u8a00\u8a9e\u6587\u5b57\u5217\u306e\u89e3\u6790\u306f\u542b\u307e\u308c\u307e\u305b\u3093\u3002\u7d42\u7aef\u5f0f\u3068\u975e\u7d42\u7aef\u5f0f\u306e\u30af\u30e9\u30b9\u3092\u5b9f\u88c5\u3057\u3001\u5165\u529b\u3067 Context \u5f15\u6570\u3092\u4f7f\u7528\u3057\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u89e3\u91c8\u3057\u3001\u5f0f\u306e AST \u30c4\u30ea\u30fc\u3092\u4f5c\u6210\u3057\u3001\u30eb\u30fc\u30c8\u5f0f\u3067 Interpret \u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067\u5341\u5206\u3067\u3059\u3002\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001\u5b9f\u884c\u6642\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u72b6\u614b\u3092\u4fdd\u5b58\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u5b9f\u88c5<\/h3>\n<p>\u30d1\u30bf\u30fc\u30f3\u306b\u306f\u4ee5\u4e0b\u304c\u542b\u307e\u308c\u307e\u3059:<\/p>\n<ul>\n<li>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8 \u2013 AST \u30c4\u30ea\u30fc\u3092\u8fd4\u3057\u3001\u30eb\u30fc\u30c8 \u30ce\u30fc\u30c9 (\u30af\u30e9\u30a4\u30a2\u30f3\u30c8) \u306b\u5bfe\u3057\u3066 Interpret(context) \u3092\u5b9f\u884c\u3057\u307e\u3059<\/li>\n<li>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8 \u2013 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u72b6\u614b\u304c\u542b\u307e\u308c\u3066\u304a\u308a\u3001\u89e3\u91c8\u6642\u306b\u5f0f\u306b\u6e21\u3055\u308c\u307e\u3059 (\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8)<\/li>\n<li>\u62bd\u8c61\u5f0f \u2013 Interpret(context) (Expression) \u30e1\u30bd\u30c3\u30c9\u3092\u542b\u3080\u62bd\u8c61\u30af\u30e9\u30b9<\/li>\n<li>\u30bf\u30fc\u30df\u30ca\u30eb\u5f0f\u306f\u6700\u7d42\u5f0f\u3067\u3042\u200b\u200b\u308a\u3001\u62bd\u8c61\u5f0f (\u30bf\u30fc\u30df\u30ca\u30eb\u5f0f) \u306e\u5b50\u5b6b\u3067\u3059<\/li>\n<li>\u975e\u7d42\u7aef\u5f0f\u306f\u6709\u9650\u5f0f\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3053\u308c\u306b\u306f AST \u30c4\u30ea\u30fc\u306e\u6df1\u90e8\u306b\u3042\u308b\u9802\u70b9\u3078\u306e\u30dd\u30a4\u30f3\u30bf\u304c\u542b\u307e\u308c\u307e\u3059\u3002\u901a\u5e38\u3001\u975e\u7d42\u7aef\u5f0f\uff08NonterminalExpression\uff09\u306e\u89e3\u91c8\u306e\u7d50\u679c\u306b\u5f71\u97ff\u3057\u307e\u3059\u3002<\/ul>\n<p>C# \u3067\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u4f8b<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-unknown\" data-lang=\"unknown\"><code>        static void Main(string[] args)\n        {\n            var context = new Context();\n            var initialProgram = new PerformExpression(\n                new IExpression[] {\n                    new SetExpression(\"alpha\", \"1\"),\n                    new GetExpression(\"alpha\"),\n                    new PrintExpression(\n                        new IExpression[] {\n                            new ConstantExpression(\"Hello Interpreter Pattern\")\n                        }\n                    )\n                }\n            );\n            System.Console.WriteLine(initialProgram.interpret(context));\n        }\n}\n<\/code><\/pre>\n<\/div>\n<p>C# \u3067\u306e\u62bd\u8c61\u5f0f\u306e\u4f8b<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-unknown\" data-lang=\"unknown\"><code>{\n    String interpret(Context context);\n}\n<\/code><\/pre>\n<\/div>\n<p>C# \u306e\u30bf\u30fc\u30df\u30ca\u30eb\u5f0f\u306e\u4f8b (\u6587\u5b57\u5217\u5b9a\u6570)<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-unknown\" data-lang=\"unknown\"><code>{\n    private String constant;\n\n    public ConstantExpression(String constant) {\n        this.constant = constant;\n    }\n\n    override public String interpret(Context context) {\n        return constant;\n    }\n}\n<\/code><\/pre>\n<\/div>\n<p>C# \u306e\u975e\u7d42\u7aef\u5f0f\u306e\u4f8b (\u533a\u5207\u308a\u6587\u5b57\u300c;\u300d\u3092\u4f7f\u7528\u3057\u3066\u3001\u4e0b\u4f4d\u9802\u70b9\u306e\u7d50\u679c\u3092\u958b\u59cb\u3057\u3066\u9023\u7d50\u3059\u308b)<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-unknown\" data-lang=\"unknown\"><code>{\n    public PerformExpression(IExpression[] leafs) : base(leafs) {\n        this.leafs = leafs;\n    }\n    \n    override public String interpret(Context context) {\n        var output = \"\";\n        foreach (var leaf in leafs) {\n            output += leaf.interpret(context) + \";\";\n        }\n        return output;\n    }\n}\n<\/code><\/pre>\n<\/div>\n<h3>\u6a5f\u80fd\u7684\u306b\u5b9f\u884c\u3067\u304d\u307e\u3059\u304b?<\/h3>\n<p>\u77e5\u3089\u308c\u3066\u3044\u308b\u3088\u3046\u306b\u3001\u3059\u3079\u3066\u306e\u30c1\u30e5\u30fc\u30ea\u30f3\u30b0\u5b8c\u5168\u8a00\u8a9e\u306f\u540c\u7b49\u3067\u3059\u3002\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u30d1\u30bf\u30fc\u30f3\u3092\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306b\u79fb\u690d\u3059\u308b\u3053\u3068\u306f\u53ef\u80fd\u3067\u3059\u304b?<\/p>\n<p>\u5b9f\u9a13\u3068\u3057\u3066\u3001Elm \u3068\u3044\u3046 Web \u7528\u306e FP \u8a00\u8a9e\u3092\u53d6\u308a\u4e0a\u3052\u3066\u307f\u307e\u3057\u3087\u3046\u3002 Elm \u306b\u306f\u30af\u30e9\u30b9\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u30ec\u30b3\u30fc\u30c9\u3068\u30bf\u30a4\u30d7\u304c\u3042\u308b\u305f\u3081\u3001\u6b21\u306e\u30ec\u30b3\u30fc\u30c9\u3068\u30bf\u30a4\u30d7\u304c\u5b9f\u88c5\u306b\u95a2\u4fc2\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u5f0f \u2013 \u8003\u3048\u3089\u308c\u308b\u3059\u3079\u3066\u306e\u8a00\u8a9e\u5f0f\u306e\u30ea\u30b9\u30c8 (\u5f0f)<\/li>\n<li>\u5f93\u5c5e\u5f0f \u2013 \u975e\u7d42\u7aef\u5f0f (ExpressionLeaf) \u306b\u5f93\u5c5e\u3059\u308b\u5f0f<\/li>\n<li>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8 \u2013 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u72b6\u614b (\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8) \u3092\u4fdd\u5b58\u3059\u308b\u30ec\u30b3\u30fc\u30c9<\/li>\n<li>Interpret(context) \u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u95a2\u6570 &#8211; \u30bf\u30fc\u30df\u30ca\u30eb\u5f0f\u3068\u975e\u30bf\u30fc\u30df\u30ca\u30eb\u5f0f\u306e\u6a5f\u80fd\u3092\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u306a\u3059\u3079\u3066\u306e\u95a2\u6570<\/li>\n<li>\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc\u306e\u72b6\u614b\u306e\u88dc\u52a9\u30ec\u30b3\u30fc\u30c9 &#8211; \u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc\u306e\u6b63\u3057\u3044\u52d5\u4f5c\u306b\u5fc5\u8981\u3067\u3001\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc\u306e\u72b6\u614b\u3068\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u4fdd\u5b58\u3057\u307e\u3059<\/li>\n<\/ul>\n<p>Elm \u3067\u4f7f\u7528\u53ef\u80fd\u306a\u5f0f\u306e\u30bb\u30c3\u30c8\u5168\u4f53\u306e\u89e3\u91c8\u3092\u5b9f\u88c5\u3059\u308b\u95a2\u6570\u306e\u4f8b:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-unknown\" data-lang=\"unknown\"><code>  case input.expression of\n    Constant text -&gt;\n      { \n        output = text, \n        context = input.context \n      }\n    Perform leafs -&gt;\n      let inputs = List.map (\\leaf -&gt; { expressionLeaf = leaf, context = input.context } ) leafs in\n        let startLeaf = { expressionLeaf = (Node (Constant \"\")), context = { variables = Dict.empty } } in\n          let outputExpressionInput = List.foldl mergeContextsAndRunLeafs startLeaf inputs in\n            {\n              output = (runExpressionLeaf outputExpressionInput).output,\n              context = input.context\n            }\n    Print printExpression -&gt;\n      run \n      { \n        expression = printExpression, \n        context = input.context \n      }\n    Set key value -&gt;\n      let variables = Dict.insert key value input.context.variables in\n      {\n        output = \"OK\",\n        context = { variables = variables }\n      }\n    Get key -&gt;\n      {\n        output = Maybe.withDefault (\"No value for key: \" ++ key) (Dict.get key input.context.variables),\n        context = input.context\n      }\n<\/code><\/pre>\n<\/div>\n<h3>\u89e3\u6790\u306b\u3064\u3044\u3066\u306f\u3069\u3046\u3067\u3059\u304b?<\/h3>\n<p>\u30bd\u30fc\u30b9 \u30b3\u30fc\u30c9\u3092 AST \u30c4\u30ea\u30fc\u306b\u89e3\u6790\u3059\u308b\u3053\u3068\u306f\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc \u30d1\u30bf\u30fc\u30f3\u306b\u306f\u542b\u307e\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u30bd\u30fc\u30b9 \u30b3\u30fc\u30c9\u3092\u89e3\u6790\u3059\u308b\u306b\u306f\u3044\u304f\u3064\u304b\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u308c\u306b\u3064\u3044\u3066\u306f\u307e\u305f\u5225\u306e\u6a5f\u4f1a\u306b\u8aac\u660e\u3057\u307e\u3059\u3002<br \/>Elm \u306e\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u306e\u5b9f\u88c5\u3067\u306f\u3001\u9802\u70b9\u306e\u89e3\u6790\u3068\u4e0b\u4f4d\u9802\u70b9\u306e\u89e3\u6790\u3068\u3044\u3046 2 \u3064\u306e\u95a2\u6570\u3067\u69cb\u6210\u3055\u308c\u308b\u5358\u7d14\u306a\u30d1\u30fc\u30b5\u30fc\u3092 AST \u30c4\u30ea\u30fc\u306b\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-unknown\" data-lang=\"unknown\"><code>parseLeafs state =\n    let tokensQueue = state.tokensQueue in\n        let popped = pop state.tokensQueue in\n            let tokensQueueTail = tail state.tokensQueue in\n                if popped == \"Nothing\" then\n                    state\n                else if popped == \"Perform(\" then\n                    {\n                        tokensQueue = tokensQueue,\n                        result = (state.result ++ [Node (parse tokensQueue)])\n                    }\n                else if popped == \")\" then\n                    parseLeafs {\n                        tokensQueue = tokensQueueTail,\n                        result = state.result\n                    }\n                else if popped == \"Set\" then\n                    let key = pop tokensQueueTail in\n                        let value = pop (tail tokensQueueTail) in\n                            parseLeafs {\n                                tokensQueue = tail (tail tokensQueueTail),\n                                result = (state.result ++ [Node (Set key value)])\n                            }\n                else if popped == \"Get\" then\n                    let key = pop tokensQueueTail in\n                        parseLeafs {\n                            tokensQueue = tail tokensQueueTail,\n                            result = (state.result ++ [Node (Get key)])\n                        }\n                else \n                    parseLeafs {\n                        tokensQueue = tokensQueueTail,\n                        result = (state.result ++ [Node (Constant popped)])\n                    }\n\nparse tokensQueue =\n    let popped = pop tokensQueue in\n        let tokensQueueTail = tail tokensQueue in\n            if popped == \"Perform(\" then\n                Perform (\n                    parseLeafs {\n                        tokensQueue = tokensQueueTail, \n                        result = []\n                    }\n                ).result\n            else if popped == \"Set\" then\n                let key = pop tokensQueueTail in\n                    let value = pop (tail tokensQueueTail) in\n                        Set key value\n            else if popped == \"Print\" then\n                Print (parse tokensQueueTail)\n            else\n                Constant popped\n<\/code><\/pre>\n<\/div>\n<h3>\u30ea\u30f3\u30af<\/h3>\n<p><a href=\"https:\/\/gitlab.com\/demensdeum\/patterns\/-\/tree\/master\/interpreter\/elm\" target=\"_blank\" rel=\"noopener\">https:\/\/gitlab.com\/demensdeum \/patterns\/-\/tree\/master\/interpreter\/elm<\/a><br \/><a href=\"https:\/\/gitlab.com\/demensdeum\/patterns\/-\/tree\/master\/interpreter\/csharp\" target=\"_blank\" rel=\"noopener\">https:\/\/gitlab.com\/demensdeum\/patterns\/-\/tree\/master\/interpreter\/csharp<\/a><\/p>\n<h3>\u30bd\u30fc\u30b9<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Interpreter_pattern\" target=\"_blank\" rel=\"noopener\">https:\/\/en.wikipedia.org\/wiki\/Interpreter_pattern<\/a> <br \/><a href=\"https:\/\/elm-lang.org\/\" target=\"_blank\" rel=\"noopener\">https:\/\/elm-lang.org\/<\/a><br \/>\n<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u542b\u307e\u308c\u308b\u3082\u306e \u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc \u30d1\u30bf\u30fc\u30f3\u306f\u3001\u52d5\u4f5c\u30c7\u30b6\u30a4\u30f3 \u30d1\u30bf\u30fc\u30f3\u3092\u6307\u3057\u307e\u3059\u3002\u3053\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001AST \u30c4\u30ea\u30fc\u3092\u64cd\u4f5c\u3057\u3066\u72ec\u81ea\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002AST \u30c4\u30ea\u30fc\u306e\u9802\u70b9\u306f\u3001\u8a00\u8a9e\u306e\u6a5f\u80fd\u3092\u63d0\u4f9b\u3059\u308b Interpret \u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u7d42\u7aef\u5f0f\u3068\u975e\u7d42\u7aef\u5f0f\u3067\u3059\u3002 \u7d42\u7aef\u5f0f &#8211; \u4f8b: \u6587\u5b57\u5217\u5b9a\u6570 &#8211; \u300cHello World\u300d \u975e\u7d42\u7aef\u5f0f &#8211; \u305f\u3068\u3048\u3070\u3001Print(&#8220;Hello World&#8221;) \u306b\u306f\u3001Print \u3068\u7d42\u7aef\u5f0f &#8220;Hello World&#8221; \u304b\u3089\u306e\u5f15\u6570\u304c\u542b\u307e\u308c\u307e\u3059 \u9055\u3044\u306f\u4f55\u3067\u3059\u304b?\u9055\u3044\u306f\u3001\u89e3\u91c8\u306f\u7d42\u7aef\u5f0f\u3067\u7d42\u4e86\u3057\u307e\u3059\u304c\u3001\u975e\u7d42\u7aef\u5f0f\u306e\u5834\u5408\u306f\u3001\u5165\u529b\u3055\u308c\u308b\u3059\u3079\u3066\u306e\u9802\u70b9\/\u5f15\u6570\u306b\u308f\u305f\u3063\u3066\u6df1\u304f\u7d99\u7d9a\u3055\u308c\u308b\u3053\u3068\u3067\u3059\u3002 AST \u30c4\u30ea\u30fc\u304c\u975e\u7d42\u7aef\u5f0f\u306e\u307f\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u6c7a\u3057\u3066\u5b8c\u4e86\u3057\u307e\u305b\u3093\u3002\u3069\u306e\u30d7\u30ed\u30bb\u30b9\u306b\u3082\u7279\u5b9a\u306e\u6709\u9650\u6027\u304c\u5fc5\u8981\u3067\u3059\u3002\u3053\u306e\u6709\u9650\u6027\u304c\u7d42\u7aef\u5f0f\u306e\u6b63\u4f53\u3067\u3042\u308a\u3001\u901a\u5e38\u3001\u7d42\u7aef\u5f0f\u306b\u306f\u6587\u5b57\u5217\u306a\u3069\u306e\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u307e\u3059\u3002 AST \u30c4\u30ea\u30fc\u306e\u4f8b\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\u3002 Dcoetzee\u3001CC0\u3001\u30a6\u30a3\u30ad\u30e1\u30c7\u30a3\u30a2 \u30b3\u30e2\u30f3\u30ba\u7d4c\u7531 \u3054\u89a7\u306e\u3068\u304a\u308a\u3001\u7d42\u7aef\u5f0f\u306f\u5b9a\u6570\u3068\u5909\u6570\u3067\u3042\u308a\u3001\u6b8b\u308a\u306f\u975e\u7d42\u7aef\u5f0f\u3067\u3059\u3002 \u542b\u307e\u308c\u306a\u3044\u3082\u306e \u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u306e\u5b9f\u88c5\u306b\u306f\u3001AST \u30c4\u30ea\u30fc\u306b\u5165\u529b\u3055\u308c\u305f\u8a00\u8a9e\u6587\u5b57\u5217\u306e\u89e3\u6790\u306f\u542b\u307e\u308c\u307e\u305b\u3093\u3002\u7d42\u7aef\u5f0f\u3068\u975e\u7d42\u7aef\u5f0f\u306e\u30af\u30e9\u30b9\u3092\u5b9f\u88c5\u3057\u3001\u5165\u529b\u3067 Context \u5f15\u6570\u3092\u4f7f\u7528\u3057\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u89e3\u91c8\u3057\u3001\u5f0f\u306e AST \u30c4\u30ea\u30fc\u3092\u4f5c\u6210\u3057\u3001\u30eb\u30fc\u30c8\u5f0f\u3067 Interpret \u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067\u5341\u5206\u3067\u3059\u3002\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001\u5b9f\u884c\u6642\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u72b6\u614b\u3092\u4fdd\u5b58\u3067\u304d\u307e\u3059\u3002 \u5b9f\u88c5 \u30d1\u30bf\u30fc\u30f3\u306b\u306f\u4ee5\u4e0b\u304c\u542b\u307e\u308c\u307e\u3059: \u30af\u30e9\u30a4\u30a2\u30f3\u30c8 \u2013 AST \u30c4\u30ea\u30fc\u3092\u8fd4\u3057\u3001\u30eb\u30fc\u30c8 \u30ce\u30fc\u30c9 (\u30af\u30e9\u30a4\u30a2\u30f3\u30c8) \u306b\u5bfe\u3057\u3066 Interpret(context) \u3092\u5b9f\u884c\u3057\u307e\u3059 \u30b3\u30f3\u30c6\u30ad\u30b9\u30c8 \u2013 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u72b6\u614b\u304c\u542b\u307e\u308c\u3066\u304a\u308a\u3001\u89e3\u91c8\u6642\u306b\u5f0f\u306b\u6e21\u3055\u308c\u307e\u3059<a class=\"more-link\" href=\"https:\/\/demensdeum.com\/blog\/ja\/2022\/06\/24\/pattern-interpreter\/\">Continue reading <span class=\"screen-reader-text\">&#8220;\u30d1\u30bf\u30fc\u30f3\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[61,52],"tags":[95],"class_list":["post-3131","post","type-post","status-publish","format-standard","hentry","category-techie","category-tutorials","tag-patterns","entry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"ja","enabled_languages":["en","ru","zh","de","fr","ja","pt","hi"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"ru":{"title":true,"content":true,"excerpt":false},"zh":{"title":true,"content":true,"excerpt":false},"de":{"title":true,"content":true,"excerpt":false},"fr":{"title":true,"content":true,"excerpt":false},"ja":{"title":true,"content":true,"excerpt":false},"pt":{"title":true,"content":true,"excerpt":false},"hi":{"title":false,"content":false,"excerpt":false}}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts\/3131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/comments?post=3131"}],"version-history":[{"count":15,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts\/3131\/revisions"}],"predecessor-version":[{"id":3886,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/posts\/3131\/revisions\/3886"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/media?parent=3131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/categories?post=3131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/ja\/wp-json\/wp\/v2\/tags?post=3131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}