summaryrefslogtreecommitdiff
path: root/error.h
AgeCommit message (Collapse)AuthorLines
2019-11-10Add basics for interpreter; add CLI optionsTom Harley-1/+2
The compiler now accepts options on the command-line, such as whether to interpret or compile, or what kind of output is desired. Instead of mallocing (and creating a memory leak), generated code now uses the Boehm garbage collector to allocate memory for boxes. I'm not entirely sure how the GC works, but it does seem to be working (tested by setting the environment variable GC_PRINT_STATS when running a compiled program that calculates a Fibonacci number). More testing relating to the GC should be created. The basics for an interpreted mode has been started, but getting it to work fully would be difficult: it would require figuring out how to dynamically link LLVM modules/object files into the LLVM execution engine, both for calling wrapper functions and for using the GC. Removed -Weverything because it was finding problems in the GC code despite it being included as a system library. The main function of an inter program has been renamed to inter_main. The GC requires GC_INIT is invoked at initialisation on some systems, so common.c now contains the real main function, which runs GC_INIT followed by inter_main. GC_INIT is a macro, so it cannot be called easily from LLVMIR.
2019-10-30Enable -WeverythingTom Harley-3/+3
Clang has a -Weverything option, that enables all compile-time warnings and elevates them all to errors. This option is now passed to the compiler, and all warnings/errors the code produced have been addressed. Using -Weverything locks the project into using clang as its compiler: this should not be a problem since clang is probably being used to compile the LLVM output of the project anyway. If support for other compilers is required, it should be simple enough to replace -Weverything with an equivalent collection of portable flags. Explicit Makefile rules for compiling the C files produced by flex/bison are now included in the project since these C files absolutely do not pass -Weverything checks.
2019-10-09Implement function definitionsTom Harley-1/+6
Functions can now be defined using the "def" construct. A "main" function has to be defined for LLVM to compile the program. Recursive function definitions are not supported, since all values are eagerly evaluated, causing infinite recursion of the non-base case. Recursive definitions can be supported either by including an if primitive that does not evaluate both sides, or by implementing support for lazy evalution. I'm interested in exploring the latter, but will probably implement the former for now. Similar to the if primitive above, the def primitive is currently an implementation which could potentially be altered into a function that manipulates meta-variables at compile time. This would require compile-time evaluation of functions, which would be really cool, but is also superfluous to the current goal. I might return to this idea after I'm happy with the base implementation of the language.
2019-10-03Support + and * operationsTom Harley-0/+17