Skip to content

Commit

Permalink
Merge pull request #2886 from dkearns/improve-basic-support
Browse files Browse the repository at this point in the history
Improve BASIC support
  • Loading branch information
masatake authored Apr 5, 2021
2 parents 068a16f + 5ada465 commit 8933d0f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions Units/parser-basic.r/basic-labels.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repeat input.bas /^repeat:$/;" l
7 changes: 7 additions & 0 deletions Units/parser-basic.r/basic-labels.d/input.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
' This is not a label:
REM This is not a label:

repeat:
PRINT "Going 'round again"
GOTO repeat
END
File renamed without changes.
File renamed without changes.
11 changes: 10 additions & 1 deletion parsers/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ static void findBasicTags (void)
if (!*p)
continue;

/* REM comment? */
if (strncasecmp (p, "REM", 3) == 0 &&
(isspace (*(p + 3)) || *(p + 3) == '\0'))
continue;

/* Single-quote comment? */
if (*p == '\'')
continue;

/* In Basic, keywords always are at the start of the line. */
for (kw = keywords; kw->token; kw++)
if (match_keyword (p, kw)) break;
Expand All @@ -187,7 +196,7 @@ static void findBasicTags (void)

parserDefinition *BasicParser (void)
{
static char const *extensions[] = { "bas", "bi", "bb", "pb", NULL };
static char const *extensions[] = { "bas", "bi", "bm", "bb", "pb", NULL };
parserDefinition *def = parserNew ("Basic");
def->kindTable = BasicKinds;
def->kindCount = ARRAY_SIZE (BasicKinds);
Expand Down

0 comments on commit 8933d0f

Please sign in to comment.