Lines Matching refs:l
50 bc_lex_identifier(BcLex* l) in bc_lex_identifier() argument
54 const char* buf = l->buf + l->i - 1; in bc_lex_identifier()
71 l->t = BC_LEX_KW_AUTO + (BcLexType) i; in bc_lex_identifier()
75 if (!BC_LEX_KW_POSIX(kw)) bc_lex_verr(l, BC_ERR_POSIX_KW, kw->name); in bc_lex_identifier()
78 l->i += n - 1; in bc_lex_identifier()
86 bc_lex_name(l); in bc_lex_identifier()
90 if (BC_ERR(l->str.len - 1 > 1)) in bc_lex_identifier()
92 bc_lex_verr(l, BC_ERR_POSIX_NAME_LEN, l->str.v); in bc_lex_identifier()
102 bc_lex_string(BcLex* l) in bc_lex_string() argument
110 l->t = BC_LEX_STR; in bc_lex_string()
115 buf = l->buf; in bc_lex_string()
122 for (i = l->i; (c = buf[i]) && c != '"'; ++i) in bc_lex_string()
127 if (BC_ERR(c == '\0') && !vm->eof && l->mode != BC_MODE_FILE) in bc_lex_string()
129 got_more = bc_lex_readLine(l); in bc_lex_string()
137 l->i = i; in bc_lex_string()
138 bc_lex_err(l, BC_ERR_PARSE_STRING); in bc_lex_string()
142 len = i - l->i; in bc_lex_string()
143 bc_vec_string(&l->str, len, l->buf + l->i); in bc_lex_string()
145 l->i = i + 1; in bc_lex_string()
146 l->line += nlines; in bc_lex_string()
157 bc_lex_assign(BcLex* l, BcLexType with, BcLexType without) in bc_lex_assign() argument
159 if (l->buf[l->i] == '=') in bc_lex_assign()
161 l->i += 1; in bc_lex_assign()
162 l->t = with; in bc_lex_assign()
164 else l->t = without; in bc_lex_assign()
168 bc_lex_token(BcLex* l) in bc_lex_token() argument
173 char c = l->buf[l->i++], c2; in bc_lex_token()
188 bc_lex_commonTokens(l, c); in bc_lex_token()
195 bc_lex_assign(l, BC_LEX_OP_REL_NE, BC_LEX_OP_BOOL_NOT); in bc_lex_token()
198 if (l->t == BC_LEX_OP_BOOL_NOT) in bc_lex_token()
200 bc_lex_verr(l, BC_ERR_POSIX_BOOL, "!"); in bc_lex_token()
208 bc_lex_string(l); in bc_lex_token()
215 bc_lex_err(l, BC_ERR_POSIX_COMMENT); in bc_lex_token()
216 bc_lex_lineComment(l); in bc_lex_token()
222 bc_lex_assign(l, BC_LEX_OP_ASSIGN_MODULUS, BC_LEX_OP_MODULUS); in bc_lex_token()
228 c2 = l->buf[l->i]; in bc_lex_token()
234 bc_lex_verr(l, BC_ERR_POSIX_BOOL, "&&"); in bc_lex_token()
236 l->i += 1; in bc_lex_token()
237 l->t = BC_LEX_OP_BOOL_AND; in bc_lex_token()
239 else bc_lex_invalidChar(l, c); in bc_lex_token()
246 l->t = BC_LEX_OP_TRUNC; in bc_lex_token()
252 bc_lex_assign(l, BC_LEX_OP_ASSIGN_PLACES, BC_LEX_OP_PLACES); in bc_lex_token()
259 l->t = (BcLexType) (c - '(' + BC_LEX_LPAREN); in bc_lex_token()
265 bc_lex_assign(l, BC_LEX_OP_ASSIGN_MULTIPLY, BC_LEX_OP_MULTIPLY); in bc_lex_token()
271 c2 = l->buf[l->i]; in bc_lex_token()
276 l->i += 1; in bc_lex_token()
277 l->t = BC_LEX_OP_INC; in bc_lex_token()
279 else bc_lex_assign(l, BC_LEX_OP_ASSIGN_PLUS, BC_LEX_OP_PLUS); in bc_lex_token()
285 l->t = BC_LEX_COMMA; in bc_lex_token()
291 c2 = l->buf[l->i]; in bc_lex_token()
296 l->i += 1; in bc_lex_token()
297 l->t = BC_LEX_OP_DEC; in bc_lex_token()
299 else bc_lex_assign(l, BC_LEX_OP_ASSIGN_MINUS, BC_LEX_OP_MINUS); in bc_lex_token()
305 c2 = l->buf[l->i]; in bc_lex_token()
308 if (BC_LEX_NUM_CHAR(c2, true, false)) bc_lex_number(l, c); in bc_lex_token()
311 l->t = BC_LEX_KW_LAST; in bc_lex_token()
312 bc_lex_err(l, BC_ERR_POSIX_DOT); in bc_lex_token()
320 c2 = l->buf[l->i]; in bc_lex_token()
321 if (c2 == '*') bc_lex_comment(l); in bc_lex_token()
322 else bc_lex_assign(l, BC_LEX_OP_ASSIGN_DIVIDE, BC_LEX_OP_DIVIDE); in bc_lex_token()
367 bc_lex_number(l, c); in bc_lex_token()
373 l->t = BC_LEX_SCOLON; in bc_lex_token()
380 c2 = l->buf[l->i]; in bc_lex_token()
385 l->i += 1; in bc_lex_token()
386 bc_lex_assign(l, BC_LEX_OP_ASSIGN_LSHIFT, BC_LEX_OP_LSHIFT); in bc_lex_token()
390 bc_lex_assign(l, BC_LEX_OP_REL_LE, BC_LEX_OP_REL_LT); in bc_lex_token()
396 bc_lex_assign(l, BC_LEX_OP_REL_EQ, BC_LEX_OP_ASSIGN); in bc_lex_token()
403 c2 = l->buf[l->i]; in bc_lex_token()
408 l->i += 1; in bc_lex_token()
409 bc_lex_assign(l, BC_LEX_OP_ASSIGN_RSHIFT, BC_LEX_OP_RSHIFT); in bc_lex_token()
413 bc_lex_assign(l, BC_LEX_OP_REL_GE, BC_LEX_OP_REL_GT); in bc_lex_token()
420 l->t = (BcLexType) (c - '[' + BC_LEX_LBRACKET); in bc_lex_token()
427 if (BC_NO_ERR(l->buf[l->i] == '\n')) in bc_lex_token()
429 l->i += 1; in bc_lex_token()
430 l->t = BC_LEX_WHITESPACE; in bc_lex_token()
432 else bc_lex_invalidChar(l, c); in bc_lex_token()
438 bc_lex_assign(l, BC_LEX_OP_ASSIGN_POWER, BC_LEX_OP_POWER); in bc_lex_token()
469 bc_lex_identifier(l); in bc_lex_token()
476 l->t = (BcLexType) (c - '{' + BC_LEX_LBRACE); in bc_lex_token()
482 c2 = l->buf[l->i]; in bc_lex_token()
487 bc_lex_verr(l, BC_ERR_POSIX_BOOL, "||"); in bc_lex_token()
489 l->i += 1; in bc_lex_token()
490 l->t = BC_LEX_OP_BOOL_OR; in bc_lex_token()
492 else bc_lex_invalidChar(l, c); in bc_lex_token()
499 bc_lex_invalidChar(l, c); in bc_lex_token()