14 enum yytokentype keytoks;
19 static struct keys k[] =
27 void __attribute__ ((noreturn))
33 vfprintf(stderr, msg, args);
44 if (!(ret = malloc(size)))
50 static void __attribute__ ((noreturn))
51 parse_err(char* msg, ...)
56 fprintf(stderr, "Line %d: ", line);
57 vfprintf(stderr, msg, args);
68 if (!(ret = strdup(s)))
75 get_string_out(int delim)
82 while ((c = getchar()) != delim || last == '\\'){
83 if (last=='\\' && c != delim)
91 parse_err("Too long string, max allowed length is %d",BUFSIZE-1);
101 return (c >= '0' && c <= '9' ) ||
102 (c >= 'a' && c <= 'z') ||
103 (c >= 'A' && c <= 'Z') ||
111 return (c >= 'a' && c <= 'z') ||
112 (c >= 'A' && c <= 'Z');
120 while ((c = getchar ()) == ' ' || c == '\t' || c =='\n'){
133 #define CC(a,b) ((a<<8)|b)
137 case CC('!','='): return NEQ;
138 case CC('!','~'): return NRE;
139 case CC('<','='): return LE;
140 case CC('>','='): return GE;
141 case CC('=','='): return EQ;
142 case CC('~','~'): return RE;
143 case CC('-','>'): return ARROW;
165 yylval.str = get_string_out(c);
169 if (c >= '0' && c <= '9'){
171 scanf("%d",&yylval.n);
179 while (is_var_id(c = getchar())){
183 parse_err("Too long identifier, max allowed length is %d",BUFSIZE-1);
186 yylval.str = xstrdup(buf);
196 while (is_alpha(c = getchar())){
199 parse_err("Keyword too long");
203 n = (sizeof(k)/sizeof(struct keys));
204 for (i = 0; i < n; i++){
205 if (!strcmp(buf,k[i].keywords))
209 parse_err("Unknown keyword %s", buf);
212 parse_err("Unknown character %c", c);