yaipl

所属分类:collect
开发工具:OCaml
文件大小:0KB
下载次数:0
上传日期:2018-01-24 21:20:15
上 传 者sh-1993
说明:  另一种必要的编程语言——一个基于LLVM万花筒的有趣项目
(Yet Another Imperative Programming Language - a fun project based on LLVM s Kaleidoscope)

文件列表:
.merlin (146, 2018-01-24)
Makefile (385, 2018-01-24)
_tags (167, 2018-01-24)
examples/ (0, 2018-01-24)
examples/average.yaipl (46, 2018-01-24)
examples/average_main.cpp (361, 2018-01-24)
examples/extern.yaipl (75, 2018-01-24)
examples/fibonacci.yaipl (86, 2018-01-24)
examples/functions.yaipl (51, 2018-01-24)
examples/logic.yaipl (145, 2018-01-24)
examples/mandelbrot.yaipl (1433, 2018-01-24)
examples/print_stars.yaipl (148, 2018-01-24)
examples/print_stars_main.cpp (248, 2018-01-24)
myocamlbuild.ml (338, 2018-01-24)
src/ (0, 2018-01-24)
src/astree.ml (270, 2018-01-24)
src/astree.mli (270, 2018-01-24)
src/codegen.ml (7955, 2018-01-24)
src/codegen.mli (282, 2018-01-24)
src/emit.ml (1089, 2018-01-24)
src/emit.mli (247, 2018-01-24)
src/lexer.mll (891, 2018-01-24)
src/optimization.ml (356, 2018-01-24)
src/optimization.mli (66, 2018-01-24)
src/parser.mly (1884, 2018-01-24)
src/yaipl.ml (2123, 2018-01-24)
src/yaiplc.ml (1028, 2018-01-24)
stdlib/ (0, 2018-01-24)
stdlib/io.c (122, 2018-01-24)
test/ (0, 2018-01-24)
test/gitkeep (0, 2018-01-24)

# YAIPL - Yet Another Imperative Programming Language This is yet another implementation of an imperative programming language (YAIPL). It is a fun project based on the LLVM Ocaml tutorial on [Kaleidoscope](https://llvm.org/docs/tutorial/OCamlLangImpl1.html) to understand the LLVM infrastructure's internals and its intermediate representation. Contrary to the tutorial, YAIPL's implementation does not implement the lexer and parser in pure Ocaml but rather utilizes ocamllex and menhir. There are two ways to interact with YAIPL. The compiler yaiplc and the REPL yaipl. Compile yaiplc, yaipl and its stdlib simply with: ``` bash make ``` To compile your fist YAIPL program: ``` bash yaiplc.native examples/print_stars.yaipl print_stars clang++ examples/print_stars_main.cpp stdlib/io.o print_stars.o -o print_stars_main.out ``` And just execute it: ``` bash ./print_stars_main.out **************************************************************************************************** ``` yaiplc dumps also the llcode: ``` llvm ; ModuleID = 'main' source_filename = "main" declare double @putchard(double) define double @printstar(double %n) { entry: br label %loop loop: ; preds = %loop, %entry %i = phi double [ 1.000000e+00, %entry ], [ %nextvar, %loop ] %calltmp = call double @putchard(double 4.200000e+01) %nextvar = fadd double %i, 1.000000e+00 %cmptmp = fcmp ult double %i, %n br i1 %cmptmp, label %loop, label %afterloop afterloop: ; preds = %loop ret double 0.000000e+00 } ```

近期下载者

相关文件


收藏者