Lines Matching refs:l

45 void bc_lex_invalidChar(BcLex *l, char c) {  in bc_lex_invalidChar()  argument
46 l->t = BC_LEX_INVALID; in bc_lex_invalidChar()
47 bc_lex_verr(l, BC_ERR_PARSE_CHAR, c); in bc_lex_invalidChar()
50 void bc_lex_lineComment(BcLex *l) { in bc_lex_lineComment() argument
51 l->t = BC_LEX_WHITESPACE; in bc_lex_lineComment()
52 while (l->i < l->len && l->buf[l->i] != '\n') l->i += 1; in bc_lex_lineComment()
55 void bc_lex_comment(BcLex *l) { in bc_lex_comment() argument
58 const char *buf = l->buf; in bc_lex_comment()
62 l->i += 1; in bc_lex_comment()
63 l->t = BC_LEX_WHITESPACE; in bc_lex_comment()
65 for (i = l->i; !end; i += !end) { in bc_lex_comment()
70 l->i = i; in bc_lex_comment()
71 bc_lex_err(l, BC_ERR_PARSE_COMMENT); in bc_lex_comment()
77 l->i = i + 2; in bc_lex_comment()
78 l->line += nlines; in bc_lex_comment()
81 void bc_lex_whitespace(BcLex *l) { in bc_lex_whitespace() argument
83 l->t = BC_LEX_WHITESPACE; in bc_lex_whitespace()
84 for (c = l->buf[l->i]; c != '\n' && isspace(c); c = l->buf[++l->i]); in bc_lex_whitespace()
87 void bc_lex_commonTokens(BcLex *l, char c) { in bc_lex_commonTokens() argument
88 if (!c) l->t = BC_LEX_EOF; in bc_lex_commonTokens()
89 else if (c == '\n') l->t = BC_LEX_NLINE; in bc_lex_commonTokens()
90 else bc_lex_whitespace(l); in bc_lex_commonTokens()
93 static size_t bc_lex_num(BcLex *l, char start, bool int_only) { in bc_lex_num() argument
95 const char *buf = l->buf + l->i; in bc_lex_num()
123 bc_vec_push(&l->str, &c); in bc_lex_num()
129 void bc_lex_number(BcLex *l, char start) { in bc_lex_number() argument
131 l->t = BC_LEX_NUMBER; in bc_lex_number()
133 bc_vec_popAll(&l->str); in bc_lex_number()
134 bc_vec_push(&l->str, &start); in bc_lex_number()
136 l->i += bc_lex_num(l, start, false); in bc_lex_number()
140 char c = l->buf[l->i]; in bc_lex_number()
145 if (BC_IS_POSIX) bc_lex_err(l, BC_ERR_POSIX_EXP_NUM); in bc_lex_number()
148 bc_vec_push(&l->str, &c); in bc_lex_number()
149 l->i += 1; in bc_lex_number()
150 c = l->buf[l->i]; in bc_lex_number()
153 bc_vec_push(&l->str, &c); in bc_lex_number()
154 l->i += 1; in bc_lex_number()
155 c = l->buf[l->i]; in bc_lex_number()
159 bc_lex_verr(l, BC_ERR_PARSE_CHAR, c); in bc_lex_number()
161 l->i += bc_lex_num(l, 0, true); in bc_lex_number()
166 bc_vec_pushByte(&l->str, '\0'); in bc_lex_number()
169 void bc_lex_name(BcLex *l) { in bc_lex_name() argument
172 const char *buf = l->buf + l->i - 1; in bc_lex_name()
175 l->t = BC_LEX_NAME; in bc_lex_name()
179 bc_vec_string(&l->str, i, buf); in bc_lex_name()
182 l->i += i - 1; in bc_lex_name()
185 void bc_lex_init(BcLex *l) { in bc_lex_init() argument
187 assert(l != NULL); in bc_lex_init()
188 bc_vec_init(&l->str, sizeof(char), NULL); in bc_lex_init()
191 void bc_lex_free(BcLex *l) { in bc_lex_free() argument
193 assert(l != NULL); in bc_lex_free()
194 bc_vec_free(&l->str); in bc_lex_free()
197 void bc_lex_file(BcLex *l, const char *file) { in bc_lex_file() argument
198 assert(l != NULL && file != NULL); in bc_lex_file()
199 l->line = 1; in bc_lex_file()
203 void bc_lex_next(BcLex *l) { in bc_lex_next() argument
205 assert(l != NULL); in bc_lex_next()
207 l->last = l->t; in bc_lex_next()
208 l->line += (l->i != 0 && l->buf[l->i - 1] == '\n'); in bc_lex_next()
210 if (BC_ERR(l->last == BC_LEX_EOF)) bc_lex_err(l, BC_ERR_PARSE_EOF); in bc_lex_next()
212 l->t = BC_LEX_EOF; in bc_lex_next()
214 if (l->i == l->len) return; in bc_lex_next()
219 vm.next(l); in bc_lex_next()
220 } while (l->t == BC_LEX_WHITESPACE); in bc_lex_next()
223 void bc_lex_text(BcLex *l, const char *text) { in bc_lex_text() argument
224 assert(l != NULL && text != NULL); in bc_lex_text()
225 l->buf = text; in bc_lex_text()
226 l->i = 0; in bc_lex_text()
227 l->len = strlen(text); in bc_lex_text()
228 l->t = l->last = BC_LEX_INVALID; in bc_lex_text()
229 bc_lex_next(l); in bc_lex_text()