Skip to content

Commit 92ffe75

Browse files
committed
basic: move identifier char detection to separate function
1 parent 7e5ed42 commit 92ffe75

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

parsers/basic.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ static KeyWord basic_keywords[] = {
8181
* FUNCTION DEFINITIONS
8282
*/
8383

84+
static bool isIdentChar (char c)
85+
{
86+
return c && !isspace (c) && c != '(' && c != ',' && c != '=';
87+
}
88+
8489
/* Match the name of a dim or const starting at pos. */
8590
static void extract_dim (char const *pos, BasicKind kind)
8691
{
@@ -120,7 +125,7 @@ static void extract_dim (char const *pos, BasicKind kind)
120125
pos++;
121126
}
122127

123-
for (; *pos && !isspace (*pos) && *pos != '(' && *pos != ',' && *pos != '='; pos++)
128+
for (; isIdentChar (*pos); pos++)
124129
vStringPut (name, *pos);
125130
makeSimpleTag (name, kind);
126131

@@ -141,7 +146,7 @@ static void extract_dim (char const *pos, BasicKind kind)
141146
break; /* break if we are in a comment */
142147

143148
vStringClear (name);
144-
for (; *pos && !isspace (*pos) && *pos != '(' && *pos != ',' && *pos != '='; pos++)
149+
for (; isIdentChar (*pos); pos++)
145150
vStringPut (name, *pos);
146151
makeSimpleTag (name, kind);
147152
}
@@ -153,7 +158,7 @@ static void extract_dim (char const *pos, BasicKind kind)
153158
static void extract_name (char const *pos, BasicKind kind)
154159
{
155160
vString *name = vStringNew ();
156-
for (; *pos && !isspace (*pos) && *pos != '(' && *pos != ',' && *pos != '='; pos++)
161+
for (; isIdentChar (*pos); pos++)
157162
vStringPut (name, *pos);
158163
makeSimpleTag (name, kind);
159164
vStringDelete (name);

0 commit comments

Comments
 (0)