You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,34 +43,34 @@ The Coral GitHub page provides installers for MacOS and several Linux distributi
43
43
To build the language from the source, **you must have OCaml (5.x recommended), ocaml-llvm, and clang already installed**. To build Coral from the source with OCaml, ocaml-llvm, and gcc/clang already installed, run:
This will generate an executable called coral which acts as a compiler and interpreter for our language. If OCaml and ocaml-llvm are not already installed, you should install them. On Mac OS, run:
52
52
53
53
```bash
54
-
>brew install opam llvm
55
-
>opam init
56
-
>eval$(opam env)
57
-
>opam install llvm ocamlbuild ocamlfind
54
+
brew install opam llvm
55
+
opam init
56
+
eval$(opam env)
57
+
opam install llvm ocamlbuild ocamlfind
58
58
```
59
59
60
60
If the above fails, you may need to run `eval $(opam env)` after opam init. You may also need to ensure the LLVM binaries are in your PATH:
61
61
62
62
```bash
63
-
>export PATH=/opt/homebrew/opt/llvm/bin:$PATH# Apple Silicon
64
-
>export PATH=/usr/local/opt/llvm/bin:$PATH# Intel Mac
63
+
export PATH=/opt/homebrew/opt/llvm/bin:$PATH# Apple Silicon
64
+
export PATH=/usr/local/opt/llvm/bin:$PATH# Intel Mac
65
65
```
66
66
67
67
On Linux, follow the OCaml/Opam installation instructions [here](https://opam.ocaml.org/doc/Install.html) for your distribution, install llvm following instructions [here](https://apt.llvm.org/), and then run
68
68
69
69
```bash
70
-
>sudo apt-get install cmake llvm opam
71
-
>opam init
72
-
>eval$(opam env)
73
-
>opam install llvm ocamlbuild ocamlfind
70
+
sudo apt-get install cmake llvm opam
71
+
opam init
72
+
eval$(opam env)
73
+
opam install llvm ocamlbuild ocamlfind
74
74
```
75
75
76
76
You may need to add the llvm bin directory to your PATH variable using bashrc or zshrc.
@@ -116,23 +116,23 @@ print(gcd(a,b))
116
116
This code is syntactically identical to Python, and requires no type annotations. To compile using the Coral compiler, save this code to a file called gcd.cl and compile it with
117
117
118
118
```bash
119
-
>coral gcd.cl
119
+
coral gcd.cl
120
120
```
121
121
122
122
By default, this will generate the corresponding LLVM IR, compile it to an executable file called a.out, and run it. To change the name of the output file, run
123
123
124
124
```bash
125
-
>coral gcd.cl -o main
125
+
coral gcd.cl -o main
126
126
```
127
127
128
128
This will name the file main instead. To generate only the LLVM IR, run Coral with the ```-emit-llvm``` flag. To generate only the assembly code, run Coral with the ```-S``` flag. To only run the semantic checker without compilation, use the ```-no-compile``` flag. To disable runtime error checking for improved performance, using the ```-no-except``` flag.
129
129
130
130
```bash
131
-
>coral gcd.cl -emit-llvm # only produces llvm
132
-
>coral gcd.cl -no-compile # only run semantic checker
133
-
>coral gcd.cl -no-except # generates machine code with no runtime error handling
134
-
>coral gcd.cl -S # only generates assembly code
135
-
>coral gcd.cl -d # shows debugging information about the program. can be combined with other flags
131
+
coral gcd.cl -emit-llvm # only produces llvm
132
+
coral gcd.cl -no-compile # only run semantic checker
133
+
coral gcd.cl -no-except # generates machine code with no runtime error handling
134
+
coral gcd.cl -S # only generates assembly code
135
+
coral gcd.cl -d # shows debugging information about the program. can be combined with other flags
136
136
```
137
137
138
138
Coral also has a build-in **interpreter**. To use the interpreter, simply run ```coral``` without a file specified. This will open an interactive window like the OCaml or Python interpreter in which you can run any valid Coral program. The following is an example of gcd code run in the interpreter:
0 commit comments