Fix dc comment handling
diff --git a/include/lex.h b/include/lex.h
index b6612fd..e397017 100644
--- a/include/lex.h
+++ b/include/lex.h
@@ -173,6 +173,7 @@
BcStatus bc_lex_next(BcLex *l);
void bc_lex_lineComment(BcLex *l);
+BcStatus bc_lex_comment(BcLex *l);
void bc_lex_whitespace(BcLex *l);
BcStatus bc_lex_number(BcLex *l, char start);
BcStatus bc_lex_name(BcLex *l);
diff --git a/src/bc/lex.c b/src/bc/lex.c
index a2d3556..f69521a 100644
--- a/src/bc/lex.c
+++ b/src/bc/lex.c
@@ -97,33 +97,6 @@
else l->t.t = without;
}
-BcStatus bc_lex_comment(BcLex *l) {
-
- size_t i, nlines = 0;
- const char *buf = l->buf;
- bool end = false;
- char c;
-
- l->t.t = BC_LEX_WHITESPACE;
-
- for (i = ++l->i; !end; i += !end) {
-
- for (c = buf[i]; c != '*' && c != 0; c = buf[++i]) nlines += c == '\n';
-
- if (c == 0 || buf[i + 1] == '\0') {
- l->i = i;
- return BC_STATUS_PARSE_NO_COMMENT_END;
- }
-
- end = buf[i + 1] == '/';
- }
-
- l->i = i + 2;
- l->line += nlines;
-
- return BC_STATUS_SUCCESS;
-}
-
BcStatus bc_lex_token(BcLex *l) {
BcStatus s = BC_STATUS_SUCCESS;
diff --git a/src/data.c b/src/data.c
index 2b0aaa1..25ed163 100644
--- a/src/data.c
+++ b/src/data.c
@@ -257,7 +257,7 @@
const BcLexType dc_lex_tokens[] = {
BC_LEX_OP_MODULUS, BC_LEX_INVALID, BC_LEX_INVALID, BC_LEX_LPAREN,
BC_LEX_INVALID, BC_LEX_OP_MULTIPLY, BC_LEX_OP_PLUS, BC_LEX_INVALID,
- BC_LEX_OP_MINUS, BC_LEX_INVALID, BC_LEX_OP_DIVIDE,
+ BC_LEX_OP_MINUS, BC_LEX_INVALID, BC_LEX_INVALID,
BC_LEX_INVALID, BC_LEX_INVALID, BC_LEX_INVALID, BC_LEX_INVALID,
BC_LEX_INVALID, BC_LEX_INVALID, BC_LEX_INVALID, BC_LEX_INVALID,
BC_LEX_INVALID, BC_LEX_INVALID,
diff --git a/src/dc/lex.c b/src/dc/lex.c
index 36048b9..fa77aab 100644
--- a/src/dc/lex.c
+++ b/src/dc/lex.c
@@ -142,6 +142,14 @@
break;
}
+ case '/':
+ {
+ if (l->buf[l->i] == '*') s = bc_lex_comment(l);
+ else l->t.t = BC_LEX_OP_DIVIDE;
+
+ break;
+ }
+
case '0':
case '1':
case '2':
diff --git a/src/lex.c b/src/lex.c
index f71854c..d62f509 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -35,6 +35,33 @@
--l->i;
}
+BcStatus bc_lex_comment(BcLex *l) {
+
+ size_t i, nlines = 0;
+ const char *buf = l->buf;
+ bool end = false;
+ char c;
+
+ l->t.t = BC_LEX_WHITESPACE;
+
+ for (i = ++l->i; !end; i += !end) {
+
+ for (c = buf[i]; c != '*' && c != 0; c = buf[++i]) nlines += c == '\n';
+
+ if (c == 0 || buf[i + 1] == '\0') {
+ l->i = i;
+ return BC_STATUS_PARSE_NO_COMMENT_END;
+ }
+
+ end = buf[i + 1] == '/';
+ }
+
+ l->i = i + 2;
+ l->line += nlines;
+
+ return BC_STATUS_SUCCESS;
+}
+
void bc_lex_whitespace(BcLex *l) {
char c;
l->t.t = BC_LEX_WHITESPACE;