æ§æ解æ
ä¸ç½®æ¼ç®åãæ¸ããã¨ãã«è¾¼ããæ°æã¡ãããããã«ã ã¤ãã¦æ¸ããå ´åã¯åªå é ä½ãé«ããªãã 空ç½ãæãã§æ¸ããå ´åã¯åªå é ä½ãä½ããªãã¨ä¾¿å©ãã f x + y â (f x) + yã¨è§£é f x+y â f (x + y)ã¨è§£éãã§ã«èãã¦ã人ããããããè©å¤ãããªãã®ãâ¦ãâ¦
ä¸ç½®æ¼ç®åã¨Haskell風ã®é¢æ°å¼ã³åºãããã¼ã¹ããå¦çãSchemeã§æ¸ãã¦ã¿ãã ä¾ãã°ä»¥ä¸ã®ãµã³ãã«ãå®è¡ããã¨11ã¨6ã表示ããã ( ~ a = 2 ~ b = a + 1 ~ print (a + b * 3) ~ fact n = n == 0 and 1 or n * fact (n - 1) ~ print (fact b) )å®éã«ã¯ãâ¦
ãHaskell ãã¼ãµãã§æ¤ç´¢ããã¨ãParsecçã®Haskellã§ãã¼ãµãã¤ãã話ã°ããåºã¦ã㦠Haskellã®ãããªãã¼ãµãã¤ãã話ã¯ã¿ã¤ããããªãã£ãã ããªããµã¤ãã«ã¼ã« ãã¼ãµãã§æ¤ç´¢ãããã以ä¸ã®ãã¼ã¸ãè¦ã¤ããããã ãã£ãã説æããã¨ï¼åå¥è§£æã¯è¦â¦
åªå é ä½ãæ°å¤ã§æå®ããæ¹å¼ã®ä¸ç½®æ¼ç®åã®å¦çãã¡ãã£ã¨ããã£ãããã (use util.match) (define rule '((+ . 1) (- . 1) (* . 2) (/ . 2))) (define (prec op) (let ((n (assoc op rule))) (if n (cdr n) 0))) (define parse (match-lambda ((e1) e1) â¦