xref: /llvm-project/polly/lib/External/isl/isl_stream_private.h (revision 1fa7b972c02efa8e80706995f1c6326e68205c47)
152a25237STobias Grosser #include <isl_int.h>
252a25237STobias Grosser #include <isl/stream.h>
3*1fa7b972STobias Grosser #include <isl_yaml.h>
452a25237STobias Grosser 
552a25237STobias Grosser struct isl_token {
652a25237STobias Grosser 	int type;
752a25237STobias Grosser 
852a25237STobias Grosser 	unsigned int on_new_line : 1;
952a25237STobias Grosser 	unsigned is_keyword : 1;
1052a25237STobias Grosser 	int line;
1152a25237STobias Grosser 	int col;
1252a25237STobias Grosser 
1352a25237STobias Grosser 	union {
1452a25237STobias Grosser 		isl_int	v;
1552a25237STobias Grosser 		char	*s;
1652a25237STobias Grosser 		isl_map *map;
1752a25237STobias Grosser 		isl_pw_aff *pwaff;
1852a25237STobias Grosser 	} u;
1952a25237STobias Grosser };
2052a25237STobias Grosser 
2152a25237STobias Grosser struct isl_token *isl_token_new(isl_ctx *ctx,
2252a25237STobias Grosser 	int line, int col, unsigned on_new_line);
23*1fa7b972STobias Grosser 
24*1fa7b972STobias Grosser /* An input stream that may be either a file or a string.
25*1fa7b972STobias Grosser  *
26*1fa7b972STobias Grosser  * line and col are the line and column number of the next character (1-based).
27*1fa7b972STobias Grosser  * start_line and start_col are set by isl_stream_getc to point
28*1fa7b972STobias Grosser  * to the position of the returned character.
29*1fa7b972STobias Grosser  * last_line is the line number of the previous token.
30*1fa7b972STobias Grosser  *
31*1fa7b972STobias Grosser  * yaml_state and yaml_indent keep track of the currently active YAML
32*1fa7b972STobias Grosser  * elements.  yaml_size is the size of these arrays, while yaml_depth
33*1fa7b972STobias Grosser  * is the number of elements currently in use.
34*1fa7b972STobias Grosser  * yaml_state and yaml_indent may be NULL if no YAML parsing is being
35*1fa7b972STobias Grosser  * performed.
36*1fa7b972STobias Grosser  * yaml_state keeps track of what is expected next at each level.
37*1fa7b972STobias Grosser  * yaml_indent keeps track of the indentation at each level, with
38*1fa7b972STobias Grosser  * ISL_YAML_INDENT_FLOW meaning that the element is in flow format
39*1fa7b972STobias Grosser  * (such that the indentation is not relevant).
40*1fa7b972STobias Grosser  */
41*1fa7b972STobias Grosser struct isl_stream {
42*1fa7b972STobias Grosser 	struct isl_ctx	*ctx;
43*1fa7b972STobias Grosser 	FILE        	*file;
44*1fa7b972STobias Grosser 	const char  	*str;
45*1fa7b972STobias Grosser 	int	    	line;
46*1fa7b972STobias Grosser 	int	    	col;
47*1fa7b972STobias Grosser 	int		start_line;
48*1fa7b972STobias Grosser 	int		start_col;
49*1fa7b972STobias Grosser 	int		last_line;
50*1fa7b972STobias Grosser 	int	    	eof;
51*1fa7b972STobias Grosser 
52*1fa7b972STobias Grosser 	char	    	*buffer;
53*1fa7b972STobias Grosser 	size_t	    	size;
54*1fa7b972STobias Grosser 	size_t	    	len;
55*1fa7b972STobias Grosser 	int	    	c;
56*1fa7b972STobias Grosser 	int		un[5];
57*1fa7b972STobias Grosser 	int		n_un;
58*1fa7b972STobias Grosser 
59*1fa7b972STobias Grosser 	struct isl_token	*tokens[5];
60*1fa7b972STobias Grosser 	int	    	n_token;
61*1fa7b972STobias Grosser 
62*1fa7b972STobias Grosser 	struct isl_hash_table	*keywords;
63*1fa7b972STobias Grosser 	enum isl_token_type	 next_type;
64*1fa7b972STobias Grosser 
65*1fa7b972STobias Grosser 	int			yaml_depth;
66*1fa7b972STobias Grosser 	int			yaml_size;
67*1fa7b972STobias Grosser 	enum isl_yaml_state	*yaml_state;
68*1fa7b972STobias Grosser 	int			*yaml_indent;
69*1fa7b972STobias Grosser };
70