{"id":524,"date":"2014-01-07T02:30:47","date_gmt":"2014-01-06T17:30:47","guid":{"rendered":"http:\/\/owmya.com\/wordpress\/?p=524"},"modified":"2014-01-08T23:59:51","modified_gmt":"2014-01-08T14:59:51","slug":"esrap-peg-%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%82%92%e5%ae%9f%e9%9a%9b%e3%81%ab%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b-%e3%81%9d%e3%81%ae%ef%bc%91","status":"publish","type":"post","link":"https:\/\/owmya.com\/wordpress\/?p=524","title":{"rendered":"esrap-peg \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u5b9f\u969b\u306b\u4f7f\u3063\u3066\u307f\u308b"},"content":{"rendered":"<h2>(require :esrap-peg) \u306f\u3067\u304d\u305f\u304c\u30fb\u30fb\u30fb<\/h2>\n<p>\u3055\u3066 esrap-peg \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3063\u3066\u307f\u3088\u3046\u3068\u3057\u305f\u304c\u3001\u3044\u304d\u306a\u308a\u300c\u4f7f\u3044\u65b9\u304c\u3088\u3046\u308f\u304b\u3089\u3093\u300d\u72b6\u614b\u306b\u9665\u308b\u3002<\/p>\n<p>esrap-peg \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u95a2\u6570\uff08or \u30de\u30af\u30ed\uff09\u306f\u4ee5\u4e0b<\/p>\n<ul>\n<li>basic-parse-peg<\/li>\n<li>parse-peg-file<\/li>\n<li>ast-eval<\/li>\n<li>peg-code<\/li>\n<li>peg-compile<\/li>\n<li>def-peg-matchers<\/li>\n<\/ul>\n<p>\u3053\u306e\u4ed6\u306b\u5909\u6570 *esrap-peg-patern-package* \u304c\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<p>\u3053\u306e\u95a2\u6570\u306e\u3046\u3061\u3001parse-peg-file \u3068 peg-code, peg-compile \u306b\u95a2\u3057\u3066\u306f esrap-peg \u306b\u3064\u3044\u3066\u304f\u308b test.lisp \u306a\u3069\u3092\u898b\u306a\u304c\u3089\u3057\u3070\u3089\u304f\u5538\u3063\u3066\u3044\u308c\u3070\u3001\u304a\u304a\u3088\u305d\u306e\u4f7f\u3044\u65b9\u306f\u308f\u304b\u3063\u3066\u304f\u308b\u3002\u305d\u3057\u3066\u3001REPL \u4e0a\u3067\u4f7f\u3063\u3066\u307f\u308c\u3070\u3001\u3059\u3050\u306b\u305d\u306e\u7d50\u679c\u304b\u3089\u4f55\u304c\u51fa\u3066\u304f\u308b\u304b\u3082\u304a\u304a\u3088\u305d\u308f\u304b\u308b\u306e\u306f\u6d41\u77f3\u306b Lisp \u306e\u826f\u3044\u3068\u3053\u308d\u3002<\/p>\n<h2>\u304a\u304a\u3088\u305d\u3059\u3050\u306b\u5206\u304b\u3063\u305f\u3068\u3053\u308d\u306e\u3053\u3068<\/h2>\n<ol>\n<li>PEG \u306e\u6587\u6cd5\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\uff08ex: foo.peg\uff09<\/li>\n<li><code>(esrap-peg:parse-peg-file \"foo.peg\")<\/code>\u00a0\u00a0\u3092\u8a55\u4fa1\u3059\u308b\u3068 foo.peg \u3067\u5b9a\u7fa9\u3057\u305f\u6587\u6cd5\u306b\u5f93\u3063\u305f\u30d1\u30fc\u30b5\u30b3\u30fc\u30c9\u304c\u8fd4\u3055\u308c\u307e\u3059\uff08\u591a\u91cd\u5024\u3067\u623b\u3063\u3066\u304f\u308b\u306e\u3067\u4e00\u756a\u4e0a\u306e\u5024\uff09<\/li>\n<li>\u3053\u306e\u30d1\u30fc\u30b5\u30b3\u30fc\u30c9\u3092 peg-compile \u306b\u98df\u308f\u305b\u3066\u3042\u3052\u307e\u3059\uff08ex&gt; <code>(esrap-peg:peg-compile (esrap-peg:parse-peg-file \"foo.peg\"))<\/code>\u3000\uff09<\/li>\n<li>\u3053\u3053\u307e\u3067\u9806\u8abf\u306b\u6210\u529f\u3057\u3066\u3044\u308c\u3070\u3001esrap:parse \u95a2\u6570\u304c\u7d44\u307f\u3042\u304c\u3063\u3066\u3044\u307e\u3059<\/li>\n<\/ol>\n<p>esrap:parse \u95a2\u6570\u306f\u3001esrap-peg \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u306f\u306a\u304f\u3066 esrap \u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u4ee3\u7269\u3067\u3001 esrap \u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30d1\u30fc\u30b5\u69cb\u7bc9\u306e\u305f\u3081\u306e\u95a2\u6570\u3092\u547c\u3093\u3067\u7d44\u307f\u4e0a\u3052\u308b\u306e\u304c\u672c\u6765\u306e esrap \u3067\u306e\u30b9\u30bf\u30a4\u30eb\u306a\u3093\u3067\u3057\u3087\u3046\u3051\u308c\u3069\u3001PEG \u3067\u305d\u306e\u90e8\u5206\u3092\u4ee3\u884c\u3055\u305b\u3066\u3057\u307e\u3046\u306e\u304c esrap-peg \u3068\u3002<\/p>\n<p>\u305d\u3057\u3066\u51fa\u6765\u4e0a\u304c\u3063\u305f esrap:parse \u95a2\u6570\u3067\u3059\u304c\u3001<\/p>\n<pre><code>\r\n&gt; (esrap:parse 'statement \"......\")\r\n<\/code><\/pre>\n<p>\u306e\u69d8\u306a\u5f62\u3067\u4f7f\u3048\u308b\u3002&#8221;&#8230;..&#8221; \u306b\u306f foo.peg \u3067\u5b9a\u7fa9\u3057\u305f\u6587\u6cd5\u306b\u5f93\u3063\u305f\u30b3\u30fc\u30c9\u304c\u5165\u308b\u3002\u3053\u3053\u306f text \u3067\u3042\u308c\u3070\u826f\u3044\u306e\u3067\u3001REPL \u4e0a\u3067\u5b89\u76f4\u306b\u8a66\u3059\u306b\u306f\u6587\u5b57\u5217\u3067\u76f4\u306b\u66f8\u3044\u3066\u554f\u984c\u306a\u304f\u52d5\u304f\u3002\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u3044\u3066\u304a\u304f\u306a\u3089\u3001\u305d\u308c\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3053\u3053\u306b\u306f\u3081\u8fbc\u3093\u3067\u3084\u308c\u3070\u826f\u3044\u3002<\/p>\n<p>\u3067\u3067\u3059\u306d\u3001\u3053\u3046\u3059\u308b\u3068 esrap:parse \u95a2\u6570\u304c\u4f55\u3092\u8fd4\u3059\u304b\u3068\u3044\u3046\u3068\u3001\u6587\u6cd5\u5b9a\u7fa9\u306b\u5f93\u3063\u3066\u4e0e\u3048\u3089\u308c\u305f\u30b3\u30fc\u30c9\u3092\u69cb\u6587\u89e3\u91c8\u3057\u305f\u7d50\u679c\u306e\u307e\u3055\u3057\u304f S \u5f0f\u306e\u5f62\uff08\u30ab\u30c3\u30b3\u3060\u3089\u3051\uff09\u306e\u69cb\u6587\u89e3\u6790\u6728\u3067\u3059\u3002<\/p>\n<h2>\u69cb\u6587\u89e3\u6790\u6728\u306f\u5f97\u3089\u308c\u305f\u3051\u308c\u3069\u30fb\u30fb\u30fb<\/h2>\n<p>\u3055\u3066\u3053\u3053\u307e\u3067\u3067\u7121\u4e8b\u3001\u69cb\u6587\u89e3\u6790\u6728\u3092\u5f97\u3089\u308c\u308b\u3088\u3046\u306b\u306f\u306a\u3063\u305f\u308f\u3051\u3067\u3059\u304c\u3001\u3053\u308c\u3060\u3051\u3060\u3068\u307e\u3055\u3057\u304f\u6587\u6cd5\u306b\u5f93\u3063\u305f\u5f62\u5f0f\u3092\u30c1\u30a7\u30c3\u30af\u3057\u305f\u3060\u3051\u3067\u3001\u305d\u306e\u610f\u5473\u306f\u5168\u7136\u307e\u3063\u305f\u304f\u89e3\u91c8\u3057\u3066\u3044\u307e\u305b\u3093\u3002\u3051\u308c\u3069\u3001\u3088\u3063\u307d\u3069\u7279\u4f8b\u3092\u9664\u3044\u3066\u5927\u6982\u306e\u5834\u5408\u306f\u5927\u5207\u306a\u306e\u306f\u610f\u5473\u306e\u65b9\u306a\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u3069\u3046\u3044\u3046\u3053\u3068\u304b\u3068\u3044\u3046\u3068\u3001\u6587\u6cd5\u306b\u5f93\u3063\u3066\u4f8b\u3048\u3070\u6574\u6570\u5024\u304c\u8a18\u3055\u308c\u3066\u3044\u308b\u3068\u3057\u305f\u3089\u3001\u300c\u3061\u3083\u3093\u3068\u6574\u6570\u5024\u306e\u8868\u73fe\u5f62\u5f0f\u306b\u9069\u3063\u3066\u3044\u308b\u300d\u306a\u3093\u3066\u306e\u306f\u672c\u6765\u306e\u76ee\u7684\u7269\u3067\u306f\u306a\u304f\u3066\u3001\u300c\u305d\u306e\u8868\u73fe\u3055\u308c\u305f\u6574\u6570\u5024\u306f\u30ca\u30f3\u30dc\u306a\u306e\u304b\uff1f\u300d\u304c\u5927\u6982\u306b\u304a\u3044\u3066\u4e00\u756a\u91cd\u8981\u306a\u306e\u3067\u3059\u3002<\/p>\n<p>\u3059\u306a\u308f\u3061\u3001esrap:parse \u95a2\u6570\u304c\u51fa\u6765\u3066\u3001\u69cb\u6587\u89e3\u6790\u6728\u3092\u5f97\u3089\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3060\u3051\u3067\u306f\u3001\u300c\u30fb\u30fb\u30fb\u306e\u8868\u73fe\u5f62\u5f0f\u306b\u9069\u3063\u3066\u3044\u308b\u300d\u3092\u78ba\u8a8d\u3057\u304b\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u300c\u305d\u306e\u8868\u73fe\u3055\u308c\u305f\u3082\u306e\u306f\u306a\u3093\u306a\u306e\u304b\uff1f\u300d\u306b\u7b54\u3048\u3089\u308c\u308b\u3088\u3046\u306b\u305b\u3093\u3068\u3044\u304b\u3093\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070 lex\/yacc \u3067\u300c\u6574\u6570\u8868\u8a18\u3092\u89e3\u91c8\u3057\u3066\u6574\u6570\u5024\u3092\u8fd4\u3059\u300d\u7684\u306a\u3053\u3068\u3092\u3084\u308b\u306b\u306f\u3001(\u3053\u308c\u3060\u3051\u306a\u3089 yacc \u306f\u3044\u3089\u306a\u304f\u3066\uff09lex \u3067\u5b57\u53e5\u89e3\u6790\u3057\u305f\u969b\u306b\u3067\u3082\u3001\u8868\u8a18\u3092\u6574\u6570\u5024\u306b\u5909\u63db\u3057\u3066\u3001\u9069\u5f53\u306b\u89e3\u6790\u7d50\u679c\u306b\u8cbc\u308a\u4ed8\u3051\u3066\u304a\u304f\u3068\u304b\u3057\u305f\u308a\u3059\u308b\u308f\u3051\u3067\u3059\u3002\u3053\u3046\u3057\u3066\u7f6e\u3051\u3070\u3001\u69cb\u6587\u89e3\u6790\u7d50\u679c\u3092\u53d7\u3051\u3066\u3001\u300c\u3075\u3080\u3001\u6574\u6570\u3067\u3042\u308b\u304b\u3002\u3057\u3066\u5024\u306f\uff1f\u300d\u3068\u306a\u308c\u3070\u8cbc\u3063\u4ed8\u3044\u3066\u3044\u308b\u6574\u6570\u5024\u3092\u6301\u3063\u3066\u304d\u3066\u300c\u30ab\u30af\u30ab\u30af\u30b7\u30ab\u30b8\u30ab\u3067\u3063\u305b\u300d\u3068\u306a\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u3068\u4f3c\u305f\u3053\u3068\u3092\u3084\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u304a\u52a9\u3051\u306e\u4ed5\u7d44\u307f\u3082 esrap-peg \u306b\u306f\u3061\u3083\u3093\u3068\u3042\u308a\u307e\u3057\u305f\u3002\u3042\u308b\u3093\u3067\u3059\u3051\u3069\u3001\u3082\u3046\u307b\u3068\u3093\u3069 undocument \u3067\u30a2\u30f3\u30b0\u30e9\u306a\u4e16\u754c\u306b\u5165\u3063\u3066\u3044\u308b\u611f\u3058\u3067\u3059\u3002\u300c\u30bd\u30fc\u30b9\u8aad\u3081\u300d\u3063\u3066\u611f\u3058\u3067\u3057\u305f\u3002<\/p>\n<p>\u305d\u3082\u305d\u3082\u3001\u6700\u521d\u306f\u305d\u306e\u3088\u3046\u306a\u624b\u7acb\u3066\u304c\u6e96\u5099\u3055\u308c\u3066\u3044\u308b\u304b\u3055\u3048\u5206\u304b\u3089\u306a\u3044\u72b6\u614b\u3067\u3001\u4ed5\u65b9\u304c\u306a\u3044\u306e\u3067\u30b0\u30fc\u30b0\u30eb\u5148\u751f\u306b\u304a\u4f3a\u3044\u3092\u7acb\u3066\u3066\u307f\u307e\u3057\u3066\u3001esrap-peg\u00a0 \u306e\u5229\u7528\u4f8b\u3092\u63a2\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u3053\u308c\u304c\u307e\u305f\u7121\u304f\u3066\u96e3\u5100\u3057\u305f\u306e\u3067\u3059\u304c\u3001Quicklisp \u306e\u3068\u3053\u308d\u306b\u3042\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u4e2d\u3067 query-fs \u3068\u3044\u3046 SQL \u6587\u3078\u306e\u6a4b\u6e21\u3057\u7684\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u3042\u308a\u3001\u305d\u308c\u304c esrap-peg \u3092\u5229\u7528\u3057\u3066\u3044\u305f\u306e\u3067\u3001\u307e\u305a\u306f\u305d\u308c\u3092\u8aad\u3093\u3067\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u306e\u7d50\u679c\u3001\u5404\u6587\u6cd5\u8981\u7d20\u306b\u5bfe\u3057\u3066\u610f\u5473\u89e3\u91c8\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3001\u305d\u306e\u6587\u6cd5\u8981\u7d20\uff08\u30b7\u30f3\u30dc\u30eb\u304c\u305d\u308c\u305e\u308c\u5272\u308a\u632f\u3089\u308c\u308b\uff09\u306b\u5bfe\u3057\u3066\u610f\u5473\u3092\u4e0e\u3048\u308b\u95a2\u6570\u3092\u8cbc\u308a\u4ed8\u3051\u307e\u3059\u3002\u5b9f\u969b\u306b\u306f\u3001\u5272\u308a\u5f53\u3066\u306e\u30b7\u30f3\u30dc\u30eb\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc\u306b peg-handler \u3068\u3044\u3046\u9805\u76ee\u3067\u95a2\u6570\u672c\u4f53\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u306e\u30de\u30af\u30ed\u304c esrap-peg:def-peg-fun \u3067\u3059\u3002esrap-peg:def-peg-matchers \u3068\u3044\u3046\u30de\u30af\u30ed\u3082\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u3069\u3046\u305b\u307b\u3068\u3093\u3069\u306e\u6587\u6cd5\u8981\u7d20\u306b\u5bfe\u3057\u3066 def-peg-fun \u3059\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u4e00\u6c17\u306b\u3084\u3063\u3066\u3057\u307e\u3048\u3068\u3044\u3046\u30de\u30af\u30ed\u3067\u3059\u3002\u3053\u306e\u30de\u30af\u30ed\u306f\u3061\u3087\u3063\u3068\u3084\u308a\u3059\u304e\u306e\u6c17\u304c\u3042\u3063\u3066\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u5168\u5bb9\u3092\u5206\u304b\u308a\u3065\u3089\u304f\u3057\u3066\u3044\u308b\u304d\u3089\u3044\u3082\u82e5\u5e72\u611f\u3058\u3089\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u305d\u306e\u8cbc\u308a\u4ed8\u3051\u3089\u308c\u305f\u95a2\u6570\u3092\u5bb9\u6613\u306b\u547c\u3079\u308b\u3088\u3046\u306b\u3057\u305f\u306e\u304c\u3001esrap-peg:ast-eval \u95a2\u6570\u3067\u3059\u3002ast-eval \u306f\u8cbc\u308a\u4ed8\u3051\u3089\u308c\u305f\u95a2\u6570\u3092\u547c\u3076\u969b\u306b\u3001\u5f15\u6570\u3068\u3057\u3066\u69cb\u6587\u89e3\u6790\u6728\u306e\u5272\u308a\u5f53\u3066\u306e\u30b7\u30f3\u30dc\u30eb\u304b\u3089\u5148\u306e\u90e8\u5206\u3092\u6e21\u3057\u3066\u304f\u308c\u307e\u3059\uff08\u3063\u3066\u8a00\u308f\u308c\u3066\u3082\u826f\u304f\u5206\u304b\u3089\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u3042\u3068\u3067\u30b5\u30f3\u30d7\u30eb\u793a\u3057\u307e\u3059\uff09\u3002<\/p>\n<p>def-peg-fun \u3067\u6240\u671b\u306e\u8981\u7d20\u306b\u5bfe\u3057\u3066\u610f\u5473\u89e3\u91c8\uff08\u307e\u3042\u5b9f\u969b\u306a\u3093\u3067\u3082\u3067\u304d\u308b\u306e\u3067\u610f\u5473\u3092\u89e3\u91c8\u4ee5\u4e0a\u306b\u3044\u308d\u3044\u308d\u3067\u304d\u307e\u3059\u304c\uff09\u3059\u308b\u95a2\u6570\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u3001\u305d\u308c\u3092 ast-eval \u3067\u8a55\u4fa1\u3059\u308b\u5f62\u3067\u3059\u3002\u8cbc\u308a\u4ed8\u3051\u308b\u95a2\u6570\u3092\u4e0a\u624b\u3044\u3053\u3068\u7d61\u7e70\u3063\u3066\u304a\u3051\u3070\u3001\u5f97\u3089\u308c\u305f\u69cb\u6587\u89e3\u6790\u6728\u306e\u6839\u3063\u3053\u306b\u5bfe\u3057\u3066 ast-eval \u3092\u639b\u3051\u3066\u3084\u308c\u3070\u3001\u5168\u4f53\u306e\u610f\u5473\u89e3\u91c8\u3092\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u3068\u66f8\u304f\u3068\u3001\u3069\u3046\u305b\u30b7\u30f3\u30dc\u30eb\u304c\u5f35\u308a\u4ed8\u3044\u3066\u3044\u308b\u306a\u3089\u3001\u95a2\u6570\u3068\u3057\u3066\u305d\u308c\u3092\u5b9a\u7fa9\u3057\u3066\u3057\u307e\u3048\u3070\u666e\u901a\u306e eval \u3067\u3082\u52d5\u304f\u306e\u3067\u306f\uff1f\u3068\u3082\u601d\u3048\u308b\u3068\u3053\u308d\u3067\u3059\u304c\u3001\u5b9f\u969b\u306b eval \u3063\u3066\u554f\u984c\u306a\u3044\u5f0f\u3092\u5410\u304f\u3088\u3046\u306a\u6587\u6cd5\u5b9a\u7fa9\u304c\u3084\u305f\u3089\u3081\u3063\u305f\u3089\u5927\u5909\u306b\u306a\u308b\u306e\u3067\u3001\u3053\u308c\u306f\u8ae6\u3081\u305f\u65b9\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3088\u3046\u306a\u611f\u3058\u3067\u304a\u304a\u3088\u305d\u308f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3084\u3063\u3071\u308a\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u4f7f\u7528\u4f8b\u3060\u3051\u3067\u306f\u826f\u304f\u5206\u304b\u3089\u305a\u3001\u7d50\u5c40 esrap-peg\u00a0\u306e\u30bd\u30fc\u30b9\u306e\u8a72\u5f53\u90e8\u5206\u3082\u8aad\u307f\u3001REPL \u3067\u305d\u306e\u8fba\u308a\u3092\u3044\u3058\u304f\u308a\u5012\u3057\u3066\u7406\u89e3\u3057\u305f\u611f\u3058\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u8aad\u3081\u3068\u306f\u3044\u3048\u3001\u307e\u3060\u3057\u3082 esrap-peg:parse-peg-file \u3084 esrap-peg:peg-compile (\u4e2d\u3067\u8abf\u6574\u3057\u3066 esrap-peg:peg-code \u3092\u4e0a\u624b\u3044\u3053\u3068\u547c\u3093\u3067\u3044\u308b\u306e\u3067\u8aad\u3080\u3068\u3057\u305f\u3089\u3001\u305d\u306e\u5b9f\u4f53\u306f esrap-peg:peg-code\uff09\u3092\u8aad\u3093\u3067\u7406\u89e3\u3059\u308b\u306e\u306b\u6bd4\u3079\u308c\u3070\u697d\u305d\u3046\u306a\u306e\u3067\u3001\u826f\u304b\u3063\u305f\u306e\u3067\u3059\u3051\u308c\u3069\u3001\u6b63\u6708\u4f11\u307f\u631f\u3093\u3060\u305f\u3081\u6848\u5916\u6642\u9593\u304c\u639b\u304b\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n<h2>\u4f7f\u7528\u4f8b<\/h2>\n<p>peg \u30d5\u30a1\u30a4\u30eb\u306e\u4f8b\uff1a<\/p>\n<pre><code>\r\nstatement &lt;- spaces expression spaces\r\n\r\nexpression &lt;- (expression spaces add spaces multiplicative_expression)\r\n    \/ (expression spaces sub spaces multiplicative_expression)\r\n    \/ multiplicative_expression\r\n\r\nmultiplicative_expression &lt;-\r\n    (multiplicative_expression spaces mult spaces primary_expression)\r\n    \/ (multiplicative_expression spaces div spaces primary_expression)\r\n    \/ (multiplicative_expression spaces mod spaces primary_expression)\r\n    \/ primary_expression\r\n\r\nprimary_expression &lt;- constant\r\n    \/ ('(' spaces expression spaces ')')\r\n\r\nconstant &lt;- integer_constant\r\n\r\ninteger_constant &lt;- decimal_integer_constant\r\n\r\ndecimal_integer_constant &lt;- sign_part? digit+\r\n\r\nsign_part &lt;- '+' \/ '-'\r\n\r\n## Lex!\r\n\r\nalphabet &lt;- [a-zA-Z]\r\ndigit &lt;- [0-9]\r\n\r\n# operator\r\n\r\nadd &lt;- '+'\r\nsub &lt;- '-'\r\nmult &lt;- '*'\r\ndiv &lt;- '\/'\r\nmod &lt;- '%'\r\n\r\n#\r\n\r\nspaces &lt;- [ \\t]*\r\neol &lt;- '\\r\\n' \/ '\\n' \/ '\\r' \/ eof\r\neof &lt;- !.\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u3001\u6587\u6cd5\u5b9a\u7fa9\u7d42\u4e86\u3002\u3053\u308c\u3092\u9069\u5f53\u306a\u30d5\u30a1\u30a4\u30eb\u306b\u3067\u3063\u3061\u4e0a\u3052\u3066\u304a\u304f\u3002\u4f8b\u3048\u3070\u3001foo.peg\u3002<\/p>\n<p>\u6b21\u306f Lisp \u306e\u30b3\u30fc\u30c9(\u8aad\u307f\u3065\u3089\u3055\u512a\u5148, \u4e2d\u8eab\u7cbe\u67fb\u3057\u3066\u307e\u305b\u3093\u30fb\u30fb\u30fbesrap-peg \u306e\u95a2\u6570\u306f import \u3059\u308b\u306a\u308a\u3057\u3066\u30fb\u30fb\u30fb\uff1a<\/p>\n<pre><code>\r\n(require :esrap-peg) ;; or (asdf:load-system \"esrap-peg\") etx...\r\n#| \u307e\u3042\u9069\u5f53\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u306a\u308a\u30e6\u30fc\u30ba\u30d1\u30c3\u30b1\u30fc\u30b8\u3059\u308b\u306a\u308a\u3057\u3066\r\n   \u3044\u3061\u3044\u3061 esrap-peg \u540d\u524d\u7a7a\u9593\u3092\u8868\u8a18\u3057\u306a\u3044\u3067\u3059\u3080\u3088\u3046\u306b\u3057\u305f\u65b9\u304c\r\n   \u697d\u3067\u3059\u3002\u305d\u306e\u524d\u63d0\u3067\u4e0b\u306f\u66f8\u3044\u3066\u3042\u308b\u306e\u3067\u3001\u305d\u3046\u3057\u306a\u3044\u306a\u3089\u4e0b\u3067\u4f7f\u308f\u308c\u3066\u3044\u308b\r\n   \u5168\u3066\u306e esrap-peg \u306e\u95a2\u6570\u3068 esrap:parse \u306f\u305d\u308c\u305e\u308c\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u4ed8\u304d\u3067\r\n   \u66f8\u304d\u76f4\u3057\u304c\u5fc5\u8981\u3067\u3059\u3002 |#\r\n\r\n(peg-compile \u00a0 (parse-peg-file\u00a0\u00a0\u00a0\"foo.peg\"))\r\n\r\n(defun val_digits (x &amp;optional (y 0))\u00a0 ;; \u982d\u306e\u6cb8\u3044\u305f\u95a2\u6570\u3067\u30b4\u30e1\u30f3\r\n  (cond ((not x) y)\r\n        ('t (val_digits (cdr x) (+ (* 10 y) (parse-integer (cadr (car x))))))))\r\n\r\n(def-peg-fun identifier (x)) (def-peg-fun defined_identifier (x))\r\n\r\n(def-peg-fun statement (x) \u00a0 (ast-eval (second x)))\r\n\r\n(def-peg-fun expression (x)\r\n  (cond ((atom (car x)) (ast-eval x)) ; x == MULTIPLICATIVE_EXPRESSION\r\n        ((eq 'add (car (third x))) (+ (ast-eval (car x)) (ast-eval (fifth x))))\r\n        ((eq 'sub (car (third x))) (- (ast-eval (car x)) (ast-eval (fifth x))))\r\n        ('t (break))))\r\n\r\n(def-peg-fun multiplicative_expression (x)\r\n  (cond ((atom (car x)) (ast-eval x)) ; x == PRIMARY_EXPRESSION\r\n        ((eq 'mult (car (third x))) (* (ast-eval (car x)) (ast-eval (fifth x))))\r\n        ((eq 'div (car (third x))) (\/ (ast-eval (car x)) (ast-eval (fifth x))))\r\n        ((eq 'mod (car (third x))) (mod (ast-eval (car x)) (ast-eval (fifth x))))\r\n        ('t (progn (format 't \"MULTIPLICATIVE EXPRESSION ERROR: ~A\" (third x))))))\r\n\r\n(def-peg-fun primary_expression (x)\r\n  (cond ((eq 'constant (car x)) (ast-eval x))\r\n        ((eq 'defined_identifier (car x)) (ast-eval x))\r\n        ('t (ast-eval (third x))))) ; open-r-brachet spaces EXPRESSION spaces close-r-bracket\r\n\r\n(def-peg-fun constant (x) \u00a0 (ast-eval x))\r\n\r\n(def-peg-fun integer_constant (x) \u00a0 (ast-eval x))\r\n\r\n(def-peg-fun decimal_integer_constant (x)\r\n  (cond ((not (car x)) (val_digits (car (cdr x))))\r\n        ((equal (car (cdr (car x))) \"-\") (- (val_digits (car (cdr x)))))\r\n        ('t (val_digits (car (cdr x))))))\r\n<\/code><\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3002\u4e0a\u306b\u3082\u66f8\u3044\u305f\u3051\u308c\u3069\u3001esrap-peg \u306e\u95a2\u6570\u3082 esrap-peg:def-peg-fun \u306e\u3088\u3046\u306a\u5f62\u5f0f\u3067\u66f8\u3051\u3070\u3001(require :esrap-peg) \u3057\u3066\u3042\u308b\u3060\u3051\u3067\u3082\u52d5\u304d\u307e\u3059\u3002\u3068\u3053\u308d\u3069\u3053\u308d\u6b8b\u5ff5\u306a\u611f\u3058\u306e\u6b8b\u9ab8\u304c\u30fb\u30fb\u30fb\u6c17\u306b\u3057\u306a\u3044\u30fb\u30fb\u30fb<\/p>\n<p>\u3053\u308c\u3092\u30a8\u30f4\u30a1\u3063\u3066\u3001<\/p>\n<p style=\"padding-left: 30px;\"><code>(esrap:parse 'statement \"1 + 24 \/ (1 + 3) \")<\/code><\/p>\n<p>\u3068\u304b\u8a55\u4fa1\u3057\u3066\u5f97\u305f\u89e3\u6790\u6728\u306b esrap-peg:ast-eval \u3059\u308c\u3070 7 \u3068\u304b\u8fd4\u4e8b\u304c\u6765\u308b\u3093\u3058\u3083\u306a\u3044\u304b\u306a\u3002<\/p>\n<p>PEG \u5b9a\u7fa9\u304c\u82e5\u5e72\u5197\u9577\u306a\u306e\u306f\u3001\u5148\u3005\u306e\u5b9f\u9a13\u3067 identitier \u306a\u3093\u305e\u4f7f\u3063\u3066\u5909\u6570\u306a\u3069\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u308b\u3068\u304d\u306e\u62e1\u5f35\u306e\u6e96\u5099\u306e\u305f\u3081\u3067\u3059\u3002\u60aa\u3057\u304b\u3089\u305a\u3002<\/p>\n<h2>\u3053\u3053\u3067\u306e\u30b3\u30fc\u30c9\u306e\u30e9\u30a4\u30bb\u30f3\u30b9\u306b\u3064\u3044\u3066<\/h2>\n<p>\u4e0a\u8a18\u3001PEG \u306a\u3089\u3073\u306b Common Lisp \u306e\u30b3\u30fc\u30c9\u306f<a title=\"\u3053\u306e\u30b5\u30a4\u30c8\u3067\u63d0\u793a\u3057\u3066\u3044\u308b\u30b3\u30fc\u30c9\u306e\u57fa\u672c License\" href=\"https:\/\/owmya.com\/wordpress\/?page_id=560\">\u3053\u306e\u30b5\u30a4\u30c8\u3067\u63d0\u793a\u3057\u3066\u3044\u308b\u30b3\u30fc\u30c9\u306e\u57fa\u672c License<\/a> \u306b\u63b2\u3052\u308b\u3082\u306e\u306b\u5f93\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>(require :esrap-peg) \u306f\u3067\u304d\u305f\u304c\u30fb\u30fb\u30fb \u3055\u3066 esrap-peg \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3063\u3066\u307f\u3088\u3046\u3068\u3057\u305f\u304c\u3001\u3044\u304d\u306a\u308a\u300c\u4f7f\u3044\u65b9\u304c\u3088\u3046\u308f\u304b\u3089\u3093\u300d\u72b6\u614b\u306b\u9665\u308b\u3002 esrap-peg \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b &hellip; <a href=\"https:\/\/owmya.com\/wordpress\/?p=524\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8,16,4],"tags":[17],"class_list":["post-524","post","type-post","status-publish","format-standard","hentry","category-8","category-16","category-develop_and_design","tag-common-lisp"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/524","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=524"}],"version-history":[{"count":8,"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/524\/revisions"}],"predecessor-version":[{"id":562,"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/524\/revisions\/562"}],"wp:attachment":[{"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/owmya.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}