Ejemplo n.º 1
0
static int
is_predicate(int z)
{	char c, c_prev = z;
	char want = (z == '{') ? '}' : ')';
	int i = 0, j, nesting = 0;
	char peek_buf[512];

	c = tl_peek(i++);	/* look ahead without changing position */
	while ((c != want || nesting > 0) && c != -1 && i < 2047)
	{	if (islower((int) c) || c == '_')
		{	peek_buf[0] = c;
			j = 1;
			while (j < (int) sizeof(peek_buf)
			&&    (isalnum((int)(c = tl_peek(i))) || c == '_'))
			{	peek_buf[j++] = c;
				i++;
			}
			c = 0;	/* make sure we don't match on z or want on the peekahead */
			if (j >= (int) sizeof(peek_buf))
			{	peek_buf[j-1] = '\0';
				fatal("name '%s' in ltl formula too long", peek_buf);
			}
			peek_buf[j] = '\0';
			if (strcmp(peek_buf, "always") == 0
			||  strcmp(peek_buf, "equivalent") == 0
			||  strcmp(peek_buf, "eventually") == 0
			||  strcmp(peek_buf, "until") == 0
			||  strcmp(peek_buf, "next") == 0
			||  strcmp(peek_buf, "c_expr") == 0)
			{	return 0;
			}
		} else
		{	int c_nxt = tl_peek(i);
			if (((c == 'U' || c == 'V' || c == 'X')
			&& !isalnum_(c_prev)
			&& (c_nxt == -1 || !isalnum_(c_nxt)))
			||  (c == '<' && c_nxt == '>')
			||  (c == '<' && c_nxt == '-')
			||  (c == '-' && c_nxt == '>')
			||  (c == '[' && c_nxt == ']'))
			{	return 0;
		}	}

		if (c == z)
		{	nesting++;
		}
		if (c == want)
		{	nesting--;
		}
		c_prev = c;
		c = tl_peek(i++);
	}
	return 1;
}
Ejemplo n.º 2
0
static const tic_outline_item* getJsOutline(const char* code, s32* size)
{
	enum{Size = sizeof(tic_outline_item)};

	*size = 0;

	static tic_outline_item* items = NULL;

	if(items)
	{
		free(items);
		items = NULL;
	}

	const char* ptr = code;

	while(true)
	{
		static const char FuncString[] = "function ";

		ptr = strstr(ptr, FuncString);

		if(ptr)
		{
			ptr += sizeof FuncString - 1;

			const char* start = ptr;
			const char* end = start;

			while(*ptr)
			{
				char c = *ptr;

				if(isalnum_(c));
				else if(c == '(')
				{
					end = ptr;
					break;
				}
				else break;

				ptr++;
			}

			if(end > start)
			{
				items = items ? realloc(items, (*size + 1) * Size) : malloc(Size);

				items[*size].pos = start - code;
				items[*size].size = end - start;

				(*size)++;
			}
		}
		else break;
	}

	return items;
}
Ejemplo n.º 3
0
int joe_ispunct(int wide,struct charmap *map,int c)
{
	if (joe_isspace(c))
		return 0;

	if (c=='_')
		return 1;

	if (isalnum_(wide,map,c))
		return 0;

	return joe_isprint(wide,map,c);
}