Mercurial > hg > index.cgi
annotate src/parse.s @ 131:95f174bf459b
Add error handling for immediate mode loop
author | William Astle <lost@l-w.ca> |
---|---|
date | Sat, 18 May 2024 00:41:46 -0600 |
parents | 9f23ddc5165f |
children | 917b4893bb3d |
rev | line source |
---|---|
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1 *pragmapush list |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
2 *pragma list |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
4 ; This is the overall parsing package. This is responsible for converting program text into the internal byte code and |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
5 ; reporting any syntax errors and anything else reasonably detectable at parse time without having overly complicated |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
6 ; code analysis. In almost all cases, the returned error will be a syntax error. |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
7 ; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
8 ; This is a recursive descent parser. |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
9 ; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
10 ; Entry: |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
11 ; X Points to the text to encode |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
12 ; B Nonzero to prevent generating any output (error check/length calculation only) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
13 ; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
14 ; Exit: |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
15 ; U Points to the encoded line |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
16 ; D Length of the encoded line |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
17 ; CC.C clear |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
18 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
19 ; Error Exit: |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
20 ; B Error code |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
21 ; U Offset to error input |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
22 ; CC.C set |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
23 parse_errorsn ldb #err_sn |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
24 parse_error lds parse_stackptr ; restore the original stack pointer so we can call from down stack |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
25 puls u ; get back original free pointer |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
26 stu freestart ; deallocate any allocated result |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
27 ldu parse_tokenst ; get start location of the token where the error was raised |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
28 coma ; make sure C is set for error |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
29 rts |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
30 parse stb parse_noout ; save no-output flag |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
31 leay ,x ; save input pointer in a less useful register |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
32 ldu freestart ; point to start of free memory where we will build the output |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
33 pshs u ; save original free memory location |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
34 sts parse_stackptr ; save the stack pointer for bailing out on errors |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
35 parse_nextstmt jsr parse_nexttok ; fetch the next token, return type in D |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
36 bcs parse_error ; brif we failed at parsing a token |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
37 parse0 ldx #parsetab_cmd ; point to jump table for token type handler |
127
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
38 cmpb #token_stmtsep ; is it a statement separator? |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
39 beq parse_nextstmt ; brif so - we can just skip it |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
40 parse1 cmpb ,x ; did we match a valid command token? |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
41 beq parse3 ; brif so |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
42 leax 3,x ; move to next entry |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
43 cmpx #parsetab_cmde ; end of table? |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
44 blo parse1 ; brif not |
131
95f174bf459b
Add error handling for immediate mode loop
William Astle <lost@l-w.ca>
parents:
130
diff
changeset
|
45 bra parse_errorsn ; fell off the end |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
46 parse3 jsr [1,x] ; call the handler |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
47 bcs parse_error ; brif the handler indicated error |
127
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
48 bsr parse_curtoken ; fetch the token we left off on |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
49 cmpb #token_eot ; end of input? |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
50 bne parse4 ; brif not |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
51 ldb #bc_eol ; stash an end of line op |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
52 bsr parse_write |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
53 bcs parse_error ; brif we errored out writing to the result (OM?) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
54 tfr u,d ; calculate the length of the result |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
55 subd ,s |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
56 puls u,pc ; get pointer to start of encoded result and return (C is already clear) |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
57 parse4 cmpb #token_stmtsep ; statement separator? |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
58 beq parse_nextstmt ; brif so - do another statement |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
59 cmpb #token_remabbr ; ' token? |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
60 beq parse0 ; brif so - parse it as a new statement |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
61 bra parse_errorsn ; raise a syntax error |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
62 parse_write lda parse_noout ; are we doing output? |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
63 beq parse_write0 ; brif so |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
64 leau 1,u ; just count up the output and don't do anything |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
65 rts |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
66 parse_write0 leax -stackheadroom,s ; calculate bottom of stack with headroom |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
67 cmpx freestart ; did the stack run into the end of the output? |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
68 bhs parse_write1 ; brif not - we're good |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
69 ldb #err_om ; raise out of memory error, C already set from comparison |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
70 rts |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
71 parse_write1 stb ,u+ ; save output byte |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
72 stu freestart ; save new to of used memory |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
73 list_noop |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
74 parse_noop rts ; return all clear - C clear from comparison above |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
75 parse_curtoken ldb parse_curtok ; fetch token code of current token |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
76 rts |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
77 parse_tokerr comb ; flag error - unexpected token |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
78 ldb #err_sn ; raise syntax error |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
79 rts |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
80 parse_nextchar lda ,y ; at end of input already? |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
81 beq parse_curchar ; brif so |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
82 leay 1,y ; move to next input character |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
83 parse_curchar lda ,y ; fetch input character |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
84 rts |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
85 parse_nexttok bsr parse_curchar ; fetch current input |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
86 beq parse_nexttok1 ; brif end of input |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
87 parse_nexttok0 cmpa #0x20 ; space? |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
88 bne parse_nexttok2 ; brif not |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
89 bsr parse_nextchar ; eat the space |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
90 bne parse_nexttok0 ; brif not end of input |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
91 parse_nexttok1 ldb #token_eot ; flag end of input |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
92 bra parse_nexttok6 ; go return it |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
93 parse_nexttok2 sty parse_tokenst ; save start of current token after skipping spaces |
124
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
94 bsr parse_toupper ; make sure we have upper case letters for matching |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
95 ldx #parse_wt ; point to keyword parsing table |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
96 jsr parse_wordtab ; go see if we have a match in the keyword table |
124
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
97 bcc parse_nexttok6 ; brif we do - return it |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
98 ldy parse_tokenst ; return to the start of the token - pointer probably clobbered |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
99 bsr parse_curchar ; get back input character (may have been clobbered) |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
100 cmpa #'. ; leading decimal? |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
101 beq parse_nexttok3 ; brif so - parse number |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
102 cmpa #'0 ; is it a digit |
124
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
103 blo parse_nexttok10 ; brif not |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
104 cmpa #'9 ; is it still a digit? |
124
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
105 bhi parse_nexttok10 ; brif not |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
106 parse_nexttok3 jmp parse_number ; go parse a number |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
107 parse_nexttok6 stb parse_curtok ; save token type |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
108 leay 1,y ; eat the input character |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
109 clra ; clear C to indicate no error (and clear Z also) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
110 rts |
124
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
111 parse_nexttok10 cmpa #'A ; is it alpha? |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
112 blo parse_nexttok11 ; brif not |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
113 cmpa #'Z ; is it still alpha? |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
114 bls parse_nexttok12 ; brif so |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
115 parse_nexttok11 comb ; flag error - unrecognized token |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
116 ldb #token_error |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
117 rts |
124
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
118 parse_nexttok12 bsr parse_nextcharu ; fetch next input character |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
119 cmpa #'0 ; is it alphanumeric? |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
120 blo parse_nexttok13 ; brif not |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
121 cmpa #'9 ; is it numeric? |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
122 bls parse_nexttok12 ; brif so - keep skipping it |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
123 cmpa #'A ; is it alpha? |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
124 blo parse_nexttok13 ; brif not |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
125 cmpa #'Z ; is it still alpha? |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
126 bls parse_nexttok12 ; brif so - keep skipping it |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
127 parse_nexttok13 tfr y,d ; calculate length of identifier |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
128 subd parse_tokenst |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
129 std val0+val.strlen ; save it for reference |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
130 ldb #token_ident ; indicate an identifier (variable name, etc.) |
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
131 rts ; return result (C will be clear from SUBD above) |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
132 parse_nextcharu bsr parse_nextchar ; fetch next input character |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
133 beq parse_toupper0 ; brif end of input |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
134 parse_toupper cmpa #'a ; is it lower case alpha? |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
135 blo parse_toupper0 ; brif not |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
136 cmpa #'z ; is it still lower case alpha? |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
137 bhi parse_toupper0 ; brif not |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
138 suba #0x20 ; adjust to upper case alpha |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
139 parse_toupper0 rts ; Z only set here if input was zero entering from parse_nextcharu |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
140 parse_iseos cmpa #token_stmtsep ; end of statement? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
141 beq parse_iseos0 ; brif so |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
142 cmpa #token_eot ; end of text? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
143 parse_iseos0 rts |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
144 parse_number jmp parse_tokerr |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
145 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
127
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
146 ; Parse a statement that consists of just the command token |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
147 parse_cmdsingle equ parse_write ; just write the token out and bail |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
148 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
149 ; Parse a REM or ' statement. We just copy the comment out after the REM or ' token. |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
150 parse_rem jsr parse_write ; write the token/character out |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
151 ldb ,y+ ; get next input character |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
152 bne parse_rem ; brif not at the end of the input |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
153 ldb #token_eot ; flag end of input for mainline parser |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
154 stb parse_curtok |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
155 rts ; return, pass back the C result from parse_write |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
156 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
157 ; Parse an optional line number range which may be [lineno][-[lineno]] |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
158 parse_range jsr parse_write ; output the token |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
159 jsr parse_nexttok ; fetch input token |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
160 ldx zero ; set default start and end line numbers - whole program |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
161 leau -1,x |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
162 pshs x,u |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
163 bsr parse_iseos ; are there arguments? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
164 beq parse_range3 ; brif so |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
165 cmpa #token_int32 ; is it an integer (line number)? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
166 bne parse_range0 ; brif not |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
167 ldd val0+val.int ; is the upper 16 bits set? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
168 beq parse_rangee ; brif yes - we have an error |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
169 ldd val0+val.int+2 ; set the start line number |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
170 std ,s |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
171 jsr parse_nexttok ; see what's after the line number |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
172 parse_range0 cmpa #token_minus ; do we have a range? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
173 beq parse_range1 ; brif so |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
174 bsr parse_iseos ; end of statement? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
175 bne parse_rangee ; brif not - error |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
176 ldd ,s ; set end line to start line |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
177 std 2,s |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
178 bra parse_range3 ; go output things |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
179 parse_range1 jsr parse_nexttok ; skip the - |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
180 bsr parse_iseos ; end of statement? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
181 beq parse_range3 ; brif so |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
182 cmpa #token_int32 ; is it an integer? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
183 bne parse_rangee ; brif not |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
184 ldx val0+val.int ; upper 16 bits set? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
185 bne parse_rangee ; brif so - invalid number |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
186 ldx val0+val.int+2 ; get end line number |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
187 stx 2,s ; save end line number |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
188 cmpx ,s ; is end line lower than start line? |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
189 blo parse_rangee ; brif so - error |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
190 parse_range3 puls a ; write out the range |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
191 jsr parse_write |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
192 puls a |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
193 jsr parse_write |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
194 puls a |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
195 jsr parse_write |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
196 puls a |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
197 jmp parse_write |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
198 parse_rangee jmp parse_errorsn ; go raise the parse error |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
200 ; This routine parses tokens using the table at parse_wordtab. The table is structured as follows: |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
201 ; |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
202 ; * two bytes which contain the length of the table less the two bytes for this length value |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
203 ; * a sequence of entries consisting of a single byte matching character and a token code followed |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
204 ; by an optional sub table, structured exactly the same way. |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
205 ; |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
206 ; The optional subtable will be present if the token code is token_eot |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
207 ; |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
208 ; If the character match is negative, it means a lookahead failed. The negative value is the number |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
209 ; of characters to unget and the token code is the token value to return. No other entries after this |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
210 ; in a table will be considered since thie negative match is a global match. |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
211 ; |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
212 ; When a token_eot match is found, if there are no further characters in the input, the match is |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
213 ; determined to be invalid and processing continues with the next entry. |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
214 parse_wordtab0 leas 3,s ; clean up stack for sub table handling |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
215 parse_wordtab pshs a,x ; save input character and start of table |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
216 ldd ,x++ ; get length of this table |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
217 addd 1,s ; calculate the address of the end of the table |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
218 std 1,s ; save end address for comparison later |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
219 lda ,s ; get back input character |
125
0607e4e20702
Correct offset error for keyword table lookup
William Astle <lost@l-w.ca>
parents:
124
diff
changeset
|
220 parse_wordtab1 ldb 1,x ; fetch token code for this entry |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
221 cmpa ,x++ ; does this entry match? |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
222 bne parse_wordtab4 ; brif not |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
223 cmpb #token_eot ; is it indicating a sub table? |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
224 bne parse_wordtab6 ; brif not |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
225 jsr parse_nextcharu ; fetch next input character (for sub table match) |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
226 bne parse_wordtab0 ; brif we are going to check the sub table |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
227 parse_wordtab2 ldd ,x ; fetch length of sub table |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
228 leax d,x ; move past sub table |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
229 parse_wordtab3 lda ,s ; get back input character |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
230 cmpx 1,s ; are we at the end of the table? |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
231 blo parse_wordtab1 ; brif not - check another entry |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
232 comb ; indicate no match |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
233 puls a,x,pc ; clean up stack and return |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
234 parse_wordtab4 lda -2,x ; get the match character |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
235 bmi parse_wordtab5 ; brif negative - lookahead fail |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
236 cmpb #token_eot ; is there a sub table to skip? |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
237 beq parse_wordtab2 ; brif so - skip sub table |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
238 bra parse_wordtab3 ; otherwise just move to the next entry |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
239 parse_wordtab5 leay a,y ; move back the specified number of characters |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
240 parse_wordtab6 clra ; clear C to indicate a match |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
241 puls a,x,pc ; clean up stack and return |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
242 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
243 ; Convert a token number back to its keyword. This will use the same table used by parse_wordtab. Enter with a character |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
244 ; output routine pointer in U which takes the character in A. The routine can assume that Y is preserved. Will return |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
245 ; with C set if the token does not exist in the word table and clear otherwise. |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
246 parse_wtdc pshs u ; save routine pointer |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
247 ldu #strbuff+20 ; point to temporary string buffer |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
248 clr ,-u ; put a NUL at the end of the string |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
249 ldx #parse_wt ; point to keyword parse table |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
250 bsr parse_wtdc2 ; call the tree walker function |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
251 bcc parse_wtdc1 ; brif we do have a match |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
252 puls u,pc ; clean stack and return |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
253 parse_wtdc0 jsr [,s] ; output the character |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
254 parse_wtdc1 lda ,u+ ; get output byte |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
255 bne parse_wtdc0 ; brif we're not at the end yet |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
256 clra ; make sure C is clear |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
257 puls u,pc ; clean stack and return |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
258 parse_wtdc2 pshs a,x ; save the token match value and the table pointer |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
259 ldd ,x++ ; get table length |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
260 addd 1,s ; calculate end address |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
261 std 1,s ; save it |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
262 parse_wtdc3 ldd ,x++ ; get this table entry |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
263 bmi parse_wtdc6 ; brif it's a backtracking entry - skip it |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
264 cmpa ,s ; does the token match here? |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
265 bne parse_wtdc5 ; brif not |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
266 parse_wtdc4 sta ,-y ; add the character to the output buffer |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
267 puls a,x,pc ; return up the call stack - C is clear from CMPA above |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
268 parse_wtdc5 cmpb #token_eot ; does this entry have a sub table? |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
269 bne parse_wtdc6 ; brif not |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
270 pshs a ; save the matched character |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
271 lda 1,s ; get back the token we need |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
272 bsr parse_wtdc2 ; go handle the sub table |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
273 puls a ; get back the matched character |
129
d5886daa4f65
Fix a less than brilliant branch target in token to keyword routine
William Astle <lost@l-w.ca>
parents:
127
diff
changeset
|
274 bcc parse_wtdc4 ; brif it did match - record it and return |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
275 parse_wtdc6 cmpx 1,s ; are we at the end of this table? |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
276 bne parse_wtdc3 ; brif not - handle another table entry |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
277 coma ; make sure C is set for no match |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
278 puls a,x,pc ; clean up stack and return |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
279 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
280 ; This table defines the various handler routines for the various bytecode tokens. Each token is defined as follows: |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
281 ; parse_tokdefT <sym>,<parse>,<list>,<exec> |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
282 ; where: |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
283 ; T: c for command, f for function, p for particle |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
284 ; <sym>: the symbol name without the "token_" prefix |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
285 ; <parse>: parse handler for the type, ignored for particles |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
286 ; <list>: list handler for the type, ingored for particles |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
287 ; <exec>: execution handler for the type, ignored for particles |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
288 *pragmapush list |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
289 *pragma nolist |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
290 __toknump set 0 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
291 __toknumc set 0x40 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
292 __toknumf set 0xc0 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
293 setstr __cmdparset="" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
294 setstr __cmdlistt="" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
295 setstr __cmdexect="" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
296 setstr __fnparset="" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
297 setstr __fnlistt="" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
298 setstr __fnexect="" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
299 parse_tokendefp macro noexpand |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
300 token_\1 equ __toknump |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
301 __toknump set __toknump+1 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
302 endm |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
303 parse_tokendefc macro noexpand |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
304 token_\1 equ __toknumc |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
305 __toknumc set __toknumc+1 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
306 ifstr ne,"{2}","" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
307 setstr __cmdparset="%(__cmdparset)\tfcb\ttoken_\1\n\tfdb {2}\n" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
308 endc |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
309 ifstr ne,"{3}","" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
310 setstr __cmdlistt="%(__cmdlistt)\tfcb\ttoken_\1\n\tfdb {3}\n" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
311 endc |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
312 ifstr ne,"{4}","" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
313 setstr __cmdexect="%(__cmdexect)\tfdb {3}\n" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
314 else |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
315 setstr __cmdexect="%(__cmdexect)\tfdb SNERROR\n" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
316 endc |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
317 endm |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
318 parse_tokendeff macro noexpand |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
319 token_\1 equ __toknumf |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
320 __toknumf set __toknumf+1 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
321 ifstr ne,"{2}","" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
322 setstr __fnparset="%(__fnparset)\tfcb\ttoken_\1\n\tfdb {2}\n" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
323 endc |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
324 ifstr ne,"{3}","" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
325 setstr __fnlistt="%(__fnlistt)\tfcb\ttoken_\1\n\tfdb {3}\n" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
326 endc |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
327 ifstr ne,"{4}","" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
328 setstr __fnexect="%(__fnexect)\tfdb {3}\n" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
329 else |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
330 setstr __fnexect="%(__fnexect)\tfdb SNERROR\n" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
331 endc |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
332 endm |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
333 token_cmdparse macro |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
334 *pragmapush nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
335 *pragma nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
336 includestr "%(__cmdparset)" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
337 *pragmapop nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
338 endm |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
339 token_cmdlist macro |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
340 *pragmapush nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
341 *pragma nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
342 includestr "%(__cmdlistt)" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
343 *pragmapop nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
344 endm |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
345 token_cmdexec macro |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
346 *pragmapush nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
347 *pragma nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
348 includestr "%(__cmdexect)" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
349 token__maxcmd equ __toknumc-1 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
350 *pragmapop nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
351 endm |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
352 token_fnparse macro |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
353 *pragmapush nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
354 *pragma nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
355 includestr "%(__fnparset)" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
356 *pragmapop nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
357 endm |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
358 token_fnlist macro |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
359 *pragmapush nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
360 *pragma nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
361 includestr "%(__fnlistt)" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
362 *pragmapop nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
363 endm |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
364 token_fnexec macro |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
365 *pragmapush nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
366 *pragma nolist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
367 includestr "%(__fnexect)" |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
368 token__maxfn equ __toknumf-1 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
369 *pragmapop nolist |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
370 endm |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
371 *pragmapop list |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
372 parse_tokendefp error ; Used to mark errors; should always be first so it's token #0 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
373 parse_tokendefp eot ; End of input marker or special handling in word tables |
130
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
374 parse_tokendefp int32 ; 32 bit integer (has special parsing) |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
375 parse_tokendefp float ; floating point value (has special parsing) |
9f23ddc5165f
Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents:
129
diff
changeset
|
376 parse_tokendefp ident ; identifier (has special parsing) |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
377 parse_tokendefp stmtsep ; statement separator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
378 parse_tokendefp times ; times (multiplication) operator (*) |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
379 parse_tokendefp plus ; addition operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
380 parse_tokendefp divide ; division operator (/) |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
381 parse_tokendefp minus ; subtraction operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
382 parse_tokendefp exp ; exponentiation operator (^) |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
383 parse_tokendefp lt ; less than operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
384 parse_tokendefp le ; less than or equal operateor |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
385 parse_tokendefp gt ; greater than operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
386 parse_tokendefp ge ; greater than or equal operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
387 parse_tokendefp eq ; equality operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
388 parse_tokendefp ne ; inequality operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
389 parse_tokendefp not ; boolean NOT operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
390 parse_tokendefp and ; boolean AND operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
391 parse_tokendefp or ; boolean OR operator |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
392 parse_tokendefp bang ; exclamation mark |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
393 parse_tokendefp hash ; number sign |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
394 parse_tokendefp dollar ; dollar sign (string sigil) |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
395 parse_tokendefp percent ; percent sign (integer sigil) |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
396 parse_tokendefp amp ; ampersand |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
397 parse_tokendefp oparen ; opening paren |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
398 parse_tokendefp cparen ; closing paren |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
399 parse_tokendefp sep ; comma (separator) |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
400 parse_tokendefp semi ; semicolon |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
401 parse_tokendefp at ; @ symbol |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
402 parse_tokendefp else ; ELSE |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
403 parse_tokendefp then ; THEN |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
404 parse_tokendefp to ; TO |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
405 parse_tokendefp sub ; SUB |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
406 parse_tokendefp as ; AS |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
407 |
127
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
408 parse_tokendefc remabbr,parse_rem,list_noop,exec_noop ; abbreviated REM (') |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
409 parse_tokendefc rem,parse_rem,list_noop,exec_noop ; REM |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
410 parse_tokendefc return,parse_cmdsingle,parse_noop,parse_noop ; RETURN |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
411 parse_tokendefc run,parse_noop,parse_noop,parse_noop ; RUN |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
412 parse_tokendefc data,parse_noop,parse_noop,parse_noop ; DATA |
127
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
413 parse_tokendefc end,parse_cmdsingle,parse_noop,parse_noop ; END |
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
414 parse_tokendefc stop,parse_cmdsingle,parse_noop,parse_noop ; STOP |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
415 parse_tokendefc let,parse_noop,parse_noop,parse_noop ; LET |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
416 parse_tokendefc list,parse_noop,parse_noop,parse_noop ; LIST |
127
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
417 parse_tokendefc new,parse_cmdsingle,parse_noop,parse_noop ; NEW |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
418 parse_tokendefc print,parse_noop,parse_noop,parse_noop ; PRINT |
127
527212870064
Add parsing routines for bare commands and REM statements
William Astle <lost@l-w.ca>
parents:
126
diff
changeset
|
419 parse_tokendefc pop,parse_cmdsingle,parse_noop,parse_noop ; POP |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
420 parse_tokendefc goto,parse_noop,parse_noop,parse_noop ; GOTO |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
421 parse_tokendefc gosub,parse_noop,parse_noop,parse_noop ; GOSUB |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
422 parse_tokendefc go,parse_noop,parse_noop,parse_noop ; GO |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
423 |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
424 parse_tokendeff asc,parse_noop,parse_noop,parse_noop ; ASC() |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
425 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
426 ; Parse handling tables |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
427 parsetab_cmd token_cmdparse |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
428 parsetab_cmde |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
429 parsetab_fn token_fnparse |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
430 parsetab_fne |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
431 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
432 ; List handling tables |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
433 listtab_cmd token_cmdlist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
434 listtab_cmde |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
435 listtab_fn token_fnlist |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
436 listtab_fne |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
437 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
438 ; Execution handling tables |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
439 exectab_cmd token_cmdexec |
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
125
diff
changeset
|
440 exectab_fn token_fnexec |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
441 *pragmapop list |