{"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\/zh\/2022\/06\/24\/pattern-interpreter\/","title":{"rendered":"\u6a21\u5f0f\u89e3\u91ca\u5668"},"content":{"rendered":"<h3>\u5305\u542b\u4ec0\u4e48<\/h3>\n<p>\u89e3\u91ca\u5668\u6a21\u5f0f\u662f\u6307\u884c\u4e3a\u8bbe\u8ba1\u6a21\u5f0f\u3002\u6b64\u6a21\u5f0f\u5141\u8bb8\u60a8\u901a\u8fc7\u4f7f\u7528 AST \u6811\u6765\u5b9e\u73b0\u60a8\u81ea\u5df1\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u8be5\u6811\u7684\u9876\u70b9\u662f\u5b9e\u73b0 Interpret \u65b9\u6cd5\u7684\u7ec8\u7aef\u548c\u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f\uff0c\u8be5\u65b9\u6cd5\u63d0\u4f9b\u4e86\u8be5\u8bed\u8a00\u7684\u529f\u80fd\u3002<\/p>\n<ul>\n<li>\u7ec8\u7aef\u8868\u8fbe\u5f0f &#8211; \u4f8b\u5982\uff0c\u5b57\u7b26\u4e32\u5e38\u91cf &#8211; \u201c\u4f60\u597d\u4e16\u754c\u201d<\/li>\n<li>\u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f &#8211; \u4f8b\u5982 Print(\u201cHello World\u201d)\uff0c\u5305\u542b Print \u548c\u6765\u81ea\u7ec8\u7aef\u8868\u8fbe\u5f0f\u201cHello World\u201d\u7684\u53c2\u6570<\/li>\n<\/ul>\n<p>\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\uff0c\u89e3\u91ca\u5728\u7ec8\u7aef\u8868\u8fbe\u5f0f\u4e0a\u7ed3\u675f\uff0c\u4f46\u5bf9\u4e8e\u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f\uff0c\u5b83\u4f1a\u5728\u6240\u6709\u4f20\u5165\u7684\u9876\u70b9\/\u53c2\u6570\u4e0a\u7ee7\u7eed\u6df1\u5165\u3002\u5982\u679c AST \u6811\u4ec5\u7531\u975e\u7ec8\u7ed3\u7b26\u8868\u8fbe\u5f0f\u7ec4\u6210\uff0c\u90a3\u4e48\u5e94\u7528\u7a0b\u5e8f\u5c06\u6c38\u8fdc\u65e0\u6cd5\u5b8c\u6210\uff0c\u56e0\u4e3a\u4efb\u4f55\u8fc7\u7a0b\u90fd\u9700\u8981\u4e00\u5b9a\u7684\u6709\u9650\u6027\uff0c\u8fd9\u79cd\u6709\u9650\u6027\u5c31\u662f\u7ec8\u7aef\u8868\u8fbe\u5f0f\uff0c\u5b83\u4eec\u901a\u5e38\u5305\u542b\u6570\u636e\uff0c\u4f8b\u5982\u5b57\u7b26\u4e32\u3002<\/p>\n<p>AST \u6811\u7684\u793a\u4f8b\u5982\u4e0b\uff1a<\/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\uff0cCC0\uff0c\u6765\u81ea\u7ef4\u57fa\u5171\u4eab\u8d44\u6e90<\/p>\n<p>\u5982\u60a8\u6240\u89c1\uff0c\u7ec8\u7aef\u8868\u8fbe\u5f0f\u662f\u5e38\u91cf\u548c\u53d8\u91cf\uff0c\u5176\u4f59\u7684\u662f\u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f\u3002<\/p>\n<h3>\u4e0d\u5305\u62ec\u4ec0\u4e48<\/h3>\n<p>\u89e3\u91ca\u5668\u5b9e\u73b0\u4e0d\u5305\u62ec\u89e3\u6790\u8f93\u5165\u5230 AST \u6811\u4e2d\u7684\u8bed\u8a00\u5b57\u7b26\u4e32\u3002\u5b9e\u73b0\u7ec8\u7ed3\u7b26\u548c\u975e\u7ec8\u7ed3\u7b26\u8868\u8fbe\u5f0f\u7684\u7c7b\u3001\u5728\u8f93\u5165\u5904\u4f7f\u7528 Context \u53c2\u6570\u7684 Interpret \u65b9\u6cd5\u3001\u521b\u5efa\u8868\u8fbe\u5f0f\u7684 AST \u6811\u5e76\u5728\u6839\u8868\u8fbe\u5f0f\u5904\u8fd0\u884c Interpret \u65b9\u6cd5\u5c31\u8db3\u591f\u4e86\u3002\u4e0a\u4e0b\u6587\u53ef\u7528\u4e8e\u5728\u8fd0\u884c\u65f6\u5b58\u50a8\u5e94\u7528\u7a0b\u5e8f\u72b6\u6001\u3002<\/p>\n<h3>\u5b9e\u65bd<\/h3>\n<p>\u8be5\u6a21\u5f0f\u6d89\u53ca\uff1a<\/p>\n<ul>\n<li>Client \u2013 \u8fd4\u56de AST \u6811\u5e76\u4e3a\u6839\u8282\u70b9\uff08Client\uff09\u8fd0\u884c Interpret(context)<\/li>\n<li>\u4e0a\u4e0b\u6587 &#8211; \u5305\u542b\u5e94\u7528\u7a0b\u5e8f\u7684\u72b6\u6001\uff0c\u5728\u89e3\u91ca\u65f6\u4f20\u9012\u7ed9\u8868\u8fbe\u5f0f\uff08\u4e0a\u4e0b\u6587\uff09<\/li>\n<li>\u62bd\u8c61\u8868\u8fbe\u5f0f &#8211; \u5305\u542b Interpret(context) (Expression) \u65b9\u6cd5\u7684\u62bd\u8c61\u7c7b<\/li>\n<li>\u7ec8\u7aef\u8868\u8fbe\u5f0f\u662f\u6700\u7ec8\u8868\u8fbe\u5f0f\uff0c\u662f\u62bd\u8c61\u8868\u8fbe\u5f0f (TerminalExpression) \u7684\u540e\u4ee3<\/li>\n<li>\u975e\u7ec8\u7ed3\u8868\u8fbe\u5f0f\u4e0d\u662f\u6709\u9650\u8868\u8fbe\u5f0f\uff1b\u5b83\u5305\u542b\u6307\u5411 AST \u6811\u6df1\u5904\u9876\u70b9\u7684\u6307\u9488\uff1b\u4e0b\u7ea7\u9876\u70b9\u901a\u5e38\u4f1a\u5f71\u54cd\u975e\u7ec8\u7ed3\u8868\u8fbe\u5f0f (NonTerminalExpression) \u7684\u89e3\u91ca\u7ed3\u679c<\/li>\n<\/ul>\n<p>C# \u4e2d\u7684\u5ba2\u6237\u7aef\u793a\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# \u4e2d\u7684\u62bd\u8c61\u8868\u8fbe\u5f0f\u793a\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# \u4e2d\u7684\u7ec8\u7aef\u8868\u8fbe\u5f0f\u793a\u4f8b\uff08\u5b57\u7b26\u4e32\u5e38\u91cf\uff09<\/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# \u4e2d\u975e\u7ec8\u7ed3\u7b26\u8868\u8fbe\u5f0f\u7684\u793a\u4f8b\uff08\u4f7f\u7528\u5206\u9694\u7b26\u201c;\u201d\u5f00\u59cb\u5e76\u8fde\u63a5\u4ece\u5c5e\u9876\u70b9\u7684\u7ed3\u679c<\/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>\u4f60\u80fd\u4ece\u529f\u80fd\u4e0a\u505a\u5230\u8fd9\u4e00\u70b9\u5417\uff1f<\/h3>\n<p>\u4f17\u6240\u5468\u77e5\uff0c\u6240\u6709\u56fe\u7075\u5b8c\u5907\u7684\u8bed\u8a00\u90fd\u662f\u7b49\u4ef7\u7684\u3002\u662f\u5426\u53ef\u4ee5\u5c06\u9762\u5411\u5bf9\u8c61\u6a21\u5f0f\u8f6c\u79fb\u5230\u51fd\u6570\u5f0f\u7f16\u7a0b\u8bed\u8a00\uff1f<\/p>\n<p>\u4f5c\u4e3a\u5b9e\u9a8c\uff0c\u6211\u4eec\u91c7\u7528\u4e00\u79cd\u540d\u4e3a Elm \u7684 FP \u7f51\u7edc\u8bed\u8a00\u3002 Elm\u4e2d\u6ca1\u6709\u7c7b\uff0c\u4f46\u662f\u6709Records\u548cTypes\uff0c\u56e0\u6b64\u5b9e\u73b0\u4e2d\u6d89\u53ca\u5230\u4ee5\u4e0b\u8bb0\u5f55\u548c\u7c7b\u578b\uff1a<\/p>\n<ul>\n<li>\u8868\u8fbe\u5f0f &#8211; \u5217\u51fa\u6240\u6709\u53ef\u80fd\u7684\u8bed\u8a00\u8868\u8fbe\u5f0f\uff08Expression\uff09<\/li>\n<li>\u4ece\u5c5e\u8868\u8fbe\u5f0f \u2013 \u4ece\u5c5e\u4e8e\u975e\u7ec8\u7ed3\u7b26\u8868\u8fbe\u5f0f (ExpressionLeaf) \u7684\u8868\u8fbe\u5f0f<\/li>\n<li>Context \u2013 \u5b58\u50a8\u5e94\u7528\u7a0b\u5e8f\u72b6\u6001\u7684\u8bb0\u5f55\uff08Context\uff09<\/li>\n<li>\u5b9e\u73b0 Interpret(context) \u65b9\u6cd5\u7684\u51fd\u6570 &#8211; \u5b9e\u73b0\u7ec8\u7aef\u548c\u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f\u529f\u80fd\u7684\u6240\u6709\u5fc5\u8981\u51fd\u6570<\/li>\n<li>\u89e3\u91ca\u5668\u72b6\u6001\u7684\u8f85\u52a9\u8bb0\u5f55 &#8211; \u89e3\u91ca\u5668\u6b63\u786e\u64cd\u4f5c\u6240\u5fc5\u9700\u7684\uff0c\u5b83\u4eec\u5b58\u50a8\u89e3\u91ca\u5668\u72b6\u6001\u3001\u4e0a\u4e0b\u6587<\/li>\n<\/ul>\n<p>\u5728 Elm \u4e2d\u5b9e\u73b0\u5bf9\u6574\u4e2a\u53ef\u80fd\u8868\u8fbe\u5f0f\u96c6\u7684\u89e3\u91ca\u7684\u51fd\u6570\u793a\u4f8b\uff1a<\/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\u600e\u4e48\u6837\uff1f<\/h3>\n<p>\u89e3\u91ca\u5668\u6a21\u5f0f\u4e2d\u4e0d\u5305\u542b\u5c06\u6e90\u4ee3\u7801\u89e3\u6790\u4e3a AST \u6811\uff1b\u6709\u591a\u79cd\u89e3\u6790\u6e90\u4ee3\u7801\u7684\u65b9\u6cd5\uff0c\u7a0d\u540e\u4f1a\u8be6\u7ec6\u4ecb\u7ecd\u3002<br \/>\u5728Elm\u89e3\u91ca\u5668\u7684\u5b9e\u73b0\u4e2d\uff0c\u6211\u5728AST\u6811\u4e2d\u7f16\u5199\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u89e3\u6790\u5668\uff0c\u7531\u4e24\u4e2a\u51fd\u6570\u7ec4\u6210\u2014\u2014\u89e3\u6790\u9876\u70b9\uff0c\u89e3\u6790\u4ece\u5c5e\u9876\u70b9\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>\u94fe\u63a5<\/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>\u6765\u6e90<\/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>\u5305\u542b\u4ec0\u4e48 \u89e3\u91ca\u5668\u6a21\u5f0f\u662f\u6307\u884c\u4e3a\u8bbe\u8ba1\u6a21\u5f0f\u3002\u6b64\u6a21\u5f0f\u5141\u8bb8\u60a8\u901a\u8fc7\u4f7f\u7528 AST \u6811\u6765\u5b9e\u73b0\u60a8\u81ea\u5df1\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u8be5\u6811\u7684\u9876\u70b9\u662f\u5b9e\u73b0 Interpret \u65b9\u6cd5\u7684\u7ec8\u7aef\u548c\u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f\uff0c\u8be5\u65b9\u6cd5\u63d0\u4f9b\u4e86\u8be5\u8bed\u8a00\u7684\u529f\u80fd\u3002 \u7ec8\u7aef\u8868\u8fbe\u5f0f &#8211; \u4f8b\u5982\uff0c\u5b57\u7b26\u4e32\u5e38\u91cf &#8211; \u201c\u4f60\u597d\u4e16\u754c\u201d \u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f &#8211; \u4f8b\u5982 Print(\u201cHello World\u201d)\uff0c\u5305\u542b Print \u548c\u6765\u81ea\u7ec8\u7aef\u8868\u8fbe\u5f0f\u201cHello World\u201d\u7684\u53c2\u6570 \u6709\u4ec0\u4e48\u533a\u522b\uff1f\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\uff0c\u89e3\u91ca\u5728\u7ec8\u7aef\u8868\u8fbe\u5f0f\u4e0a\u7ed3\u675f\uff0c\u4f46\u5bf9\u4e8e\u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f\uff0c\u5b83\u4f1a\u5728\u6240\u6709\u4f20\u5165\u7684\u9876\u70b9\/\u53c2\u6570\u4e0a\u7ee7\u7eed\u6df1\u5165\u3002\u5982\u679c AST \u6811\u4ec5\u7531\u975e\u7ec8\u7ed3\u7b26\u8868\u8fbe\u5f0f\u7ec4\u6210\uff0c\u90a3\u4e48\u5e94\u7528\u7a0b\u5e8f\u5c06\u6c38\u8fdc\u65e0\u6cd5\u5b8c\u6210\uff0c\u56e0\u4e3a\u4efb\u4f55\u8fc7\u7a0b\u90fd\u9700\u8981\u4e00\u5b9a\u7684\u6709\u9650\u6027\uff0c\u8fd9\u79cd\u6709\u9650\u6027\u5c31\u662f\u7ec8\u7aef\u8868\u8fbe\u5f0f\uff0c\u5b83\u4eec\u901a\u5e38\u5305\u542b\u6570\u636e\uff0c\u4f8b\u5982\u5b57\u7b26\u4e32\u3002 AST \u6811\u7684\u793a\u4f8b\u5982\u4e0b\uff1a Dcoetzee\uff0cCC0\uff0c\u6765\u81ea\u7ef4\u57fa\u5171\u4eab\u8d44\u6e90 \u5982\u60a8\u6240\u89c1\uff0c\u7ec8\u7aef\u8868\u8fbe\u5f0f\u662f\u5e38\u91cf\u548c\u53d8\u91cf\uff0c\u5176\u4f59\u7684\u662f\u975e\u7ec8\u7aef\u8868\u8fbe\u5f0f\u3002 \u4e0d\u5305\u62ec\u4ec0\u4e48 \u89e3\u91ca\u5668\u5b9e\u73b0\u4e0d\u5305\u62ec\u89e3\u6790\u8f93\u5165\u5230 AST \u6811\u4e2d\u7684\u8bed\u8a00\u5b57\u7b26\u4e32\u3002\u5b9e\u73b0\u7ec8\u7ed3\u7b26\u548c\u975e\u7ec8\u7ed3\u7b26\u8868\u8fbe\u5f0f\u7684\u7c7b\u3001\u5728\u8f93\u5165\u5904\u4f7f\u7528 Context \u53c2\u6570\u7684 Interpret \u65b9\u6cd5\u3001\u521b\u5efa\u8868\u8fbe\u5f0f\u7684 AST \u6811\u5e76\u5728\u6839\u8868\u8fbe\u5f0f\u5904\u8fd0\u884c Interpret \u65b9\u6cd5\u5c31\u8db3\u591f\u4e86\u3002\u4e0a\u4e0b\u6587\u53ef\u7528\u4e8e\u5728\u8fd0\u884c\u65f6\u5b58\u50a8\u5e94\u7528\u7a0b\u5e8f\u72b6\u6001\u3002 \u5b9e\u65bd \u8be5\u6a21\u5f0f\u6d89\u53ca\uff1a Client \u2013 \u8fd4\u56de AST \u6811\u5e76\u4e3a\u6839\u8282\u70b9\uff08Client\uff09\u8fd0\u884c Interpret(context) \u4e0a\u4e0b\u6587 &#8211; \u5305\u542b\u5e94\u7528\u7a0b\u5e8f\u7684\u72b6\u6001\uff0c\u5728\u89e3\u91ca\u65f6\u4f20\u9012\u7ed9\u8868\u8fbe\u5f0f\uff08\u4e0a\u4e0b\u6587\uff09 \u62bd\u8c61\u8868\u8fbe\u5f0f &#8211; \u5305\u542b Interpret(context) (Expression) \u65b9\u6cd5\u7684\u62bd\u8c61\u7c7b<a class=\"more-link\" href=\"https:\/\/demensdeum.com\/blog\/zh\/2022\/06\/24\/pattern-interpreter\/\">Continue reading <span class=\"screen-reader-text\">&#8220;\u6a21\u5f0f\u89e3\u91ca\u5668&#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":"zh","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\/zh\/wp-json\/wp\/v2\/posts\/3131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/comments?post=3131"}],"version-history":[{"count":15,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts\/3131\/revisions"}],"predecessor-version":[{"id":3886,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/posts\/3131\/revisions\/3886"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/media?parent=3131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/categories?post=3131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/zh\/wp-json\/wp\/v2\/tags?post=3131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}