mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-11-22 18:32:09 +00:00
3bb7fce2f0
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@317 4df02467-bbd4-4a76-a152-e7ce94205b78
215 lines
4.2 KiB
Plaintext
215 lines
4.2 KiB
Plaintext
;ACME 0.97
|
|
; "assert" macro
|
|
!macro a @r {
|
|
!if @r != 1 {
|
|
!error "assertion failed"
|
|
}
|
|
}
|
|
|
|
three = 3
|
|
five = 5
|
|
seven = 7
|
|
fp = 123.456
|
|
abcdef = $abcdef
|
|
|
|
; literals
|
|
+a 255 == $ff
|
|
+a 255 == 0xFF
|
|
+a 255 == %#1#1#1#1
|
|
+a 255 == 0b1111####
|
|
+a 255 == &377
|
|
+a 33 == '!'
|
|
|
|
; test monadic operators
|
|
+a NOT 1 == -2
|
|
+a -three == -3
|
|
+a <abcdef == $ef
|
|
+a >abcdef == $cd
|
|
+a ^abcdef == $ab
|
|
+a addr(abcdef) == abcdef
|
|
+a int(abcdef) == abcdef
|
|
+a float(three) == three
|
|
+a three == float(three)
|
|
+a float(fp) != int(fp)
|
|
+a int(fp) != float(fp)
|
|
+a float(three) == int(three)
|
|
+a int(three) == float(three)
|
|
+a sin(3.14) > 0
|
|
+a cos(0.1) > 0.9
|
|
+a tan(3.1415 / 2) > 1
|
|
+a arcsin(1) > 1.57
|
|
+a arccos(0) > 1.57
|
|
+a arctan(1) > 0.78
|
|
|
|
; test dyadic operators
|
|
+a three^five == 3*3*3*3*3
|
|
+a three*five == 15
|
|
+a 15 / 2 == 7
|
|
+a 15.0 / 2 == 7.5
|
|
+a 15.0 DIV 2.0 == 7
|
|
+a 17 % 3 == 2
|
|
+a 3 << 3 == 24
|
|
+a -5 >> 2 == -2
|
|
+a 24 >> 3 == 3
|
|
+a -1 >> 3 == -1
|
|
+a 24 >>> 3 == 3
|
|
+a five + three == 8
|
|
+a five - three == 2
|
|
+a 2*3 == 1+5
|
|
+a 2<=3
|
|
+a 2<=2
|
|
+a 2<3
|
|
+a 3>=3
|
|
+a 3>=2
|
|
+a 3>2
|
|
+a 2!=3
|
|
+a (abcdef & $a0c0e0) == $a0c0e0
|
|
+a (abcdef | $ff0001) == $ffcdef
|
|
; +a ($aa eor $55) == $ff
|
|
+a ($aa xor $55) == $ff
|
|
|
|
; priorities
|
|
+a 3 + 4 * 5 == 23
|
|
+a 4 * 5 + 3 == 23
|
|
+a 4.1 * 5.1 + 3.1 > 23.1
|
|
|
|
+a (15 or 3 xor 5) == (15 or (3 xor 5))
|
|
+a (15 or 3 xor 5) != ((15 or 3) xor 5)
|
|
|
|
+a (15 xor 3 and 5) == (15 xor (3 and 5))
|
|
+a (15 xor 3 and 5) != ((15 xor 3) and 5)
|
|
|
|
+a (5 and 3 == 3) == (5 and (3 == 3))
|
|
+a (5 and 3 == 3) != ((5 and 3) == 3)
|
|
|
|
+a (1 == 2 != 0) == (1 == (2 != 0))
|
|
+a (1 == 2 != 0) != ((1 == 2) != 0)
|
|
|
|
+a (0 != 3 < 2) == (0 != (3 < 2))
|
|
+a (0 != 3 < 2) != ((0 != 3) < 2)
|
|
|
|
; < and > comparisons have the same priority, so this actually checks left-associativity:
|
|
+a (3 <= 3 > 0) == ((3 <= 3) > 0)
|
|
+a (3 <= 3 > 0) != (3 <= (3 > 0))
|
|
|
|
+a (<257 > 1) == ((<257) > 1)
|
|
+a (<257 > 1) != (<(257 > 1))
|
|
|
|
+a (<256 >> 4) == (<(256 >> 4))
|
|
+a (<256 >> 4) != ((<256) >> 4)
|
|
|
|
; shifts have the same priority, so this actually checks left-associativity:
|
|
+a (16 >>> 2 >> 1) == ((16 >>> 2) >> 1)
|
|
+a (16 >>> 2 >> 1) != (16 >>> (2 >> 1))
|
|
+a (16 >> 2 << 1) == ((16 >> 2) << 1)
|
|
+a (16 >> 2 << 1) != (16 >> (2 << 1))
|
|
+a (8 << 4 >>> 2) == ((8 << 4) >>> 2)
|
|
+a (8 << 4 >>> 2) != (8 << (4 >>> 2))
|
|
|
|
+a (3 >> 1 + 5) == (3 >> (1 + 5))
|
|
+a (3 >> 1 + 5) != ((3 >> 1) + 5)
|
|
|
|
; + and - have the same priority, so this actually checks left-associativity:
|
|
+a (3 - 5 + 7) == ((3 - 5) + 7)
|
|
+a (3 - 5 + 7) != (3 - (5 + 7))
|
|
|
|
; test left-associativity
|
|
+a 11-5-3 == 3
|
|
+a 11-5-3 != 9
|
|
|
|
+a (3 + 5 * 7) == (3 + (5 * 7))
|
|
+a (3 + 5 * 7) != ((3 + 5) * 7)
|
|
|
|
; *, /, DIV and MOD have the same priority, so this actually checks left-associativity:
|
|
+a (7 * 5 MOD 7) == ((7 * 5) MOD 7)
|
|
+a (7 * 5 MOD 7) != (7 * (5 MOD 7))
|
|
|
|
+a (-14 + 5) == ((-14) + 5)
|
|
+a (-14 + 5) != (-(14 + 5))
|
|
|
|
+a (-3^2) == -(3^2)
|
|
+a (-3^2) != (-3)^2
|
|
; test right-associativity
|
|
+a 2^3^4 == 2^(3^4)
|
|
+a 2^3^4 != (2^3)^4
|
|
|
|
+a NOT 3 ^ 5 == ((NOT 3) ^ 5)
|
|
+a NOT 3 ^ 5 != (NOT (3 ^ 5))
|
|
|
|
+a int(3 + 4) + .8 == (int(3 + 4) + .8)
|
|
+a int(3 + 4) + .8 != int((3 + 4) + .8)
|
|
|
|
+a 3*(4+5)+7 == (3*(4+5))+7
|
|
+a 3*(4+5)+7 != 3*((4+5)+7)
|
|
|
|
; test dyadics with different arg types
|
|
; int/int
|
|
+a 3 ^ 2 == 9
|
|
+a 3 * 2 == 6
|
|
+a 6 / 2 == 3
|
|
+a 5 DIV 2 == 2
|
|
+a 3 + 2 == 5
|
|
+a 6 - 4 == 2
|
|
+a 2 <= 3
|
|
+a 2 < 3
|
|
+a 3 >= 2
|
|
+a 3 > 2
|
|
+a 2 != 3
|
|
+a 2 == 2
|
|
+a 5 MOD 2 == 1
|
|
+a 5 >>> 1 == 2
|
|
+a (5 & 1) == 1
|
|
+a (5 | 2) == 7
|
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