return (lex->tok.ttype = TOKEN_OPERATOR);
}
- /* length operator */
- if (ch == 'l') {
- if ((nextch = lex_getch(lex)) == 'e') {
- if ((nextch = lex_getch(lex)) == 'n') {
- if ((nextch = lex_getch(lex)) == 'g') {
- if ((nextch = lex_getch(lex)) == 't') {
- if ((nextch = lex_getch(lex)) == 'h') {
- lex_tokench(lex, 'l');
- lex_tokench(lex, 'e');
- lex_tokench(lex, 'n');
- lex_tokench(lex, 'g');
- lex_tokench(lex, 't');
- lex_tokench(lex, 'h');
- lex_endtoken(lex);
- return (lex->tok.ttype = TOKEN_OPERATOR);
- } else lex_ungetch(lex, nextch);
- } else lex_ungetch(lex, nextch);
- } else lex_ungetch(lex, nextch);
- } else lex_ungetch(lex, nextch);
- } else lex_ungetch(lex, nextch);
- }
-
if (isident_start(ch))
{
const char *v;
} else if (!strcmp(v, "vector")) {
lex->tok.ttype = TOKEN_TYPENAME;
lex->tok.constval.t = TYPE_VECTOR;
+ } else if (!strcmp(v, "_length")) {
+ lex->tok.ttype = TOKEN_OPERATOR;
} else {
size_t kw;
for (kw = 0; kw < GMQCC_ARRAY_COUNT(keywords_qc); ++kw) {
#define opid3(a,b,c) (((uint8_t)a<<16)|((uint8_t)b<<8)|(uint8_t)c)
static const oper_info c_operators[] = {
- { "(", 0, opid1('('), ASSOC_LEFT, 99, OP_PREFIX, false}, /* paren expression - non function call */
- { "length", 1, opid3('l','e','n'), ASSOC_RIGHT, 98, OP_PREFIX, true},
+ { "(", 0, opid1('('), ASSOC_LEFT, 99, OP_PREFIX, false}, /* paren expression - non function call */
+ { "_length", 1, opid3('l','e','n'), ASSOC_RIGHT, 98, OP_PREFIX, true},
{ "++", 1, opid3('S','+','+'), ASSOC_LEFT, 17, OP_SUFFIX, false},
{ "--", 1, opid3('S','-','-'), ASSOC_LEFT, 17, OP_SUFFIX, false},
const float d[] = { 1 }; // 1
void main() {
- print(ftos(length a), "\n"); // 11
- print(ftos(length b), "\n"); // 3
- print(ftos(length c), "\n"); // 5
- print(ftos(length d), "\n"); // 1
+ print(ftos(_length a), "\n"); // 11
+ print(ftos(_length b), "\n"); // 3
+ print(ftos(_length c), "\n"); // 5
+ print(ftos(_length d), "\n"); // 1
- static float al = length(a);
- static float bl = length(b);
- static float cl = length(c);
- static float dl = length(d);
+ static float al = _length(a);
+ static float bl = _length(b);
+ static float cl = _length(c);
+ static float dl = _length(d);
print(ftos(al), "\n"); // 11
print(ftos(bl), "\n"); // 3
print(ftos(cl), "\n"); // 5
print(ftos(dl), "\n"); // 1
- print(ftos(length "hello world"), "\n"); // 11
+ print(ftos(_length "hello world"), "\n"); // 11
}