Mercurial > hg > index.cgi
comparison src/parse.s @ 127:527212870064
Add parsing routines for bare commands and REM statements
author | William Astle <lost@l-w.ca> |
---|---|
date | Tue, 09 Jan 2024 22:47:11 -0700 |
parents | ac183a519439 |
children | d5886daa4f65 |
comparison
equal
deleted
inserted
replaced
126:ac183a519439 | 127:527212870064 |
---|---|
29 parse_error puls u ; restore original free memory location - deallocate any encoding | 29 parse_error puls u ; restore original free memory location - deallocate any encoding |
30 stu freestart | 30 stu freestart |
31 ldu parse_tokenst ; get start location we started parsing the token at | 31 ldu parse_tokenst ; get start location we started parsing the token at |
32 rts ; return error condition | 32 rts ; return error condition |
33 parse0 ldx #parsetab_cmd ; point to jump table for token type handler | 33 parse0 ldx #parsetab_cmd ; point to jump table for token type handler |
34 cmpb #token_stmtsep ; is it a statement separator? | |
35 beq parse_nextstmt ; brif so - we can just skip it | |
34 parse1 cmpb ,x ; did we match a valid command token? | 36 parse1 cmpb ,x ; did we match a valid command token? |
35 beq parse3 ; brif so | 37 beq parse3 ; brif so |
36 leax 3,x ; move to next entry | 38 leax 3,x ; move to next entry |
37 cmpx #parsetab_cmde ; end of table? | 39 cmpx #parsetab_cmde ; end of table? |
38 blo parse1 ; brif not | 40 blo parse1 ; brif not |
39 parse2 ldb #err_sn ; flag syntax error | 41 parse2 ldb #err_sn ; flag syntax error |
40 bra parse_error ; and return the error | 42 bra parse_error ; and return the error |
41 parse3 jsr [1,x] ; call the handler | 43 parse3 jsr [1,x] ; call the handler |
42 bcs parse_error ; brif the handler indicated error | 44 bcs parse_error ; brif the handler indicated error |
43 jsr parse_curtoken ; get the token we terminated on | 45 bsr parse_curtoken ; fetch the token we left off on |
44 cmpb #token_eot ; end of input? | 46 cmpb #token_eot ; end of input? |
45 bne parse4 ; brif not | 47 bne parse4 ; brif not |
46 ldb #bc_eol ; stash an end of line op | 48 ldb #bc_eol ; stash an end of line op |
47 bsr parse_write | 49 bsr parse_write |
48 bcs parse_error ; brif we errored out writing to the result (OM?) | 50 bcs parse_error ; brif we errored out writing to the result (OM?) |
131 cmpa #'z ; is it still lower case alpha? | 133 cmpa #'z ; is it still lower case alpha? |
132 bhi parse_toupper0 ; brif not | 134 bhi parse_toupper0 ; brif not |
133 suba #0x20 ; adjust to upper case alpha | 135 suba #0x20 ; adjust to upper case alpha |
134 parse_toupper0 rts ; Z only set here if input was zero entering from parse_nextcharu | 136 parse_toupper0 rts ; Z only set here if input was zero entering from parse_nextcharu |
135 parse_number jmp parse_tokerr | 137 parse_number jmp parse_tokerr |
138 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
139 ; Parse a statement that consists of just the command token | |
140 parse_cmdsingle equ parse_write ; just write the token out and bail | |
141 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
142 ; Parse a REM or ' statement. We just copy the comment out after the REM or ' token. | |
143 parse_rem jsr parse_write ; write the token/character out | |
144 ldb ,y+ ; get next input character | |
145 bne parse_rem ; brif not at the end of the input | |
146 ldb #token_eot ; flag end of input for mainline parser | |
147 stb parse_curtok | |
148 rts ; return, pass back the C result from parse_write | |
136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 149 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
137 ; This routine parses tokens using the table at parse_wordtab. The table is structured as follows: | 150 ; This routine parses tokens using the table at parse_wordtab. The table is structured as follows: |
138 ; | 151 ; |
139 ; * two bytes which contain the length of the table less the two bytes for this length value | 152 ; * two bytes which contain the length of the table less the two bytes for this length value |
140 ; * a sequence of entries consisting of a single byte matching character and a token code followed | 153 ; * a sequence of entries consisting of a single byte matching character and a token code followed |
338 parse_tokendefp then ; THEN | 351 parse_tokendefp then ; THEN |
339 parse_tokendefp to ; TO | 352 parse_tokendefp to ; TO |
340 parse_tokendefp sub ; SUB | 353 parse_tokendefp sub ; SUB |
341 parse_tokendefp as ; AS | 354 parse_tokendefp as ; AS |
342 | 355 |
343 parse_tokendefc remabbr,parse_noop,list_noop,exec_noop ; abbreviated REM (') | 356 parse_tokendefc remabbr,parse_rem,list_noop,exec_noop ; abbreviated REM (') |
344 parse_tokendefc rem,parse_noop,list_noop,exec_noop ; REM | 357 parse_tokendefc rem,parse_rem,list_noop,exec_noop ; REM |
345 parse_tokendefc return,parse_noop,parse_noop,parse_noop ; RETURN | 358 parse_tokendefc return,parse_cmdsingle,parse_noop,parse_noop ; RETURN |
346 parse_tokendefc run,parse_noop,parse_noop,parse_noop ; RUN | 359 parse_tokendefc run,parse_noop,parse_noop,parse_noop ; RUN |
347 parse_tokendefc data,parse_noop,parse_noop,parse_noop ; DATA | 360 parse_tokendefc data,parse_noop,parse_noop,parse_noop ; DATA |
348 parse_tokendefc end,parse_noop,parse_noop,parse_noop ; END | 361 parse_tokendefc end,parse_cmdsingle,parse_noop,parse_noop ; END |
349 parse_tokendefc stop,parse_noop,parse_noop,parse_noop ; STOP | 362 parse_tokendefc stop,parse_cmdsingle,parse_noop,parse_noop ; STOP |
350 parse_tokendefc let,parse_noop,parse_noop,parse_noop ; LET | 363 parse_tokendefc let,parse_noop,parse_noop,parse_noop ; LET |
351 parse_tokendefc list,parse_noop,parse_noop,parse_noop ; LIST | 364 parse_tokendefc list,parse_noop,parse_noop,parse_noop ; LIST |
352 parse_tokendefc new,parse_noop,parse_noop,parse_noop ; NEW | 365 parse_tokendefc new,parse_cmdsingle,parse_noop,parse_noop ; NEW |
353 parse_tokendefc print,parse_noop,parse_noop,parse_noop ; PRINT | 366 parse_tokendefc print,parse_noop,parse_noop,parse_noop ; PRINT |
354 parse_tokendefc pop,parse_noop,parse_noop,parse_noop ; POP | 367 parse_tokendefc pop,parse_cmdsingle,parse_noop,parse_noop ; POP |
355 parse_tokendefc goto,parse_noop,parse_noop,parse_noop ; GOTO | 368 parse_tokendefc goto,parse_noop,parse_noop,parse_noop ; GOTO |
356 parse_tokendefc gosub,parse_noop,parse_noop,parse_noop ; GOSUB | 369 parse_tokendefc gosub,parse_noop,parse_noop,parse_noop ; GOSUB |
357 parse_tokendefc go,parse_noop,parse_noop,parse_noop ; GO | 370 parse_tokendefc go,parse_noop,parse_noop,parse_noop ; GO |
358 | 371 |
359 parse_tokendeff asc,parse_noop,parse_noop,parse_noop ; ASC() | 372 parse_tokendeff asc,parse_noop,parse_noop,parse_noop ; ASC() |