CPP-lang

所属分类:C/C++基础
开发工具:Haskell
文件大小:0KB
下载次数:0
上传日期:2023-08-23 08:22:54
上 传 者sh-1993
说明:  教育命令式静态类型编程语言。,
(Educational imperative statically typed programming language.,)

文件列表:
.hlint.yaml (122, 2023-08-23)
CPP.cabal (3712, 2023-08-23)
CPP.cf (2001, 2023-08-23)
LICENSE (1069, 2023-08-23)
Makefile (273, 2023-08-23)
Setup.hs (46, 2023-08-23)
app/ (0, 2023-08-23)
app/Main.hs (733, 2023-08-23)
examples/ (0, 2023-08-23)
examples/bad.cc (52, 2023-08-23)
examples/fib.cc (223, 2023-08-23)
examples/good.cc (139, 2023-08-23)
hie.yaml (178, 2023-08-23)
jvm/ (0, 2023-08-23)
jvm/Main.java (202, 2023-08-23)
jvm/Makefile (320, 2023-08-23)
jvm/Runtime.java (1420, 2023-08-23)
jvm/classfileanalyzer.jar (132023, 2023-08-23)
jvm/main.jar (1712, 2023-08-23)
jvm/manifest.mf (39, 2023-08-23)
src/ (0, 2023-08-23)
src/CPP.hs (1342, 2023-08-23)
src/CPP/ (0, 2023-08-23)
src/CPP/AST.hs (5600, 2023-08-23)
src/CPP/Error.hs (4159, 2023-08-23)
src/CPP/Interpreter.hs (16123, 2023-08-23)
src/CPP/JVM/ (0, 2023-08-23)
src/CPP/JVM/CodeGen.hs (19299, 2023-08-23)
src/CPP/JVM/Jasmin.hs (17015, 2023-08-23)
src/CPP/JVM/Runtime.hs (4730, 2023-08-23)
src/CPP/Lexer.x (3009, 2023-08-23)
src/CPP/Lexer/ (0, 2023-08-23)
src/CPP/Lexer/Support.hs (4604, 2023-08-23)
src/CPP/Parser.y (4682, 2023-08-23)
src/CPP/TypeChecker.hs (10901, 2023-08-23)
src/Extra.hs (2681, 2023-08-23)
test/ (0, 2023-08-23)
... ...

# CPP lang [![](https://github.com/monadplus/CPP-lang/actions/workflows/test.yml/badge.svg)](https://github.com/monadplus/CPP-lang/actions) ## Project **CPP lang** is a static type-checked general purpose programming language and my very first programming language. The language is similar to C but missing lots of important features such as: - Arrays and pointers - Structs and unions - Syscalls and bindings with lib.c - Native execution on x86 architectures The grammar of the language can be found at [CPP.cf](CPP.cf). ### Structure - The frontend (lexer/parser) is defined at [Lexer.x](src/CPP/Lexer.x) and [Parser.y](src/CPP/Parser.y). - The type checker is defined at [TypeChecker.hs](src/CPP/TypeChecker.hs). - The interpreter is defined at [Interpreter.hs](src/CPP/Interpreter.hs). - The backend for the JVM is defined at [JVM/CodeGenerator.hs](src/CPP/JVM/CodeGen.hs). ## Compile The compiler is written in *Haskell*. You can build the compiler using both [Cabal](https://cabal.readthedocs.io/en/3.4/): ```bash $ cabal build ``` or [Stack](https://docs.haskellstack.org/en/stable/README/): ```bash $ stack build ``` ## Run the interpreter Have a look at the files from [examples](examples/). All of them can be executed on the interpreter. ```bash $ cabal run CPP -- .cc --interpreter ``` ## Run on the JVM First, generate the `*.jar`: ```bash $ cabal run CPP -- .cc --jvm ``` Then, run the `*.jar`: ```bash $ java -jar .jar ``` ## TODO - [ ] Arrays - [ ] Pointers - [ ] Add `char` as primitive type - [ ] =Value= should depend on =TExp= - [ ] The JVM backend is not properly tested

近期下载者

相关文件


收藏者