summaryrefslogtreecommitdiff
path: root/programs/sub-suite/lexer.s
diff options
context:
space:
mode:
Diffstat (limited to 'programs/sub-suite/lexer.s')
-rw-r--r--programs/sub-suite/lexer.s48
1 files changed, 11 insertions, 37 deletions
diff --git a/programs/sub-suite/lexer.s b/programs/sub-suite/lexer.s
index 0d712ff..320a582 100644
--- a/programs/sub-suite/lexer.s
+++ b/programs/sub-suite/lexer.s
@@ -310,21 +310,7 @@ ptok_dqu:
lda #TOK_DQUOT ; Set the lexeme type to TOK_DQUOT.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_DQUOT.
-; lda.d ptr3 ; Get the address of the lexeme buffer.
- lda.q idx1 ; Get the index of the lexeme buffer.
- inc ; Increment it by one to get the size.
- jsr malloc ; Make a new string.
- ldb.q ptr3 ; Get the address of the lexeme buffer.
- ldy.q idx1 ; Get the size of the lexeme buffer + 1.
- iny ;
- jsr memcpy ; Copy the string in the lexeme buffer into the new string.
- sta.q t_str ; Save it in the token string.
- and #0 ; Reset A.
- tab ; Reset B.
- ldy.q idx0 ; Get the string index back.
-@end:
- jsr make_tok ; Create the token.
- rts ; End of parse_ptok.
+ bra copy_str ; Copy the string.
ptok_squ:
ldb #1 ; Make init_lex increment the string index.
jsr init_lex ; Initialize the lexeme buffer for copying.
@@ -337,23 +323,7 @@ ptok_squ:
lda #TOK_SQUOT ; Set the lexeme type to TOK_SQUOT.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_SQUOT.
- lda.q idx1 ; Get the index of the lexeme buffer.
- inc ; Increment it by one to get the size.
- jsr malloc ; Make a new string.
- ldb.q ptr3 ; Get the address of the lexeme buffer.
- ldy.q idx1 ; Get the size of the lexeme buffer + 1.
- iny ;
- jsr memcpy ; Copy the string in the lexeme buffer into the new string.
- sta.q t_str ; Save it in the token string.
- and #0 ; Reset A.
- tab ; Reset B.
- ldy.q idx0 ; Get the string index back.
-@end:
- jsr make_tok ; Create the token.
- rts ; End of parse_ptok.
-ptok_hash:
- inc.w idx0 ;
- rts ; End of parse_ptok.
+ bra copy_str ; Copy the string.
ptok_scol:
ldb #1 ; Make init_lex increment the string index.
jsr init_lex ; Initialize the lexeme buffer for copying.
@@ -365,12 +335,13 @@ ptok_scol:
lda #TOK_SCOLN ; Set the lexeme type to TOK_SCOLN.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_SCOLN.
- lda.q idx1 ; Get the index of the lexeme buffer.
- inc ; Increment it by one to get the size.
+copy_str:
+ lea d, (idx1) ; Get the index of the lexeme buffer.
+ inc d ; Increment it by one to get the size.
+ mov f, d ; Get the size of the lexeme buffer + 1.
jsr malloc ; Make a new string.
- ldb.q ptr3 ; Get the address of the lexeme buffer.
- ldy.q idx1 ; Get the size of the lexeme buffer + 1.
- iny ;
+ lea s, (ptr3) ; Get the address of the lexeme buffer.
+ mov d, a ; Get the pointer of the new string.
jsr memcpy ; Copy the string in the lexeme buffer into the new string.
sta.q t_str ; Save it in the token string.
and #0 ; Reset A.
@@ -379,6 +350,9 @@ ptok_scol:
@end:
jsr make_tok ; Create the token.
rts ; End of parse_ptok.
+ptok_hash:
+ inc.w idx0 ;
+ rts ; End of parse_ptok.
ptok_dolr:
lda #TOK_HEX ; Set the lexeme type to TOK_HEX.
sta lex_type ;