[[Programing]] > Part1.yaccˤJavascript

ĤäƤߤʤޤȤꤢϡyacc/bisonϥġ(kmyacc)ȤäJavascriptǤäˡܸץߥ󥰸Ȥޤǡɤ夭ΤǤ

#contents

*Ūʤ [#v92cda83]

ץȸϡͤ¤ˤʤäƤ(Ϥ)

#ref(summary2.png);

ץȸȤեȥϡɤȡ饤֥ϥǡȤ߹碌ơϷ̤ץࡣȤϡ礭ĤʬƤ롣Ϥϡɤʸڤʬ롣ʸϤϡ򥳥ԥ塼ʬ̿Ѵ롣ǡVM(Сޥ)¹Ԥ롣ΤϡꥢCPU¹Ԥ뤿ˡСޥǤϤʤޥѴƤɡǤϡCPUǽꡢCPUؤΰ¸ʤˡʤդˤʤäƤ롣

ǡץȸ뤿ˤϡΣ(ϡʸϡVM)ɬסϤϡȴñ(餷)ͭʪ򽦤äƤФʤȤʤ()VMϡ¾Υץߥ󥰸ǤäƤꡢ¾θ켫ΤVMȤƻȤȤ(Ĥޤꡢץߥ󥰸Υȥ󥹥졼Ѵˤ)ǡʸϤϡե񤯤ȡyaccưѴƹʸϥץäƤ롣

*kmyaccΥץեǤäƤߤ [#k25b9d76]

Ȥ櫓ǡץȸιʸϥץ뤿ˡyaccλȤǤФƤߤ뤫ʤǤϡkmyaccȤäơJavascriptäƤߤޤ

-[[yacc:http://www.tokumaru.org/yacc/]]

**¹ԷǤ [#c7c90e17]

Ȥꤢɡ

-[[Flash/FlexǺ벶͸(kmyacc)1- kmyacc  ActionScript ǤȤäƤߤ褦:http://www.hakkaku.net/articles/20080226-154]]

**Ǥȥץե [#q16522b2]

kmyaccΥץեϡǤ˼ϿƤ롣顢¹ԷǤȤ⡢ǤꤷƤۤǤ

-[[kmyacc - ¿бLALRѡ:http://www005.upp.so-net.ne.jp/kmori/kmyacc/]]
-[[kmyacc (4.1.4)>http://www.catch.jp/program/yacc/kmyacc-4.1.4.tar.gz]]

** [#j1e0b713]

kmyaccǡɬפʤΤϰʲ

-kmyacc.exe
-cygwin1.dll
-libե켰
-calc.jsy(JavascriptΥץե롧Ǥ˼Ͽ)

ʤΤȤȡ3 + 4 * 5פȤȡݤ(*)Τۤ­(+)ꡢ̤ͥ⤤Ȥ褦˼꺢ˤʤ뤫顣ʤߤˡkmyaccJavascriptץˤϡϤΥɤޤޤƤ롣

**Ѵ [#oa2b135d]

Ǥϡkmyaccǡץե(calc.jsy)ºݤץѴޤWindowsΥޥɥ饤ǡΤ褦˼¹Ԥ롣

 > kmyacc calc.jsy

ǡcalc.jsե뤬ޤ

ʤkmyaccϡեγĥҤ顢ʲΥ롼˽äƥۥȸꤷޤ

|yaccĥ|ۥȸ|ϥեĥ|
|.y|C|y.tab.c|
|.jy|Java|.java|
|.jsy|JavaScript|.js|
|.ply|Perl|.pl|

-[[KMyacc桼:http://www005.upp.so-net.ne.jp/kmori/kmyacc/kmyacc.html]]

**¹ԤƤߤ [#f0645956]

Ρcalc.jsץեˤϡJavascriptʳˤ⡢ǤɬפʥɤȤhtmlȤ߹ޤƤΤǡcalc.htmlפȥե̾ѹƥ֥饦dzȡ׻Ǥޤȡ̤ͥ䥫åǧƤ롣

-[[ץڡ:http://www.catch.jp/program/yacc/calc.html]] 㡧1+2*3

׻ˤϡε椬Ȥޤ

- + ­
- - 
- * ݤ
- / 껻
- (...) å˷׻

yaccեϡʴϡkmyaccΥץե뤽Τޤ(ѥ֥åɥᥤ)ʸˡϤhtmlեjavascriptޤޤƤޤ

-[[yaccե:http://www.catch.jp/program/yacc/calc.jsy]]

ʤɤϡͤˤʤޤ

-[[ץߥ󥰸/yacclex:http://kmaebashi.com/programmer/devlang/yacclex.html]]
-[[Bison 1.28ޥ˥奢::http://www.bookshelf.jp/texi/bison/bison-ja.html]] 1Ϥ2Ϥ褯ޤȤޤäƤ롣

* [#l338068d]

嵭ΥץɤơäƤߤޤ

**եݡɵˡ [#sb2fe985]

嵭Bison 1.28ޥ˥奢˵ܤƤ륵ץ륳ɤ򸵤ˤơ[[եݡɵˡ:http://ja.wikipedia.org/wiki/%E9%80%86%E3%83%9D%E3%83%BC%E3%83%A9%E3%83%B3%E3%83%89%E8%A8%98%E6%B3%95]](reverse polish notation)äƤߤ

-[[ץڡ:http://www.catch.jp/program/yacc/calc_rp.html]]
-[[yaccե:http://www.catch.jp/program/yacc/calcrp.jsy]]
-[[yaccե:http://www.catch.jp/program/yacc/calc_rp.jsy]]

 㡧1 5 + 2 3 + *
 > 30

ϡ(1+5)*(2+3)Ʊˤʤޤ

**٤Ⱦ;ɲ [#yb48cb07]

ǽΥץˡ٤(߾衧^)Ⱦ;(껻;ꡧ%)ɲá

-[[ץڡ:http://www.catch.jp/program/yacc/calc2.html]]
-[[yaccե:http://www.catch.jp/program/yacc/calc2.jsy]]

 2 ^ 3 => 8
 7 % 2 => 1

**ʣ [#ua682cbe]

(٤Ⱦ;դ)ʣιԤƱ˷׻Ǥ褦ˤƤߤޤ

ꥢܥǡ׻ȷ׻̤äޤ

-[[ץڡ:http://www.catch.jp/program/yacc/calc3.html]]
-[[yaccե:http://www.catch.jp/program/yacc/calc3.jsy]]


**ѿդʣ [#teeedb82]

ˡѿȤ褦ˤƤߤ!

ѿ̾ˤϡƬȾѱѻ(a-zA-Z)2ʸܰʹߤȾѱѿ(a-zA-Z0-9)Ȥޤ

Ϥ⾯

-[[ץڡ:http://www.catch.jp/program/yacc/calc6.html]]
-[[yaccե:http://www.catch.jp/program/yacc/calc6.jsy]]

 a = 10
 b = 20
 a * b => 200


**Ȥ߹ߴؿɲä [#m3b7f7d2]

ޤȤ߹ߴؿɲäޤ

-test()򤽤Τޤ֤
-sqr()ʿ֤
-rnd() ܤ֤

-[[ץڡ:http://www.catch.jp/program/yacc/calc7.html]]
-[[yaccե:http://www.catch.jp/program/yacc/calc7.jsy]]


Ȥϡʴ

 test(123) > 123
 sqr(4) > 2
 rnd(10) > 6.290423613972962

åˡͤǰĤ񤱤ޤ

2İʾΰδؿȤ߹ޤ(num1, num2)Ȥ(num1 num2)ȤäˡбƤʤǤ

ŪˤϡȤ߹ؿ̾᥽åɤȤƸƤӽФ褦ˤƤޤ

----

[[Part2.yaccˤWebץȸ>making_script02]]³

* [#qed12373]

-[[ycatch/dandori.js - GitHub:https://github.com/ycatch/dandori.js]]

*ͻ [#l1457785]

-[[ȬѸ : Series: Flash/Flex Ǻ벶͸(kmyacc) «:http://www.hakkaku.net/series/flashflex%e3%81%a7%e4%bd%9c%e3%82%8b%e4%bf%ba%e6%a7%98%e8%a8%80%e8%aa%9ekmyacc%e7%b7%a8]]
--[[Flash/FlexǺ벶͸(kmyacc)1- kmyacc  ActionScript ǤȤäƤߤ褦:http://www.hakkaku.net/articles/20080226-154]]
--[[Flash/FlexǺ벶͸(kmyacc)2- kmyacc  BASICäݤäƤߤ褦:http://www.hakkaku.net/articles/20080307-158#more-158]]
--[[Shibuya.abcꡢäͷ٤벶͸äƤ(1):http://www.hakkaku.net/articles/20080317-170]]

-[[ParserGenerator - catch.jp:http://www.catch.jp/wiki/index.php?ParserGenerator]]

-[[RubyǺ̯ʥץߥ󥰸~Esoteric Language~:http://www.amazon.co.jp/gp/product/4839927847?ie=UTF8&tag=plaseboeffect-22&linkCode=as2&camp=247&creative=7399&creativeASIN=4839927847]] Amazon
--ʤϡ+-><.,[]פ8Ĥε椷ʤץߥ󥰸䡢ǹץߥ󥰸줬Τ¸ܽǤϡʴ̯ʸ(Esoteric Language)˥ץߥ󥰸κ⤷ޤ
-[[Ruby256ܻȤ_̵ƻ:http://www.amazon.co.jp/gp/product/4756137091?ie=UTF8&tag=plaseboeffect-22&linkCode=as2&camp=247&creative=7399&creativeASIN=4756137091]] Amazon
--Ruby+Raccʤ顢ץߥ󥰸쳫ȯäƳڤʤ!ѡͥ졼Ȥɤʥͥ256ή˴⡣줵Сߤ⺣쳫ȯԤ!
-ޤĤľץߥ󥰤Υ 6 ᥿ץߥ
--http://itpro.nikkeibp.co.jp/article/COLUMN/20070604/273453/
--ޤȤƤߤȡRubyDSLʸʬޤ
-Racc ͷܤ
--Racc򤤤塼ȥꥢ
--http://www.mnet.ne.jp/~tnomura/racc.html

-ˤRubyƻ5 Rubyǽ񤯥եȥɤȥѡ
--http://www.notwork.org/~gotoken/mag/cmagazine/gokudo/5th/

-[[ץߥ󥰸:http://kmaebashi.com/programmer/devlang/index.html]]
-[[Υ by Zynga Japan: 1֤Ǻʰץץȸ(JavaScript):http://labs.unoh.net/2007/03/1javascript.html]]

-[[Route 477 - RubyǹܸDSL:http://route477.net/d/?date=20081020]]
-[[GroovyܸDSL - Gr(uehaj):http://d.hatena.ne.jp/uehaj/20091017/1255747730]]
-[[GroovyܸDSLƤ(GEP3β) - Gr(uehaj):http://d.hatena.ne.jp/uehaj/20100919/1284906117]]

-[[͵θˤ - Being Popular:http://practical-scheme.net/trans/being-popular-j.html]] ݡ롦쥢

ȥå   ʬ Хåå   ñ측 ǽ   إ   ǽRSS