Kestrel-3

Check-in [9688a01a13]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:First parser integration test
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:9688a01a135b09ffd48de6c5141195087de9bceeb69cd57eb7dbb9084ec79e1f
User & Date: kc5tja 2019-09-02 23:11:13
Context
2019-09-03
01:29
Basic .dword primitive check-in: 0dda2d09e7 user: kc5tja tags: trunk
2019-09-02
23:11
First parser integration test check-in: 9688a01a13 user: kc5tja tags: trunk
22:27
Relocate tokens beyond ASCII/UTF-8 boundaries check-in: 82629340d1 user: kc5tja tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added dev/src/bcpl/assemrv/globals_parser.h.







>
>
>
1
2
3
GLOBAL {
	parse: g_parser;
}

Changes to dev/src/bcpl/assemrv/manifest.h.

12
13
14
15
16
17
18
19
20
21
22

23
24
25
26
27
28
29
..
73
74
75
76
77
78
79
80



81

    err_field        = 50000;		// Record field (n - err_field) not of expected value

    // Hunk format executables use these constants.
    HUNK_END         = 5000;
    HUNK_CODE;

    // Global Vector Constants
    g_sections       = ug + 200;
    g_dynvecs        = g_sections + 100;
    g_utils          = g_dynvecs + 100;
    g_scanner        = g_utils + 100;


    // Dynamic vector descriptors
    dv_length        = 0;
    dv_capacity;
    dv_default;
    dv_buf;
    dv_sizeof;
................................................................................
    scs_include;
    scs_file;
    scs_line;
    scs_gv;
    scs_gref;
    scs_integer;
    scs_endstreamch = endstreamch;
}












|



>







 







|
>
>
>
|
>
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
..
74
75
76
77
78
79
80
81
82
83
84
85
86
    err_field        = 50000;		// Record field (n - err_field) not of expected value

    // Hunk format executables use these constants.
    HUNK_END         = 5000;
    HUNK_CODE;

    // Global Vector Constants
    g_sections       = ug + 100;
    g_dynvecs        = g_sections + 100;
    g_utils          = g_dynvecs + 100;
    g_scanner        = g_utils + 100;
    g_parser         = g_scanner + 100;

    // Dynamic vector descriptors
    dv_length        = 0;
    dv_capacity;
    dv_default;
    dv_buf;
    dv_sizeof;
................................................................................
    scs_include;
    scs_file;
    scs_line;
    scs_gv;
    scs_gref;
    scs_integer;
    scs_endstreamch = endstreamch;

    // Intermediate Representation order codes
    IR_LIT = 1000;
    IR_DWORD;
}

Added dev/src/bcpl/assemrv/parser.b.













>
>
>
>
>
>
1
2
3
4
5
6
LET parse(s, d) BE {
	dynvec_put_at(d, IR_LIT, 0)
	dynvec_put_at(d, 1, 1)
	dynvec_put_at(d, IR_DWORD, 2)
}

Changes to dev/src/bcpl/assemrv/runtests.

19
20
21
22
23
24
25
26








echo "====== Scanner ======"
cintsys64 -c <<endcli
failat 20
bcpl from test_scanner.b to test_scanner
test_scanner
delete test_scanner
endcli

















>
>
>
>
>
>
>
>
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
echo "====== Scanner ======"
cintsys64 -c <<endcli
failat 20
bcpl from test_scanner.b to test_scanner
test_scanner
delete test_scanner
endcli

echo "====== Parser ======"
cintsys64 -c <<endcli
failat 20
bcpl from test_parser.b to test_parser
test_parser
delete test_parser
endcli

Added dev/src/bcpl/assemrv/test_parser.b.









































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
SECTION "utils"

GET "libhdr"
GET "manifest"
GET "globals_utils"
GET "utils.b"
.

SECTION "bud"

GET "libhdr"
GET "manifest"
GET "globals_bud"
GET "globals_utils"
GET "bud.b"
.

SECTION "scanner"

GET "libhdr"
GET "manifest"
GET "globals_utils"
GET "globals_scanner"
GET "scanner.b"
.

SECTION "dynvec"

GET "libhdr"
GET "manifest"
GET "globals_utils"
GET "globals_dynvec"
GET "dynvec.b"
.

SECTION "utils"

GET "libhdr"
GET "manifest"
GET "globals_utils"
GET "utils.b"
.

SECTION "parser"

GET "libhdr"
GET "manifest"
GET "globals_dynvec"
GET "globals_parser"
GET "parser.b"
.

SECTION "test_parser"

GET "libhdr"
GET "manifest"
GET "globals_bud"
GET "globals_dynvec"
GET "globals_scanner"
GET "globals_utils"
GET "globals_parser"


LET testlist() = VALOF {
	MANIFEST { ntests = 1 }
	LET tl = getvec(ntests)
	tl!0 := ntests
	tl!1 := test_single_dword
	RESULTIS tl
}


// Parser Tests: Simple listings

AND test_single_dword(r) = VALOF {
	LET err = failat
	LET scb, s, d = 0, 0, 0

	IF r DO RESULTIS r
	testid := "test_single_dword"

	scb := findinoutput("RAM:")
	UNLESS NEQ(scb, 0, 0) DO GOTO unwind
	{
		LET outs = output()
		selectoutput(scb)
		writef(".dword 1*n")
		selectoutput(outs)
		rewindstream(scb)
	}

	s := make_scanner()
	UNLESS NEQ(s, 0, 1) DO GOTO unwind
	UNLESS EQ(scanner_get_stream(s, scb, "RAM:"), TRUE, 3) DO GOTO unwind
	scanner_nextchar(s)
	scanner_next(s)

	d := make_dynvec()
	UNLESS NEQ(d, 0, 4) DO GOTO unwind

	parse(s, d)

	UNLESS EQ(d!dv_length, 3, 100) DO GOTO unwind
	UNLESS EQ(dynvec_at(d, 0), IR_LIT, 101) DO GOTO unwind
	UNLESS EQ(dynvec_at(d, 1), 1, 102) DO GOTO unwind
	UNLESS EQ(dynvec_at(d, 2), IR_DWORD, 103) DO GOTO unwind

	err := 0

unwind:
	IF d DO dynvec_free(d)
	IF s DO scanner_free(s)
	IF scb DO endstream(scb)
	RESULTIS err
}