annotate src/parse.s @ 140:86f6f3a71e60 default tip

Fix some bugs in tokenization/parsing routine
author William Astle <lost@l-w.ca>
date Tue, 16 Jul 2024 22:30:07 -0600
parents 5d4801c0566d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
4 ; This is the overall parsing package. It is responsible for converting the input source code into the internal byte
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
5 ; code.
132
917b4893bb3d Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents: 131
diff changeset
6 ;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
7 ; This version only converts keywords to token codes. Additional conversions will be done in future versions.
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
8 ;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
9 ; Enter with X pointing to the text to parse. The encoded result will be placed freestart. On return, X will point to
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
10 ; the encoded result and D will contain the length in bytes of the result, and C will be clear.
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
11 ;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
12 ; In the event that there is insufficient memory between freestart and the bottom of the stack, C will be set. This
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
13 ; routine does not immediately throw an "out of memory" error to allow the caller to clear up some memory and try
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
14 ; again.
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
15 ;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
16 ; Enter at parseto with U set to the encoding destination and Y set to one byte past the end of the destination buffer
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
17 ; to specify the destination. Defaults to encoding to the buffer between freestart and the bottom of the stack (with
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
18 ; headroom accounted for).
132
917b4893bb3d Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents: 131
diff changeset
19 ;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
20 ; The stuff below that has hard coded colon checks will eventually be replaced by more complete parsing.
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
21 parse ldu freestart ; default to the start of free memory for encoding
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
22 leay -stackheadroom,s ; set the top of free memory
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
23 parseto lda #1 ; flag to enable memory limit detection
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
24 pshs a,u,y ; save start and end addresses and OM error detection flag
140
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
25 leay -1,x ; put the input pointer somewhere less useful and back up one spot
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
26 parsea jsr parse_nextchar ; fetch an input character
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
27 bne parseb ; brif not end of input
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
28 parsez tfr u,d ; get current output pointer
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
29 subd 3,s ; now D is the length
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
30 leas 5,s ; clean up the stack
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
31 rts ; return - C will be clear from subd above
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
32 parseb jsr parse_wordtab ; look up a keyword and see if we have a match
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
33 bcs parsec ; brif no match - handle unknown stuff
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
34 tsta ; do we have a two byte token?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
35 bne parseq ; brif so - just stash it
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
36 cmpb #token_else ; ELSE?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
37 beq parsed ; brif so - gets a hidden statement separator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
38 cmpb #token_remabbr ; REM abbreviation?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
39 bne parsee ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
40 parsed lda #': ; add a statement separator before it
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
41 parseq bsr parseoutw ; output a word
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
42 bra parsef
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
43 parsee bsr parseout ; output the token code
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
44 parsef cmpb #token_remabbr ; REM abbreviation?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
45 beq parseg ; brif so
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
46 cmpb #token_rem ; Actual REM?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
47 bne parseh ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
48 parseg ldb ,y+ ; get current input character
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
49 beq parsez ; brif end of input
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
50 bsr parseout ; add unmodified characters to output
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
51 bra parseg ; keep going until end of input
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
52 parseh cmpb #token_data ; DATA command?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
53 bne parsea ; brif not - continue normal handling
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
54 clra ; flag for not skipping quoted string
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
55 parsei ldb ,y+ ; get input character
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
56 beq parsez ; brif end of input
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
57 cmpb #'" ; string delimiter?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
58 bne parsej ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
59 coma ; flip the quoted statement handler
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
60 parsej cmpb #': ; end of statement?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
61 bne parsek ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
62 tsta ; are we skipping them?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
63 bne parsek ; brif so
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
64 leay -1,y ; unconsume it
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
65 bra parsea ; we're done with DATA
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
66 parsek bsr parseout ; put the data value into the output
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
67 bra parsei ; go handle another character
140
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
68 parsec ldb ,y ; get back the current input in the right register
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
69 cmpb #'" ; did we encounter a quoted string?
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
70 bne parsel ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
71 bsr parseout ; output delimiter
140
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
72 parsem leay 1,y ; move to next input character
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
73 ldb ,y ; get string character
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
74 beq parsez ; brif end of input
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
75 bsr parseout ; output it
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
76 cmpb #'" ; end delimiter?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
77 bne parsem ; brif not - keep looking
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
78 bra parsea ; go handle more stuff
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
79 parsep cmpb #'0 ; is it a digit?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
80 blo parsen ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
81 cmpb #'9 ; is it still a digit?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
82 bls parseo ; brif so
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
83 parsel cmpb #'A ; is it a letter?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
84 blo parsen ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
85 cmpb #'Z ; is it still a letter (UC)?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
86 bls parseo ; brif so
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
87 cmpb #'a ; is it a lower case letter?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
88 blo parsen ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
89 cmpb #'z ; is it still a lower case letter?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
90 bhi parsen ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
91 parseo bsr parseout ; stash the character
140
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
92 leay 1,y ; move to next character
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
93 ldb ,y ; fetch next input
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
94 bne parsep ; brif not end of input
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
95 jmp parsez ; go handle end of input
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
96 parsen bsr parseout ; output unknown character (number, unknown token)
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
97 jmp parsea ; go handle more
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
98 parseoutw exg a,b ; do MSB
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
99 bsr parseout
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
100 exg a,b ; and then LSB (fall through)
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
101 parseout tst 2,s ; need to test for OM?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
102 beq parseout0 ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
103 cmpu 3,s ; did we run into the end of the buffer?
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
104 blo parseout0 ; brif not
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
105 coma ; set C for error
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
106 leas 7,s ; clean up stack
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
107 rts ; return to original caller
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
108 parseout0 stb ,u+ ; stash in buffer
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
109 rts
140
86f6f3a71e60 Fix some bugs in tokenization/parsing routine
William Astle <lost@l-w.ca>
parents: 139
diff changeset
110 parse_nextchar leay 1,y ; move to next input character
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
111 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
112 rts
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
113 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
114 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
115 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
116 blo parse_toupper0 ; brif not
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
117 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
118 bhi parse_toupper0 ; brif not
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
119 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
120 parse_toupper0 rts ; Z only set here if input was zero entering from parse_nextcharu
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
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
122 ; This routine parses tokens using the table at parse_wt. The table is structured as follows:
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
123 ;
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
124 ; * 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
125 ; * a sequence of entries consisting of a single byte matching character and a token code followed
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
126 ; by an optional sub table, structured exactly the same way. The token code is 2 bytes.
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
127 ;
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
128 ; 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
129 ;
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
130 ; 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
131 ; 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
132 ; 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
133 ;
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
134 ; 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
135 ; determined to be invalid and processing continues with the next entry.
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
136 parse_wordtab ldx #parse_wt ; point to main lookup table
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
137 skip2 ; move on into the main routine
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
138 parse_wordtab0 leas 3,s ; clean up stack for sub table handling
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
139 pshs a,x ; save input character and start of table
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
140 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
141 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
142 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
143 lda ,s ; get back input character
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
144 parse_wordtab1 leax 3,x ; move past this entry - this order to avoid Z effects from leax
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
145 cmpa -3,x ; does this entry match?
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
146 bne parse_wordtab4 ; brif not
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
147 ldd -2,x ; get the matched token code
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
148 cmpd #tokenf_eot ; is it indicating a sub table?
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 puls a,x,pc ; clean up stack and return
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
159 parse_wordtab4 lda -3,x ; get the match character
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
160 bmi parse_wordtab5 ; brif negative - lookahead fail
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
161 ldd -2,x ; get the token match
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
162 cmpd #tokenf_eot ; is there a sub table to skip?
123
5681cdada362 Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents: 121
diff changeset
163 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
164 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
165 parse_wordtab5 leay a,y ; move back the specified number of characters
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
166 ldd -2,x ; get the matched token
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
167 parse_wordtab6 sta ,s ; save MSB of match
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
168 clra ; clear carry to indicate match
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
169 puls a,x,pc ; clean up stack, restore return value 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
170 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ac183a519439 Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents: 125
diff changeset
171 ; 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
172 ; 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
173 ; 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
208 ; Definition of tokens used in the interpreter.
132
917b4893bb3d Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents: 131
diff changeset
209 ;
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
210 ; Each token is defined as follows:
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
211 ; parse_tokdefT <sym>[,<handler>]
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
212 ; where T is one of:
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
213 ; p: particle - utility tokens and definitions, starting at 0x00
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
214 ; c: command - a command keyword, starting at 0x80
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
215 ; f: function - a function keyword, start at 0x80 with a 0xFF prefix
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
216 ; n: token width specific number/code, but otherwise a particle; in this case, the code replaces <handler>
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
217 ;
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
218 ; <sym> is the base symbol name (such as "then" or "eot")
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
219 ; <handler> is the address of the execution handler routine of the natural token type (command or function)
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
220 ;
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
221 ; <handler> is optional for particles. If it is omitted for command or function tokens, it defaults to SNERROR.
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
222 *pragmapush list
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
223 *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
224 __toknump set 0
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
225 __toknumc set 0x80
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
226 __toknumf set 0x80
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_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
228 token_\1 equ __toknump
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
229 tokenf_\1 equ __toknump
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
230 __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
231 endm
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
232 parse_tokendefv macro noexpand
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
233 token_\1 equ \2
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
234 tokenf_\1 equ \2
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
235 endm
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
236 setstr __cmdexect=""
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
237 setstr __funcexect=""
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
238 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
239 token_\1 equ __toknumc
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
240 tokenf_\1 equ __toknumc
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
241 __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
242 ifstr ne,"{2}",""
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
243 setstr __cmdexect="%(__cmdexect)\tfdb {2}\n"
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
244 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
245 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
246 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
247 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
248 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
249 token_\1 equ __toknumf
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
250 tokenf_\1 equ 0xff00|__toknumf
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
251 __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
252 ifstr ne,"{2}",""
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
253 setstr __fnexect="%(__fnexect)\tfdb {2}\n"
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
254 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
255 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
256 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
257 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
258 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
259 *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
260 *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
261 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
262 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
263 *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
264 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
265 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
266 *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
267 *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
268 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
269 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
270 *pragmapop nolist
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
271 endm
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
272 *pragmapop list
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
273 ; special tokens
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
274 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
275 parse_tokendefp eot ; End of input marker or special handling in word tables
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
276 ; command (and simple non-command keywords)
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
277 parse_tokendefc remabbr ; abbreviated REM (')
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
278 parse_tokendefc rem ; REM
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
279 parse_tokendefc return ; RETURN
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
280 parse_tokendefc run ; RUN
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
281 parse_tokendefc data ; DATA
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
282 parse_tokendefc end ; END
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
283 parse_tokendefc stop ; STOP
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
284 parse_tokendefc let ; LET
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
285 parse_tokendefc list ; LIST
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
286 parse_tokendefc new ; NEW
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
287 parse_tokendefc print ; PRINT
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
288 parse_tokendefc pop ; POP
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
289 parse_tokendefc goto ; GOTO
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
290 parse_tokendefc gosub ; GOSUB
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
291 parse_tokendefc go ; GO
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
292 parse_tokendefc times ; times (multiplication) operator (*)
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
293 parse_tokendefc plus ; addition operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
294 parse_tokendefc divide ; division operator (/)
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
295 parse_tokendefc minus ; subtraction operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
296 parse_tokendefc exp ; exponentiation operator (^)
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
297 parse_tokendefc lt ; less than operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
298 parse_tokendefc le ; less than or equal operateor
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
299 parse_tokendefc gt ; greater than operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
300 parse_tokendefc ge ; greater than or equal operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
301 parse_tokendefc eq ; equality operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
302 parse_tokendefc ne ; inequality operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
303 parse_tokendefc not ; boolean NOT operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
304 parse_tokendefc and ; boolean AND operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
305 parse_tokendefc or ; boolean OR operator
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
306 parse_tokendefc else ; ELSE
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
307 parse_tokendefc then ; THEN
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
308 parse_tokendefc to ; TO
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
309 parse_tokendefc sub ; SUB
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
310 parse_tokendefc as ; AS
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
311 ; secondary tokens (functions)
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
312 parse_tokendeff asc ; ASC()
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
313 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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 ; 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
315 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
316 exectab_fn token_fnexec
139
5d4801c0566d Get things building again with the updated tokenization scheme
William Astle <lost@l-w.ca>
parents: 132
diff changeset
317
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff changeset
318 *pragmapop list