peg/leg â recursive-descent parser generators for C peg and leg are tools for generating recursive-descent parsers: programs that perform pattern matching on text. They processes a Parsing Expression Grammar (PEG) [Ford 2004] to produce a program that recognises legal sentences of that grammar. peg processes PEGs written using the original syntax described by Ford; leg processes PEGs written using
調åã«ä¹ã£ã¦Rubyã§ãPEGãã¼ã¶ã³ã³ããã¼ã¿æ¸ãã¦ã¿ããRubyã¯ç´ 人(ã³ã¼ãèªåçæã¨ãã«ãã使ã£ã¦ãªã)ãªã®ã§ãããã¡ãã£ã¨ããããæ¹ãããããã¨ããããããæ¹ãRubyã£ã½ãããã¨ããã£ããæãã¦ãã ããã module PEGParserCombinator class Parser def initialize(&parser) @parser = parser end def [](input) @parser[input] end alias parse [] def /(that) Parser.new{|input| self[input] || that[input] } end def ^(that) Parser.new{|input| (r1 = self[input]) && (r2 = that[r1[1]]) && [[r1[0], r2[0]], r2
ããã¾ã§PEGãã¼ã¶ã³ã³ããã¼ã¿ä½ã£ã¦ããè¨èªã¯ãå ¨ã¦ãã¬ãã·ã«ã«ã¹ã³ã¼ãã®ç¡åé¢æ°ãããã«é¡ä¼¼ã®æ©è½ãæã£ã¦ããããã容æã«ä½ããã¨ãã§ãã¾ããããCè¨èªã«ã¯ç¡åé¢æ°ã®ãããªæ©è½ãç¡ããããã¡ãã£ã¨é ãã²ããã¾ãããã¨ããããä½ããã¨ãåªå ãããã®ã§ãã¡ã¢ãªç®¡çã¨ããã©ã¤ãã©ãªã¨ãã¦ã®åå©ç¨ããããããã«ããããã¡ã¤ã«ã«å®£è¨ãé©åã«åé¢ããã¨ãä¸åèæ ®ãã¦ã¾ããããã¨ãã°ãåçãªã¡ã¢ãªç¢ºä¿ã¯ãmallocããå¾ããã®ã¾ã¾æ¾ç½®ã§ãfreeãã¦ã¾ããããã¨ãCè¨èªã¯æ®æ®µä½¿ããªãã®ã§ãCè¨èªããªããªã«ä½¿ã£ã¦ããæ¹ããããã¨ãã¡ã¢ãªç®¡çã¨ã以å¤ã®åºæ¬çãªã¨ããã§ãããã³ãã©ããæºè¼ãªæ°ãããã®ã§ããã®è¾ºãææãã¦ããã ããã°ã¨æãã¾ãã #include <stdio.h> #include <string.h> #include <stdlib.h> #define RULE(name) Pa
Parsing Expression Grammar (PEG)ããã¼ã¹ã¨ããæ§æ解æå¨ãçæãããã¼ãµã¸ã§ãã¬ã¼ã¿Metalãä½ãã¾ãããRubyã§æ¸ããã¦ãããRubyã®ã³ã¼ããçæãã¾ãã Metalã®å¤ãã¯OMeta: an Object-Oriented Language for Pattern MatchingãRubyã«ç§»æ¤ãããã®ã§ãã Metalã®ç¹å¾´ï¼ Rubyã§ã¢ã¯ã·ã§ã³ãæ¸ãã ãªãã¸ã§ã¯ãæåï¼ç¶æ¿ãMix-inãå§è²ããªã¼ãã¼ã©ã¤ããsuperï¼ PEGã®ç¹å¾´ã¯ãã®ã¾ã¾ ææ§ããç¡ã å·¦å帰ãæ¸ããªãï¼ãã¾ã®ã¨ããï¼ ã¡ã¢åãã ã½ã¼ã¹ã³ã¼ãã¯CodeRepos:/lang/ruby/metalã«ããã®ã§ãã¬ãã¬ããããã¾ãã 使ãæ¹ Ruby gemsã§ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã $ gem install metal ææ³å®ç¾©ãã¡ã¤ã«ãæ¸ãã¦ãmetalã³ãã³ã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}