Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function main(string[] args) < int32:
- float f = 1.3
- bool b = true
- int32[] int_array = [4, 5, 12, 3]
- uint8 eightbitInteger = 127
- string s = "Hellorld!"
- loop int8 i in range(0,10,1): # range(start, stop-exclusive-optional, step-optional) <-
- if (b and f > 1):
- print(s)
- print(f)
- int_array[0]-- # decrement int_array element 0
- eighbitInteger++ # increment eightbitInteger
- ;
- ;
- loop i in int_array:
- print(i)
- ;
- loop while b:
- # Condition checked before loop statement
- ;
- loop until not b:
- # Condition checked after loop statement, inverse logic
- ;
- loop:
- print("This never ends.")
- ;
- return 0
- ;
- function print(string s):
- Console.Out.PrintLine(s)
- ;
- class Stream:
- static int32 iVal = 0
- static public function PrintLine(string s):
- .iVal = s.length()
- loop int32 i from s:
- uint8 char = s[i]
- #ifdef ASM_6502
- asm (char):
- PHA
- LDA %char%
- STA #GPU_CMDQ_ADDRESS
- PLA
- ;
- #endif
- ;
- ;
- ;
- class Console:
- static Stream Out
- ;
- class string:
- private uint8[] backingArray
- public string():
- # .<class member> is shorthand for this.<class member>
- .backingArray = []
- ;
- public string(uint32 initialBackingArraySize):
- .backingArray = [](initialBackingArraySize)
- ;
- public ~string():
- .backingArray = None
- ;
- public function addCharacter(uint8 char):
- .backingArray.add(char)
- ;
- # short circuit version of returning function - the return type is inferred from the called function
- public function length() < .backingArray.length()
- # overloads [] accessor
- public function getItemAt(uint32 itemIndex) < uint8:
- return .backingArray[itemIndex]
- ;
- # overloads [] mutator
- public function setItemAt(uint32 itemIndex, uint8 char):
- .backingArray[itemIndex] = char
- ;
- # overloads =
- public function assignment(string other):
- .backingArray = other.clone()
- ;
- public function equals(string other) < bool:
- bool same = true
- loop uint32 i from range(0, other.backingArray.length):
- if (other[i] != .backingArray[i]):
- same = false
- break
- ;
- ;
- return same
- ;
- public function clone() < uint8[]:
- return .backingArray.clone()
- ;
- ;
- class array<T>:
- private array T backingArray
- public array<T>():
- .backingArray = array T()
- ;
- public array<T>(uint32 initialBackingArraySize):
- .backingArray = array T(initialBackingArraySize)
- ;
- ;
Advertisement
Add Comment
Please, Sign In to add comment