Counterlang
Jump to navigation
Jump to search
Counterlang uses counters to do stuff
The stuff
Counter
count a #make a a counter initialized as 0 a1 #add 1 to counter of a a-2 #add -2 to counter of a a2 #add 2 to counter of a aa #add a to counter of a (double) aa #double aa #double a is 16 now a- #reset a to 0
.1 #prints 1 ,65 #prints A
Goto
!2 #loop !1 #loop
End
: #end count thisisnotexecuted thisisnotexecuted100 .thisisnotexecuted
Syntax
An Extended Backus-Naur Form (EBNF) description shall be adduced for the language:
program := { innerLine } , [ lastLine ] ;
innerLine := lineContent , newlines ;
lastLine := lineContent ;
lineContent := padding , [ command ] , [ comment ] ;
comment := "#" , { character - newline } ;
command := initCommand
| addCommand
| subtractCommand
| resetCommand
| printCharCommand
| printNumCommand
| jumpCommand
| haltCommand
;
initCommand := "count" , spacing , counterName ;
addCommand := counterName , operand ;
subtractCommand := counterName , "-" , operand ;
resetCommand := counterName , "-" ;
printCharCommand := "," , operand ;
printNumCommand := "." , operand ;
jumpCommand := "!" , operand ;
haltCommand := ":" ;
operand := unsignedInteger | counterName ;
unsignedInteger := digit , { digit } ;
counterName := letter , { letter } ;
padding := { space } ;
spacing := space , { space } ;
newlines := newline , { newline } ;
newline := "\n" ;
space := " " ;
Examples
Counting Up
The following program perpetually counts up from inclusive zero (0):
count upCounter .upCounter upCounter1 !2
Interpreter
- Common Lisp implementation of the Counterlang programming language.