Skip to content

Commit 1440723

Browse files
authored
Merge pull request #517 from boriel/feature/allow_dot_in_init_names
Allow "." in INIT labels
2 parents e987a92 + 6e9a9b8 commit 1440723

4 files changed

Lines changed: 53 additions & 2 deletions

File tree

src/zxbpp/zxbasmpplex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def t_line_prepro_pragma_defargs_define_skip(self, t):
146146
pass # Ignore whitespaces and tabs
147147

148148
def t_prepro_ID(self, t):
149-
r'[_a-zA-Z][_a-zA-Z0-9]*' # preprocessor directives
149+
r'[._a-zA-Z][._a-zA-Z0-9]*' # preprocessor directives
150150
t.type = reserved_directives.get(t.value.lower(), 'ID')
151151
if t.type == 'DEFINE':
152152
t.lexer.begin('define')

src/zxbpp/zxbpplex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def t_if_LT(self, t):
223223
return t
224224

225225
def t_prepro_ID(self, t):
226-
r'[_a-zA-Z][_a-zA-Z0-9]*' # preprocessor directives
226+
r'[._a-zA-Z][._a-zA-Z0-9]*' # preprocessor directives
227227
t.type = reserved_directives.get(t.value.lower(), 'ID')
228228
states_ = {
229229
'DEFINE': 'define',

tests/functional/init_with_dot.asm

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
org 32768
2+
__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (__CALL_BACK__), hl
12+
ei
13+
call A_LABEL.DOT
14+
jp __MAIN_PROGRAM__
15+
__CALL_BACK__:
16+
DEFW 0
17+
ZXBASIC_USER_DATA:
18+
; Defines USER DATA Length in bytes
19+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
20+
.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN
21+
.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA
22+
ZXBASIC_USER_DATA_END:
23+
__MAIN_PROGRAM__:
24+
#line 3 "init_with_dot.bas"
25+
A_LABEL.DOT:
26+
#line 9 "init_with_dot.bas"
27+
ld hl, 0
28+
ld b, h
29+
ld c, l
30+
__END_PROGRAM:
31+
di
32+
ld hl, (__CALL_BACK__)
33+
ld sp, hl
34+
exx
35+
pop hl
36+
exx
37+
pop iy
38+
pop ix
39+
ei
40+
ret
41+
;; --- end of user code ---
42+
END

tests/functional/init_with_dot.bas

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
ASM
3+
4+
#init A_LABEL.DOT
5+
6+
A_LABEL.DOT:
7+
8+
END ASM
9+

0 commit comments

Comments
 (0)