image

  • フォト Amazonギフト券
    ※この時計の時刻は、閲覧しているパソコンのものであり、必ずしも正確な時間とは限りません

検索

最近のトラックバック

無料ブログはココログ

« 2007-06-06 | トップページ | 2007-06-08 »

2007-06-07

2007-06-07

racc で xvcd を生成することを試し始めた (その4)

if ... elseif ... else end
の構文もサポートしたものを以下においた。

http://homepage2.nifty.com/youichi_kato/src.html
- racc で xvcd
    zzz-2007-06-07.tgz(2007-06-07)
   javascript 風言語から xfy/xvcd のコードを生成する

走らせ方は racc が動作する状態で、 $ make とすればよい。

このソースは http://ruby256.hp.infoseek.co.jp/ から 魔道編のサンプルプログラム
として download したものをベースにして作成している。
コード全部をここに引用したかったが、ちょっと量がおおくなったので、tar+gzip したものの公開とする。

kato$ wc *
     12      24     138 Makefile
     28      55     444 c.intp
    339     652    6030 node.rb
    509    1515   11887 parser.rb
    230     518    5219 parser.y
     60     121     719 src

以下には入力ソースと出力結果を引用する。

kato$cat src
//==== assign ====
message = 'funcall ok'
message = true
message = false
message = message
message = foo(a,b,"x")
message = foo(boo())
message = foo(boo(a))
message = foo(boo(a), zoo(b))

//==== function-call ====
puts( "abc" )
puts( func0() )
puts( a )

//==== if then end =====
if "$a=''"
  x = "ONE"
  y = "TWO"
end

//==== def func =====
def func0()
a="local"
  puts('in func0()')
end
func0()

def func1(a, b, c)
  puts('in func1()')
end
func1("A", "B", "foo(a)")

//==== if then else end =====
if "$a=''"
  a="1"
else
  a="2"
end

//==== if then elseif end =====
if "a"
  a="1"
elseif "b"
a="2"
elseif "c"
  a="3"
else
  a="4"
end

if "a"
  a="1"
elseif "b"
  a="2"
else
  a="3"
end

# //==== End of File ====

出力結果

kato$make
ruby c.intp src && echo ok
<!-- ==== assign ==== -->
<instruction:variable name="message" select="'funcall ok'"/>
<instruction:variable name="message" select="'true'"/>
<instruction:variable name="message" select="'false'"/>
<instruction:variable name="message" select="$message"/>
<instruction:variable name="message" select="foo($a,$b,'x')"/>
<instruction:variable name="message" select="foo(boo())"/>
<instruction:variable name="message" select="foo(boo($a))"/>
<instruction:variable name="message" select="foo(boo($a),zoo($b))"/>
<!-- ==== function-call ==== -->
<instruction:message-box>
  <xvcd:value-of select="'abc'"/>
</instruction:message-box>
<instruction:message-box>
  <xvcd:value-of select="func0()"/>
</instruction:message-box>
<instruction:message-box>
  <xvcd:value-of select="$a"/>
</instruction:message-box>
<!-- ==== if then end ===== -->
<instruction:if test="$a=''">
  <instruction:variable name="x" select="'ONE'"/>
  <instruction:variable name="y" select="'TWO'"/>
</instruction:if>
<!-- ==== def func ===== -->
<instruction:command name="func0">
  <instruction:variable name="a" select="'local'"/>
  <instruction:message-box>
    <xvcd:value-of select="'in func0()'"/>
  </instruction:message-box>
</instruction:command>
<instruction:call name="func0">
</instruction:call>
<instruction:command name="func1">
  <instruction:with-param  name="a"/>
  <instruction:with-param  name="b"/>
  <instruction:with-param  name="c"/>
  <instruction:message-box>
    <xvcd:value-of select="'in func1()'"/>
  </instruction:message-box>
</instruction:command>
<instruction:call name="func1">
  <instruction:with-param name="a" select="'A'"/>
  <instruction:with-param name="b" select="'B'"/>
  <instruction:with-param name="c" select="'foo(a)'"/>
</instruction:call>
<!-- ==== if then else end ===== -->
<instruction:choose>
  <instruction:when test="$a=''">
    <instruction:variable name="a" select="'1'"/>
  </instruction:when>
  <instruction:otherwise>
    <instruction:variable name="a" select="'2'"/>
  </instruction:otherwise>
</instruction:choose>
<!-- ==== if then elseif end ===== -->
<instruction:choose>
  <instruction:when test="a">
    <instruction:variable name="a" select="'1'"/>
  </instruction:when>
  <instruction:when test="44b">
    <instruction:variable name="a" select="'2'"/>
  </instruction:when>
  <instruction:when test="46c">
    <instruction:variable name="a" select="'3'"/>
  </instruction:when>
  <instruction:otherwise>
    <instruction:variable name="a" select="'4'"/>
  </instruction:otherwise>
</instruction:choose>
<instruction:choose>
  <instruction:when test="a">
    <instruction:variable name="a" select="'1'"/>
  </instruction:when>
  <instruction:when test="54b">
    <instruction:variable name="a" select="'2'"/>
  </instruction:when>
  <instruction:otherwise>
    <instruction:variable name="a" select="'3'"/>
  </instruction:otherwise>
</instruction:choose>

ソースは、まだ ruby らしくない部分も多いし無駄もある。
それを解消すべく  プログラミングRuby 第2版 言語編 という本も買った。

 

ピックアップ: 聞くべきか 調べるべきか, 科学計算用Javaライブラリ, etc...

- http://www.arclamp.jp/blog/archives/plan_action.html
> > 聞くべきか、調べるべきか (arclamp.jp アークランプ)

- http://satoshi.blogs.com/life/2007/06/ajax_vs_flashfl.html
> > Life is beautiful: AJAX vs. Flash、fladdictブログより

- http://rikima.cocolog-nifty.com/blog/2007/06/f.html
> > rikima blog: Google Developer Day Tokyo youtube crip集

- http://blogs.itmedia.co.jp/kenjiro/2007/06/post_9b1e.html?ref=atom
> > 「俺がいなくなって駄目になった」と言う転職者・異動者 - けんじろう と コラボろう! [ITmedia オルタナティブ・ブログ]

- http://journal.mycom.co.jp/news/2007/06/06/022/index.html
> > 科学計算用Javaライブラリ「JScience 4.0」登場 | エンタープライズ | マイコミジャーナル

- http://html.xamjwg.org/cobra.jsp
> > Cobra: Pure Java HTML Renderer & Parser (Open Source)

« 2007-06-06 | トップページ | 2007-06-08 »

mokuji

2013年12月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

google

  • twitter
  • __
  • _
    Googleボットチェッカー

合わせて読む

  • 合わせて読む
    フィードメーター - katoy: cocolog あわせて読みたい

リンク