A CoffeeScript-like language that compiles to C++.
CreamScript
import stdio
using namespace std
int main() ->
cout << "Hello world!" << endl
return 1
Compiled C++
#include <stdio>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 1;
}
CreamScript
int fibonacci(int n) ->
if n > 1
return fibonacci(n - 1) + fibonacci(n - 2)
else
return n
int main() ->
cout << "Fibonacci(10): " << fibonacci(10) << endl
Compiled C++
int fibonacci(int n) {
if (n > 1)
return fibonacci(n - 1) + fibonacci(n - 2);
else
return n;
}
int main()
{
cout << "Fibonacci(10): " << fibonacci(10) << endl;
}
CreamScript
sum = (double a, double b) ->
return a + b
sum(41, 1)
Compiled C++
auto sum = [] (double a, double b)
{
return a + b;
}
sum(41, 1);
Language
- ✓ Identifiers
- ✓ Variables
- ✗ Definition
- ✗ Assignment
- ✗ Keywords
- ✗ Types
- ✓ Literals
- ✓ Numbers
- ✓ Strings
- ✓ Blocks
- ✓ Single line
- ✗ Multi-line
- ✓ Statements
- ✗ If Else
- ✗ For
- ✗ While
- ✓ Return
- ✓ Expressions
- ✓ Expression Groups
- ✓ Operations
- ✓ Arithmetic
- ✓ Add, Subtract, Multiply, Divide
- ✓ Arithmetic
- ✗ Functions
- ✓ Definition
- ✓ Lambdas
- ✓ Parameter Lists
- ✗ Calls
Compiler
- ✓ Token
- ✓ Scanner
- ✓ Rewriter
- ✓ Lexer
- ✓ Parser
- ✓ Back end
- ✓ C++ Output