This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/tests/examplefiles/spice/example.spice
Marc Auberer ca56bf2696
[Spice] Add new keywords and fix bugs (#2227)
* Cleanup

* Add scope access operator

* Add enum keyword

* Update test ref

* Fix bug for tokenizing number formats

* Add pr to CHANGES
2022-09-13 23:23:42 +02:00

48 lines
No EOL
922 B
Text

const int test 0x123;
type BloodType enum {
A,
B = 3,
AB,
ZERO = 0
}
type Person struct {
string firstName
string lastName
unsigned int age
BloodType bloodType
}
// Function to compute fibonacci numbers recursively
f<int> fib(int n) {
if n <= 2 {
return 1;
}
return fib(n - 1) + fib(n - 2);
}
// Function to compute factorial numbers recursively
inline f<int> fac(int input) {
if input < 2 {
return 1;
}
result = input * fac(input - 1);
}
/**
* Entry point of the program
*/
f<int> main() {
short number = 0d10s;
printf("Fibonacci of %d: %d\n", number, fib((int) number));
long base = (long) number;
base += 1;
base <<= 1;
base >>= 3 - 1;
base -= 1;
printf("Faculty of %d: %d\n", base + 7, fac((int) base + 7));
// Sizeof usage
int size = sizeof('T');
printf("Size of char is %d, %d\n", size, true);
}