|
| 1 | +# Java Compiler API Specification |
| 2 | + |
| 3 | +#### Introduction |
| 4 | + |
| 5 | +The java version of the classical Chinese compiler is an extension of the `文言文编程语言 ` ecology, which is part of the` WenYan Programming Language` project. It can compile `文言文编程语言 ` into groovy scripts. |
| 6 | +Or convert to class bytecode and run on the JVM platform, so it can call all code libraries in the Java ecosystem. |
| 7 | + |
| 8 | +It simulates an array of programming languages such as the js language, and derives syntactic sugar, so that most of the `文言文编程语言 ` source files based on the js compiler version can be compiled and compatible on the JVM. |
| 9 | + |
| 10 | +You can find its in the README.md file [source code link](https://github.com/MagicLu550/wenyan-lang_jvm) |
| 11 | + |
| 12 | +#### use |
| 13 | + |
| 14 | +The compiler script file has not been completed, but you can do it through a jar file, as the following instructions |
| 15 | +```bash |
| 16 | +java -jar wenyan.jar -c HelloWorld.wy out -r |
| 17 | +``` |
| 18 | + |
| 19 | +For compiler parameter interpretation |
| 20 | + |
| 21 | +`-p` value: true / false support pinyin |
| 22 | + |
| 23 | +`-c` value: @MakeFile (compile files in batches), write the file path line by line / a file name, compile only one file |
| 24 | + |
| 25 | +`-o` value: path to output folder |
| 26 | + |
| 27 | +`-l` value: lib used for compilation, multiple lib paths; split |
| 28 | + |
| 29 | +`-r` value: run-time parameters Note: This option must be placed last, it will run the file |
| 30 | + |
| 31 | +#### API |
| 32 | + |
| 33 | +You can also import the jar package and use it as API |
| 34 | + |
| 35 | +```groovy |
| 36 | +import cn.wenyan.compiler.WenYanTools |
| 37 | +
|
| 38 | +def func = WenYanTools.makeCompiler |
| 39 | +
|
| 40 | +def javaClass = compiler.compileToClass("HelloWorld","吾有一言,曰『问天地好在』,書之。") |
| 41 | +
|
| 42 | +javaClass.getDeclaredMethod("run").invoke(javaClass.newInstance()) |
| 43 | +
|
| 44 | +``` |
| 45 | + |
| 46 | +API for external calls |
| 47 | + |
| 48 | +```java |
| 49 | +public interface WenYanCompiler extends Compile,RunCode{ |
| 50 | + |
| 51 | + Class<?> compileToClass(String className,String... wenyanString); |
| 52 | + |
| 53 | + void runFile(String file,String[] args); |
| 54 | + |
| 55 | + void runFile(String file); |
| 56 | + |
| 57 | + void runFile(File file) throws IOException; |
| 58 | + |
| 59 | + // = compile(wenyan) |
| 60 | + String dispatch(String wenyan); |
| 61 | + |
| 62 | + // 简体中文 to 繁体中文 |
| 63 | + String getTraditionalChinese(String wenyan); |
| 64 | +} |
| 65 | + |
| 66 | +``` |
| 67 | + |
| 68 | +#### Current progress |
| 69 | + |
| 70 | +1. Currently in development, not all syntax is complete |
| 71 | +2. The syntax of the implementation can be found in [README](https://github.com/MagicLu550/wenyan-lang_jvm/blob/master/README.md) |
| 72 | + |
0 commit comments