ゲーム開発から離れてます

こっちが詰まったら帰ることにしようか。

  • before
main(){
	return 0xff;
}
  • after
48(null)
  49(null)
  51(null)
    52(null)
      1(main)
      50(null)
      53(null)
        49(null)
        54(null)
          58(null)
            2(255)
Node count: 11

255

ノードの種類に諸々の事情でenumが使えず、定数リストを見ないとなにがなんだかわかりません。

  • before
var g;
main(argc, argv){
	var s, t;
	func(g, (s + t) * 2);
	return 1;
}
  • after
48(null)
  49(null)
    50(null)
      1(g)
  51(null)
    52(null)
      1(main)
      50(null)
        1(argc)
        1(argv)
      53(null)
        49(null)
          50(null)
            1(s)
            1(t)
        54(null)
          32(null)
            1(func)
            33(null)
              1(g)
              19(null)
                17(null)
                  1(s)
                  1(t)
                2(2)
          58(null)
            2(1)
Node count: 27

Exception in thread "main" java.lang.Exception: Unimplemented statement 32
	at c.Interpreter.evalExpr(Interpreter.java:100)
	at c.Interpreter.evalCompoundStatement(Interpreter.java:58)
	at c.Interpreter.callFunction(Interpreter.java:34)
	at c.Interpreter.callFunction(Interpreter.java:21)
	at c.CProcesser.main(CProcesser.java:18)

引数だの変数宣言だの関数呼び出しだのはASTまで作れているのですが、実行部分がまだです。
正直いつもプログラミング中にバンバン使っている構文を実装するのにLexerで予約語等定義、Parserで構文定義・AST作成アクション追加、ととにかく面倒で嫌になります。
いいえ、楽しいものです。


今回の野望はこれはほんの一部に過ぎないんだよなあ。
がんばれがんばれできるできる


筑波大学の何かの授業のページ
http://www.hpcs.is.tsukuba.ac.jp/~msato/lecture-note/comp-lecture/tiny-c-note1.html
CUP User's Manual
http://wwwseidl.informatik.tu-muenchen.de/projects/cup/manual.html
JFlex User's Manualの日本語版
http://jflex.de/jflex_manual_j.html


私が使った初めてのコンパイラコンパイラ
それはJavaCCで、LL(k)の再帰下降型でした。
あと思いつかない。