Skip to content

zxw018018/FPL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The FPL compiler

Coded in OCaml, this takes a highly stripped-down subset of C (ints, bools, and void types, arithmetic, if-else, for, and while statements, and user-defined functions) and compiles it into LLVM IR.

It needs the OCaml llvm library, which is most easily installed through opam.

Install LLVM and its development libraries, the m4 macro preprocessor, and opam, then use opam to install llvm.

The version of the OCaml llvm library must match the version of the LLVM system installed on your system.

In addition to print, which calls the C library function printf(), fpl gratuitiously includes a primitive function "printbig," which prints large ASCII-encoded characters.

The stock C compiler compiles printbig.o. testall.sh runs the fpl executable on each testcase (.mc file) to produce a .ll file, invokes "llc" (the LLVM compiler) to produce a .s (assembly) file, then invokes "cc" (the stock C compiler) to assemble the .s file, link in printbig.o, and generate an executable. See testall.sh for details.

Tips to test built-in fucntion

Compile external function as object file with gcc (do not use g++, it would casue link error!!!)

$ gcc -o mydraw.o -c source/c/mydraw.c -lGL -lGLU -lglut

Compile FPL code into assembly

$ ./fpl.native ./fplTest/test-drawLine.fpl | llc > drawLine.S

Link two files

$ gcc -o mydraw mydraw.o drawLine.S -lGL -lGLU -lglut -lm

In Mac OS X, we can use -framework OpenGL -framework GLUT to link the OpenGL library.

About

Floor Plan Language written in Ocaml and C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •