实际上还是基于C++的,功能极为简单(仅10个变量,不过组合性强),一一替换而已。耍人不错。
一个程序的例子:
天 为 今有甲与乙兮 乙予以〇兮 请将甲予以一兮甲不胜于一〇〇兮甲益则为 乙并以甲兮哉 曰乙兮曰止兮 归曰善兮哉运行结果为:5050。
上转换代码,求高人继续改进!
#!/bin/bash if [ -n "$1" ] then
cf="$1.cpp"
touch $cf
fl=`cat $1`
echo $fl
echo -e "#include <iostream>\n#include <string>\nusing namespace std;\nint main() ">$cf
fl=${fl//不逊于/ >= }
fl=${fl//不胜于/ <= }
fl=${fl//予以/ = }
fl=${fl//同于/ == }
fl=${fl//异于/ != }
fl=${fl//胜于/ > }
fl=${fl//逊于/ < }
fl=${fl//今有/ int }
fl=${fl//或云/ string }
fl=${fl//均以/ \/= }
fl=${fl//倍以/ *= }
fl=${fl//并以/ += }
fl=${fl//去以/ -= }
fl=${fl//其实/ * }
fl=${fl//其地/ & }
fl=${fl//取以/ \\ }
fl=${fl//请将/ for(}
fl=${fl//归曰/ return(}
fl=${fl//一/1}
fl=${fl//二/2}
fl=${fl//三/3}
fl=${fl//四/4}
fl=${fl//五/5}
fl=${fl//六/6}
fl=${fl//七/7}
fl=${fl//八/8}
fl=${fl//九/9}
fl=${fl//〇/0}
fl=${fl//甲/a}
fl=${fl//乙/b}
fl=${fl//丙/c}
fl=${fl//丁/d}
fl=${fl//戊/e}
fl=${fl//己/f}
fl=${fl//庚/g}
fl=${fl//辛/h}
fl=${fl//壬/i}
fl=${fl//癸/j}
fl=${fl//天/}
fl=${fl//与/ , }
fl=${fl//为/ \{ }
fl=${fl//哉/ \} }
fl=${fl//兮/; }
fl=${fl//且/ && }
fl=${fl//或/ || }
fl=${fl//曰/ cout<<}
fl=${fl//听/ cin>>}
fl=${fl//止/endl}
fl=${fl//若/if(}
fl=${fl//可/) }
fl=${fl//道/ \"}
fl=${fl//也/\" }
fl=${fl//益/++ }
fl=${fl//损/-- }
fl=${fl//并/ + }
fl=${fl//去/ - }
fl=${fl//倍/ * }
fl=${fl//均/ \/ }
fl=${fl//剩/ % }
fl=${fl//乾/1}
fl=${fl//坤/0}
fl=${fl//当/while(}
fl=${fl//试/do }
fl=${fl//则/) }
fl=${fl//善/0)}
fl=${fl//之/.}
fl=${fl//又/.}
fl=${fl//第/[}
fl=${fl//个/]}
echo $fl>>$cf
g++ -o "$1.run" $cf
fi
exit 0