misc: more syntax tests.

master
John Benediktsson 2020-08-14 13:22:34 -07:00
parent d535b62f50
commit 5176b270d2
1 changed files with 28 additions and 16 deletions

View File

@ -29,6 +29,7 @@
DEFER: word DEFER: word
FORGET: word FORGET: word
POSTPONE: word POSTPONE: word
SLOT: name
! Classes ! Classes
@ -84,8 +85,8 @@ drop ! wrong
GENERIC#: word 1 ! comment GENERIC#: word 1 ! comment
drop ! wrong drop ! wrong
MATH: + ( x y -- z ) foldable flushable MATH: + ( x y -- z ) foldable flushable
SLOT: name
C: <foo> foo C: <foo> foo
CONSTRUCTOR: <circle> circle ( radius -- obj ) ;
! Private definitions ! Private definitions
@ -103,7 +104,6 @@ drop ! wrong
HOOK: word variable ( stack -- effect ) HOOK: word variable ( stack -- effect )
GENERIC#: word 1 ( stack -- effect ) GENERIC#: word 1 ( stack -- effect )
MATH: + ( x y -- z ) foldable flushable MATH: + ( x y -- z ) foldable flushable
SLOT: name
C: <foo> foo C: <foo> foo
PRIVATE> PRIVATE>
@ -128,8 +128,6 @@ PRIVATE>
SYMBOL: word SYMBOL: word
SYMBOLS: words ... ; SYMBOLS: words ... ;
C: <foo> foo
! Math ! Math
1 2 + 1 2 +
@ -227,16 +225,35 @@ PRIVATE>
{ CHAR: c CHAR: H } { CHAR: c CHAR: H }
{ CHAR: d CHAR: C } { CHAR: d CHAR: C }
! New number literals: ! Bin
0b10101
0B10101
! Oct
0o432
0O1234567
0o1234567
0o7
! Hex
0xCAFEBABE 0xCAFEBABE
0o432 0XCAFEBABE
0b10101 0x1AB4p30
! Dec
1,000 1,000
10,000 10,000
! Float
1e10 1e10
-1.5e-5 -1.5e-5
! Weird numbers ! Weird numbers
1,234+56/78 1,234+56/78
@ -250,17 +267,12 @@ PRIVATE>
-1.5e30 -1.5e30
1.5e-30 1.5e-30
1,000.1,2 1,000.1,2
0XCAFEBABE
0x1AB4p30
0B10101
0O1234567
NAN: CAFE1234 0,. ! third token wrong NAN: CAFE1234 0,. ! third token wrong
0,. ! wrong, next line also wrong 0,. ! wrong, next line also wrong
0,. 0,.
NAN: ! ff 0xff comment NAN: ! ff 0xff comment
xCAFE1234 ! wrong xCAFE1234 ! wrong
ff ! shouldn't match as a hex number ff ! shouldn't match as a hex number
0o7
NAN: 0 NAN: 0
drop drop
NAN: ! NAN: !
@ -269,9 +281,13 @@ PRIVATE>
NAN: NAN:
f, f,
NAN: ALKSJDflKJ ! XXX: should error
! Not numbers ! Not numbers
,0.1
.
-.
1foo 1foo
1.5bar 1.5bar
+foo +foo
@ -321,7 +337,6 @@ boolean -- q: boolean )
flushablething flushablething
flushable flushable
<PRIVATEfoo <PRIVATEfoo
"asdf"foo "asdf"foo
<< 5 1 + . >> 1 << 5 1 + . >> 1
@ -335,7 +350,6 @@ pair?
tail? tail?
0.1 0.1
,0.1 ! wrong
10,0.1 10,0.1
1.23 1.23
.1 .1
@ -343,8 +357,6 @@ tail?
-0.1 -0.1
-0,1.1 -0,1.1
1. 1.
. ! other
-. ! other
! Numeral comma separator parsing (!: wrong, ~: other): ! Numeral comma separator parsing (!: wrong, ~: other):
! int ! int