A simple and light programming language for basic problem solving and calculation.
bison -d chicken.y
flex chicken.l
gcc -o chick lex.yy.c chicken.tab.c
- Interactive mode command is
chick
. - To run a script, command is
chick <file-name>.txt
.
For example,chick sample-programs/8_prime_numbers.txt
.
Topic | Description |
---|---|
Data types | Numbers : Default data type. Similar to C double data type.String : Similar to C character array. |
Variables initialization | All variables are initialized globally. variablename := expression; i := 0; firstVariable := -21.5; |
Comment | Single line comment starts with # character.# This is a comment |
Print statement | Prints expression or string without newline. print expression; print 10+20; print firstVariable; print string; print "Hello world\n"; |
Scan statement | Only works in interactive mode. scan variable; scan firstVariable; |
Operators | Precedence:
|
If Else |
|
While loop | while expression then statementi := 0; while i < 10 then { print i; print "\n"; i := i + 1; } |
For loop | for variable : (start, end, step) then statement Where, variable : A pre-initialized variable.start : An expression defining where to start the loop.end : An expression defining when to end the loop.step : An expression defining the value variable will be incremented with.Example 1: i := 0; for i : (0, 5, 1) then print i; Output: 0 1 2 3 4 Example 2: i := 0; for i : (5, 0, -1) then print i; Output: 5 4 3 2 1 Pseudocode for example 1: initialize i ← 0 set start as reference to i set start ← 0, end ← 5, step ← 1 while (start < end) do execute statements start ← start + step end while |
Exit program | Keyword exit terminates the program.exit; |
Random number | random(lower, upper) Returns a randomly generated number within lower to upper. print random(1.21, 3.15); |
Necessary maths |
|
Logarithm |
|
Trigonometry |
|
Licensed under Apache License 2.0.