JavaCC,ANTLR,ãã¼ãµã³ã³ããã¼ã¿ã触ã£ã¦ã¿ã
æå ´æã«ã¦ä»¥ä¸ã®ãããªèª²é¡ãåºãã
- ããããΣè¨ç®ã®æ§æã解æããParserã¨è§£æçµæã«ããããå¦çãè¡ãVisitorã®ä½æ
- æ¸å¼ã¯ sum i : NUMBER .. NUMBER of expression
- å¤æ°ã¯iã§åºå®ãiã1ã¤ç®ã®NUMBERãã2ã¤ç®ã®NUMBERã¾ã§å¤åãããªããexpressionãè¨ç®
- expressionã¯ååæ¼ç®ãè¡ããæ¬å¼§ã使ç¨ã§ãããã¨ã
- jjtreeãç¨ãã¦å®è£ ãã
ãã¨ãã°"sum i : 3 .. 5 of 1 + 2 * i"ã27ã«ãªããã¿ãããªå½¢ã§ããã
ã§ã¾ããjjtreeã¨ãããJavaCCã ãã ã¨
æ¦ç¥ã¨ãããæ¹åæ§ã¨ããã
- æéç縮ã®ããå¤æ°iã¯ãã¼ã¯ã¼ãã¨ãã¦ãã
- å¤æ°ã1ã¤ãããªãä»æ§ãªã®ã§è¨å·è¡¨ã¯ä½ããªã
- Visitorã®ãã£ã¼ã«ãã§iã®å½è©²å¤ãè¨æ¶ãã
ãã¨ã¯ãã®å ´ã®å¢ãã§è¿½å å®è£ ããããã¦ãã¾ãã
JavaCC,jjtreeã§
ã³ã¼ãã¯è«¸äºæ
ã®ããç¥ãèªåã§æ¸ããã³ã¼ãã¯170è¡ãããã
12æ31æ¥ã¨1æ1æ¥ã§3æéãã¤ã»ã©æ¶è²»ãå²ã¨åé¡ãèµ·ããããã«ãªãã¨ããã§ã¯ã¾ã£ãããtypoãã¦ã¸ã§ãã¬ã¼ãããç´ããªã©ã§æéãã¨ãããæ°ãããã
ANTLRã§
å¹´æ«ããâã®æ¬ãèªã¿ã¯ããã¦ããã®ã§ã軽ãæ°æã¡ã§ä½ããã¨ã«ã
è¨èªå®è£ ãã¿ã¼ã³ âã³ã³ãã¤ã©æè¡ã«ããããã¹ãå¦çããè¨èªå®è£ ã¾ã§
- ä½è : Terence Parr,ä¸ç°è²ç·,ä¼è¤ç浩
- åºç社/ã¡ã¼ã«ã¼: ãªã©ã¤ãªã¼ã¸ã£ãã³
- çºå£²æ¥: 2011/12/24
- ã¡ãã£ã¢: 大åæ¬
- è³¼å ¥: 5人 ã¯ãªãã¯: 333å
- ãã®ååãå«ãããã° (13件) ãè¦ã
ã³ã¼ãã¯æ¬¡ã®ããã«ãªãã¾ããã
åããã®ã«å¿ è¦ãªãã®ã¯
- antlr-3.4.jar
Visitorã§ã¯ãªããtree grammarã使ã£ã¦æ¨æ§æ解æå¨ãã¸ã§ãã¬ã¼ãããå½¢ã«ãã¾ãããè¡æ°ã¯102è¡ã
tree grammarã®æ¸ãæ¹ãããããã«åè¦å
«è¦ãã¦ããã1æ2æ¥ãçµãã£ã¦ãã¾ããâ¦
JParsecã§
ããããã°ããã®èª²é¡ãåºãå½åã«ãããªããåãããã£ããã¨ãæãåºãã
@pocketberserker ãããJParsecã使ãã¾ãããï¼(ï¾ï¾
2011-12-06 16:56:18 via Tween to @pocketberserker
æãåºãã¦ãã¾ã£ãããããããªãã§ãããã
åããã®ã«å¿ è¦ãªãã®ã¯
- jparsec-2.0.jar
- cglib-nodep-2.2.2.jar
JParsecã§ä½ã£ããã¤ã ã追å å®è£
ã§ä¹ç®è¨å·"*"ãçç¥ãã¦ãä¹ç®ãè¨ç®ã§ããããã«ãã¦ããã¾ãã320è¡ã
ANTLRã®ã¨ãã¨ã¯å¥ã®æå³ã§æ¸ãæ¹ãããããããã¥ã¼ããªã¢ã«ããµã³ãã«ã³ã¼ãèªãã§ããã1æ3æ¥ãéãéãã¦ãã¾ããâ¦
Scalaã®ãã¼ãµã³ã³ããã¼ã¿ã©ã¤ãã©ãªã§
ä¸è¨3ã¤ã§ããªãç²¾ç¥çã«æ¶èãããããçããæ±ãã¦Scalaã§ã試ããã¨ã«ã
98è¡ãScalaã¡ãããã¸Scalaã2æéãããã£ã¦ããªãã¯ãã
ããã£ããã¨
è¨èªã¯ç°ãªããã®ã®ãid:bleis-tiftãããä¸è¨è³æã«ãããã¦ãããã¨(83ãã¼ã¸ããã以é)ãå®æãã¾ããã
- ãã¼ãµã¸ã§ãã¬ã¼ã¿ã¯ãã¹ãè¨èªã¨ã¯ã¸ã§ãã¬ã¼ã¿ç¨ã®è¨èªãè¦ããå¿ è¦ããã
- ãã¼ãµã¸ã§ãã¬ã¼ã¿ã ã¨çæãã¦ã³ã³ãã¤ã«ããªããã°ãªããªã
- ãã¼ãµã¸ã§ãã¬ã¼ã¿ã§çæããã³ã¼ãã¯
- JParsecã®ã³ã¼ããèªãã®ã¯ã¤ãã(ã¨ãããèªããæ°ãããªãâ¦)
- ã³ã¼ãéãè¨ãã
ãã¨ããã¼ãµã¸ã§ãã¬ã¼ã¿ã¯å
é¨ã§ãã¹ãè¨èªã®ã³ã¼ããæ¸ããªããã°ãªããªããªãå ´åãå¤ãã®ã§ãªãã ããªãã¨æã£ãããã¾ããã
JParsecã使ã£ãã³ã¼ãã¯ãä»åå®è£
ãããã®ãååæ¼ç®ã¬ãã«ãªã®ã§ãªãã¨ãèªããã¬ãã«ã§åã¾ã£ã¦ãã¾ããããã£ã¨è¤éãªãã¨ããããã¨ããããããããããªããªãã¨æããã¾ããGroovyããJParsecã使ãã°èªã¿ãããã¯å¤å°æ¹åã§ããããããã¾ãããããã¿ã¼ã³ããããcase classããªãã®ã§ãã¼ã¿æ§é ã«é¢ãã¦ã¯æ¥½ã§ããªãã¨æãã¾ãã
ãã¨ããã¼ãµã³ã³ããã¼ã¿ã¯å°ãããã¼ãµãçµã¿åããã¦å¤§ããªãã¼ãµãä½ãã®ã§ãé¨åé¨åã®ãã¹ããããããã§ãã
ã³ã¼ãã®è§£èª¬ã¯ï¼
å¿ã«ä½è£ãã§ãããæ¸ãã¾ãâ¦