Skip to content

Commit 5401af0

Browse files
rdipardonyamatongwe
authored andcommitted
#349 Add initial tests for the Forth lexer
1 parent 77f793c commit 5401af0

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
\ SCE_FORTH_DEFAULT=0
2+
3+
4+
\ SCE_FORTH_COMMENT=1
5+
\ line comment
6+
7+
\ SCE_FORTH_COMMENT_ML=2
8+
( stream comment )
9+
10+
\ SCE_FORTH_IDENTIFIER=3
11+
FOO
12+
13+
\ SCE_FORTH_CONTROL=4
14+
DO
15+
LOOP
16+
17+
\ SCE_FORTH_KEYWORD=5
18+
.S
19+
2DUP
20+
CR
21+
22+
\ SCE_FORTH_DEFWORD=6
23+
: WORD ;
24+
25+
\ SCE_FORTH_PREWORD1=7
26+
POSTPONE WORD
27+
28+
\ SCE_FORTH_PREWORD2=8
29+
INCLUDE S" module.forth"
30+
31+
\ SCE_FORTH_NUMBER=9
32+
$7F
33+
%01111111
34+
127
35+
36+
\ SCE_FORTH_STRING=10
37+
." Hello, world."
38+
ABORT" Aborting..."
39+
40+
\ SCE_FORTH_LOCALE=11
41+
{ local-var }
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
0 400 0 \ SCE_FORTH_DEFAULT=0
2+
0 400 0
3+
0 400 0
4+
0 400 0 \ SCE_FORTH_COMMENT=1
5+
0 400 0 \ line comment
6+
0 400 0
7+
0 400 0 \ SCE_FORTH_COMMENT_ML=2
8+
0 400 0 ( stream comment )
9+
0 400 0
10+
0 400 0 \ SCE_FORTH_IDENTIFIER=3
11+
0 400 0 FOO
12+
0 400 0
13+
0 400 0 \ SCE_FORTH_CONTROL=4
14+
0 400 0 DO
15+
0 400 0 LOOP
16+
0 400 0
17+
0 400 0 \ SCE_FORTH_KEYWORD=5
18+
0 400 0 .S
19+
0 400 0 2DUP
20+
0 400 0 CR
21+
0 400 0
22+
0 400 0 \ SCE_FORTH_DEFWORD=6
23+
0 400 0 : WORD ;
24+
0 400 0
25+
0 400 0 \ SCE_FORTH_PREWORD1=7
26+
0 400 0 POSTPONE WORD
27+
0 400 0
28+
0 400 0 \ SCE_FORTH_PREWORD2=8
29+
0 400 0 INCLUDE S" module.forth"
30+
0 400 0
31+
0 400 0 \ SCE_FORTH_NUMBER=9
32+
0 400 0 $7F
33+
0 400 0 %01111111
34+
0 400 0 127
35+
0 400 0
36+
0 400 0 \ SCE_FORTH_STRING=10
37+
0 400 0 ." Hello, world."
38+
0 400 0 ABORT" Aborting..."
39+
0 400 0
40+
0 400 0 \ SCE_FORTH_LOCALE=11
41+
0 400 0 { local-var }
42+
0 400 0
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{1}\ SCE_FORTH_DEFAULT=0{0}
2+
3+
4+
{1}\ SCE_FORTH_COMMENT=1{0}
5+
{1}\ line comment{0}
6+
7+
{1}\ SCE_FORTH_COMMENT_ML=2{0}
8+
{2}( stream comment ){0}
9+
10+
{1}\ SCE_FORTH_IDENTIFIER=3{0}
11+
{3}FOO{0}
12+
13+
{1}\ SCE_FORTH_CONTROL=4{0}
14+
{4}DO{0}
15+
{4}LOOP{0}
16+
17+
{1}\ SCE_FORTH_KEYWORD=5{0}
18+
{5}.S{0}
19+
{5}2DUP{0}
20+
{5}CR{0}
21+
22+
{1}\ SCE_FORTH_DEFWORD=6{0}
23+
{6}: WORD{0} {6};{0}
24+
25+
{1}\ SCE_FORTH_PREWORD1=7{0}
26+
{7}POSTPONE{0} {3}WORD{0}
27+
28+
{1}\ SCE_FORTH_PREWORD2=8{0}
29+
{8}INCLUDE{0} {10}S" module.forth"{0}
30+
31+
{1}\ SCE_FORTH_NUMBER=9{0}
32+
{9}$7F{0}
33+
{9}%01111111{0}
34+
{9}127{0}
35+
36+
{1}\ SCE_FORTH_STRING=10{0}
37+
{10}." Hello, world."{0}
38+
{10}ABORT" Aborting..."{0}
39+
40+
{1}\ SCE_FORTH_LOCALE=11{0}
41+
{11}{ local-var }{0}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
lexer.*.forth=forth
2+
keywords.*.forth=begin do else if loop +loop repeat then until while
3+
keywords2.*.forth=! @ . .s >in ?dup 2@ 2! 2dup 2drop 2over 2swap bye cr dup drop emit over rot space swap
4+
keywords3.*.forth=: ;
5+
keywords4.*.forth=['] ascii char compile postpone to with
6+
keywords5.*.forth=include require
7+
keywords6.*.forth=" ." abort" c" s" z"

0 commit comments

Comments
 (0)