一つ前の記事に
ソース
digraph graphname { graph [rankdir = TB]; subgraph cluster0 { label="Compile"; b [label="car_m4(sed (here doc))" shape="rectangle"] c0 [label="m4 macro set" shape="box3d"] c [label="tmp.m4"] d [label="car_m4(m4)" shape="rectangle"] e [label="mtASM src"] b -> c -> d; c0 -> d -> e; {rank = same;c0;d;} } subgraph cluster1 { label="Assemble"; e0 [label="awk src1" shape="box3d"] f [label="car_mt(awk)" shape="rectangle"] f0 [label="C src"] f1 [label="template C src" shape="box3d"] g [label="car_mt(gcc)" shape="rectangle"] i [label="bet file"] f1 -> g; e0 -> f; f ->i; f -> f0 -> g; {rank = same; e0;f;} } a [label="Esgrsdnl src" shape="note"]; h [label="exe file" shape="Msquare"] i [label="bet file"] a -> b; e -> f; g -> h; }
処理の流れ図の上部のみを取り出してみると・・・
確かに
Compile ⇒ Assemble
と処理して exe file を生成している なので確かにコンパイル型の外部DSLである
しかし・・・・
システムの中に(gcc)があり・・・・
実際にバイナリ(exe file)を吐いているのはgccであります
なぁーんだ・・・
では、正しく自作の外部DSLの処理部分だけ抜き出してみると・・・
ソース
digraph graphname { graph [rankdir = TB]; subgraph cluster0 { label="Compile"; b [label="car_m4(sed (here doc))" shape="rectangle"] c0 [label="m4 macro set" shape="box3d"] c [label="tmp.m4"] d [label="car_m4(m4)" shape="rectangle"] e [label="mtASM src"] b -> c -> d; c0 -> d -> e; {rank = same;c0;d;} } subgraph cluster1 { label="Assemble"; e0 [label="awk src1" shape="box3d"] f [label="car_mt(awk)" shape="rectangle"] e0 -> f; {rank = same; e0;f;} } a [label="Esgrsdnl src" shape="note"]; f0 [label="C src"] i [label="bet file"] a -> b; e -> f; f ->i; f -> f0; }
こうなる
そうなるとCompileとかAssembleとか何なの? ってなるけど・・
まあ、そこはナンチャッテDSLなので・・・
しかし・・・
↑のサイトから引用しますが・・・
コード変換
で、コンパイラを作るよりは多少簡単に作れそうなのが、 図3に示すような、 DSL → 汎用言語へのコード変換です。
これが一番、かかる労力と得られる成果のバランスがいいと思います。
とありますし、汎用言語(ここではC言語)へのコード変換という手法は労力小さく成果は大きいということになります
DSLでなく汎用言語にもnimなんてトランスパイラがありますし、労力小さく言語自作するのにトランスパイル形式を採用するのはお勧めです
なぜなら、シストレ運用をやりやすくするのが一番の目的で、言語を自作するのは2番目の目的ですので・・・・