Skip to content

Commit 3e0e90e

Browse files
authored
Merge pull request #243 from boriel/feature/allow_extra_chars
Feature/allow extra chars
2 parents 9e8ed06 + ee64cc4 commit 3e0e90e

7 files changed

Lines changed: 60 additions & 3 deletions

File tree

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ply==3.10
1+
ply==3.11
22
six
33

tests/functional/extra_chars.asm

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
#line 1
14+
`mylabel:
15+
ld a, #0
16+
#line 3
17+
ld hl, 0
18+
ld b, h
19+
ld c, l
20+
__END_PROGRAM:
21+
di
22+
ld hl, (__CALL_BACK__)
23+
ld sp, hl
24+
exx
25+
pop hl
26+
exx
27+
pop iy
28+
pop ix
29+
ei
30+
ret
31+
__CALL_BACK__:
32+
DEFW 0
33+
ZXBASIC_USER_DATA:
34+
; Defines DATA END --> HEAP size is 0
35+
ZXBASIC_USER_DATA_END:
36+
; Defines USER DATA Length in bytes
37+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
38+
END

tests/functional/extra_chars.bas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
ASM
3+
`mylabel:
4+
ld a, #0
5+
END ASM
6+

tests/functional/extra_chars1.bas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
REM This should fail because it's used in BASIC context
3+
4+
LET `a = 1
5+
6+

tests/functional/test_errmsg.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ fornextopt2.bas:4: warning: FOR start value is lower than end. This FOR loop is
109109
atoloduplbl.asm:3: label '.SetSubScreen' already defined at line 2
110110
>>> process_file('asmerror2.asm')
111111
asmerror2.asm:2: Error: illegal preprocessor character '@'
112+
asmerror2.asm:2: illegal character '#'
112113
asmerror2.asm:2: Syntax error. Unexpected end of line [NEWLINE]
113114
>>> process_file('llb.bas')
114115
llb.bas:3: Undeclared function "f$"

zxbasmpplex.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def t_INITIAL_CHAR(self, t):
105105
return t
106106

107107
def t_INITIAL_TOKEN(self, t):
108-
r"[][%',.:$()*/<>~&|+^-]"
108+
r"[][%'`,.:$()*/<>~&|+^-]"
109109
return t
110110

111111
def t_prepro_define_defargs_defargsopt_defexpr_pragma_NEWLINE(self, t):
@@ -250,6 +250,9 @@ def t_INIIAL_sharp(self, t):
250250
r'\#' # Only matches if at beginning of line and "#"
251251
if t.value == '#' and self.find_column(t) == 1:
252252
t.lexer.push_state('prepro') # Start preprocessor
253+
else:
254+
t.type = 'TOKEN'
255+
return t
253256

254257
def t_defexpr_TOKEN(self, t):
255258
r'=>|<=|>=|<>|[@:.<>^=+*/&|%-]'

zxbpplex.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def t_asm_CHAR(self, t):
122122
return t
123123

124124
def t_asm_TOKEN(self, t):
125-
r"[]['.:$*/+<>|&~%^-]"
125+
r"[]['`.:$*/+<>|&~%^-]"
126126
return t
127127

128128
def t_INITIAL_CONTINUE(self, t):
@@ -331,6 +331,9 @@ def t_INITIAL_asm_sharp(self, t):
331331
if self.find_column(t) == 1:
332332
t.lexer.push_state('prepro') # Start preprocessor
333333
self.expectingDirective = True
334+
else:
335+
t.type = 'TOKEN'
336+
return t
334337

335338
def t_INITIAL_defexpr_TOKEN(self, t):
336339
r'=>|<=|>=|<>|[$!&|~@:;{}.<>^=+*/%-]'

0 commit comments

Comments
 (0)