Penguin programming language
You have to compile all files from src/
You can run scripts/make.cmd
(for Windows) or scripts/make.sh
(for Linux) to do that or use CMakeLists.txt
Penguin path/to/program.peng
See examples at examples/
Usage:
Penguin examples/a/a.peng
Penguin examples/b/b.peng < examples/b/in/1.in
You can run tests with scripts/tests.bat
or scripts/tests.sh
- Grammar (Google Docs) / Grammar (Repo docs)
- Types of tokens (Google Sheets) / Types of tokens (Repo docs)
- Priority of operations (Google Sheets) / Priority of operations (Repo docs)
- Variable types
int
:1
,-5
,0
-int a = 7;
double
:0.2
,.4
,.5e2
,7.3E-5
-doule b = 1.0e-3;
string
:"Hello World!"
-string c = "teststring";
bool
:true
,false
-bool d = true;
- Operators
- Logical operators:
and
,or
,xor
- Comparison operators:
>
,<
,>=
,<=
,==
,!=
- Mathematical operators:
+
,-
,*
,/
,%
,**
(power),++
(prefix),--
(prefix) - Assignments operators:
=
- Logical operators:
- Comments
/* ... */
- Functions
bool isEven(int a) { return a % 2 == 0; }
- Function operators:
return
- All functions are in global scope by default
null main() { write(isEven(10)); } bool isEven(int a) { return a % 2 == 0; } /* No need to place a function before its usage */
- Cycles
for
:for (int i = 0; i < 10; ++i) { ... }
while
:while (i < 5) { ... }
- Cycle operators:
break
,continue
- Conditional operators:
if (x > 5) { ... }
else if (x < 2) { ... }
else { ... }
- Built-in functions
read(a, b);
write(x, " + ", y, " = ", x + y);
- Local scopes
exsamples/a/a.peng
:null main() { int a; read(a); if (a > 2) { string a = "str"; write(a); } else { bool a = true; write(a); } write(a + 2); }