Lines Matching refs:l

46 bc_lex_invalidChar(BcLex* l, char c)  in bc_lex_invalidChar()  argument
48 l->t = BC_LEX_INVALID; in bc_lex_invalidChar()
49 bc_lex_verr(l, BC_ERR_PARSE_CHAR, c); in bc_lex_invalidChar()
53 bc_lex_lineComment(BcLex* l) in bc_lex_lineComment() argument
55 l->t = BC_LEX_WHITESPACE; in bc_lex_lineComment()
56 while (l->i < l->len && l->buf[l->i] != '\n') in bc_lex_lineComment()
58 l->i += 1; in bc_lex_lineComment()
63 bc_lex_comment(BcLex* l) in bc_lex_comment() argument
70 l->i += 1; in bc_lex_comment()
71 l->t = BC_LEX_WHITESPACE; in bc_lex_comment()
78 buf = l->buf; in bc_lex_comment()
87 for (i = l->i; !end; i += !end) in bc_lex_comment()
100 if (!vm->eof && l->mode != BC_MODE_FILE) in bc_lex_comment()
102 got_more = bc_lex_readLine(l); in bc_lex_comment()
118 l->i = i; in bc_lex_comment()
119 bc_lex_err(l, BC_ERR_PARSE_COMMENT); in bc_lex_comment()
122 l->i = i + 2; in bc_lex_comment()
123 l->line += nlines; in bc_lex_comment()
127 bc_lex_whitespace(BcLex* l) in bc_lex_whitespace() argument
131 l->t = BC_LEX_WHITESPACE; in bc_lex_whitespace()
134 for (c = l->buf[l->i]; c != '\n' && isspace(c); c = l->buf[++l->i]) in bc_lex_whitespace()
141 bc_lex_commonTokens(BcLex* l, char c) in bc_lex_commonTokens() argument
143 if (!c) l->t = BC_LEX_EOF; in bc_lex_commonTokens()
144 else if (c == '\n') l->t = BC_LEX_NLINE; in bc_lex_commonTokens()
145 else bc_lex_whitespace(l); in bc_lex_commonTokens()
156 bc_lex_num(BcLex* l, char start, bool int_only) in bc_lex_num() argument
158 const char* buf = l->buf + l->i; in bc_lex_num()
199 bc_vec_push(&l->str, &c); in bc_lex_num()
206 bc_lex_number(BcLex* l, char start) in bc_lex_number() argument
208 l->t = BC_LEX_NUMBER; in bc_lex_number()
211 bc_vec_popAll(&l->str); in bc_lex_number()
212 bc_vec_push(&l->str, &start); in bc_lex_number()
215 l->i += bc_lex_num(l, start, false); in bc_lex_number()
219 char c = l->buf[l->i]; in bc_lex_number()
226 if (BC_IS_POSIX) bc_lex_err(l, BC_ERR_POSIX_EXP_NUM); in bc_lex_number()
230 bc_vec_push(&l->str, &c); in bc_lex_number()
231 l->i += 1; in bc_lex_number()
232 c = l->buf[l->i]; in bc_lex_number()
237 bc_vec_push(&l->str, &c); in bc_lex_number()
238 l->i += 1; in bc_lex_number()
239 c = l->buf[l->i]; in bc_lex_number()
245 bc_lex_verr(l, BC_ERR_PARSE_CHAR, c); in bc_lex_number()
249 l->i += bc_lex_num(l, 0, true); in bc_lex_number()
254 bc_vec_pushByte(&l->str, '\0'); in bc_lex_number()
258 bc_lex_name(BcLex* l) in bc_lex_name() argument
261 const char* buf = l->buf + l->i - 1; in bc_lex_name()
264 l->t = BC_LEX_NAME; in bc_lex_name()
273 bc_vec_string(&l->str, i, buf); in bc_lex_name()
276 l->i += i - 1; in bc_lex_name()
280 bc_lex_init(BcLex* l) in bc_lex_init() argument
283 assert(l != NULL); in bc_lex_init()
284 bc_vec_init(&l->str, sizeof(char), BC_DTOR_NONE); in bc_lex_init()
288 bc_lex_free(BcLex* l) in bc_lex_free() argument
291 assert(l != NULL); in bc_lex_free()
292 bc_vec_free(&l->str); in bc_lex_free()
296 bc_lex_file(BcLex* l, const char* file) in bc_lex_file() argument
298 assert(l != NULL && file != NULL); in bc_lex_file()
299 l->line = 1; in bc_lex_file()
304 bc_lex_next(BcLex* l) in bc_lex_next() argument
308 assert(l != NULL); in bc_lex_next()
310 l->last = l->t; in bc_lex_next()
313 l->line += (l->i != 0 && l->buf[l->i - 1] == '\n'); in bc_lex_next()
316 if (BC_ERR(l->last == BC_LEX_EOF)) bc_lex_err(l, BC_ERR_PARSE_EOF); in bc_lex_next()
318 l->t = BC_LEX_EOF; in bc_lex_next()
321 if (l->i == l->len) return; in bc_lex_next()
327 vm->next(l); in bc_lex_next()
329 while (l->t == BC_LEX_WHITESPACE); in bc_lex_next()
340 bc_lex_fixText(BcLex* l, const char* text, size_t len) in bc_lex_fixText() argument
342 l->buf = text; in bc_lex_fixText()
343 l->len = len; in bc_lex_fixText()
347 bc_lex_readLine(BcLex* l) in bc_lex_readLine() argument
356 switch (l->mode) in bc_lex_readLine()
393 bc_lex_fixText(l, vm->buffer.v, vm->buffer.len - 1); in bc_lex_readLine()
399 bc_lex_text(BcLex* l, const char* text, BcMode mode) in bc_lex_text() argument
403 assert(l != NULL && text != NULL); in bc_lex_text()
405 bc_lex_fixText(l, text, strlen(text)); in bc_lex_text()
406 l->i = 0; in bc_lex_text()
407 l->t = l->last = BC_LEX_INVALID; in bc_lex_text()
408 l->mode = mode; in bc_lex_text()
410 bc_lex_next(l); in bc_lex_text()