Skip to content

Commit 7fc597e

Browse files
committed
Simplify the parser by making the end-of-line rule skip comments.
1 parent 1145a34 commit 7fc597e

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

src/actions.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ ok: clc
173173
cmp #$9b ; Atari EOL
174174
beq E_REM::ok
175175
cmp #$27 ; "'" starts a comment
176-
beq E_REM::ok
176+
beq E_REM::loop
177177
cmp #':' ; ':' separates commands
178178
beq E_REM::ok
179179
xit: sec

src/basic.syn

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,13 +680,9 @@ PARSE_LINE_ASSIGN:
680680
VAR_FP_LVALUE_SADDR EQUAL FP_EXPR emit TOK_FP_STORE
681681
#@endif FASTBASIC_FP
682682

683-
SKIP_COMMENT:
684-
"'" E_REM
685-
E_EOL
686-
687683
PARSE_START: statement or variable assignment
688-
PARSE_LINE_COMMAND SKIP_COMMENT
689-
SKIP_COMMENT
690-
PARSE_LINE_ASSIGN SKIP_COMMENT
684+
E_EOL
685+
PARSE_LINE_COMMAND E_EOL
686+
PARSE_LINE_ASSIGN E_EOL
691687

692688
# vi:syntax=perl

src/compiler/parser.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,6 @@ bool SMB_E_NUMBER_BYTE(parse &s)
125125
return true;
126126
}
127127

128-
bool SMB_E_EOL(parse &s)
129-
{
130-
s.debug("E_EOL");
131-
s.skipws();
132-
return( s.eos() || s.peek('\'') || s.peek(':') || s.eol() );
133-
}
134-
135128
bool SMB_E_CONST_STRING(parse &s)
136129
{
137130
s.debug("E_CONST_STRING");
@@ -158,6 +151,15 @@ bool SMB_E_REM(parse &s)
158151
return true;
159152
}
160153

154+
bool SMB_E_EOL(parse &s)
155+
{
156+
s.debug("E_EOL");
157+
s.skipws();
158+
if( s.expect('\'') )
159+
return SMB_E_REM(s);
160+
return( s.eos() || s.peek(':') || s.eol() );
161+
}
162+
161163
bool SMB_E_PUSH_VAR(parse &s)
162164
{
163165
// nothing to do!

0 commit comments

Comments
 (0)