Carrie is a small programming language written in Haskell using the Parsec library. There is limited functionality as of V1.0 but more features will be added as time goes on.
- Parses Functions, the code in the functions and comments wherever
- Parses lines seperated by ';'
- Parses If, While Stmt's
- Parses different kind of lines (assigning and returning)
- To run the compiler simply type "./CarrieCompiler name.car", where name is the name of your Carrie program.
You assign a value to a variable like this:
let x := $1;
func main(Nothing:x) -> Nothing {
let x := 2 + 0;
}
This function calculates the factorial of a number.
func fact(Int:x) -> Int {
if (x == 1) START
return 1;
END
let y := x - 1;
DEC(z, Int);
bind(fact)(y)(z);
let f := z * x;
return f;
}
if (True) START
let y := 9 + 0;
END
You have to test for equality in some when using variables and If Statements This works:
if (z == True) START
...code...
END
This does not work:
if (z) START
...code...
END
DEC is used to declare a variable with a type instead of an initial value. Often used in conjunction with bind.
DEC(z, Int);
bind(factorial, 6, z);
bind is used to assign the output of a function and its input to a variable. Often used in conjunction with DEC. The following code binds the output of giving factorial the number six and stores it in z. (z -> 720)
DEC(z, Int);
bind(factorial, 6, z);
They must be on their own line and start and end with a "#"
# This is a valid comment #
#This is not#
Lists are created by place a list of values seperated by a comma and a space in between two '|' characters
let x := |1, 2, 3|;
- Henning Tonko - Main Contributor - HenningTonko
This project is licensed under UnLicense - see the LICENSE.md file for details
- Thank you Cher