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'){
128 #define CC(a,b) ((a<<8)|b)
132 case CC('!','='): return NEQ;
133 case CC('!','~'): return NRE;
134 case CC('<','='): return LE;
135 case CC('>','='): return GE;
136 case CC('=','='): return EQ;
137 case CC('~','~'): return RE;
138 case CC('-','>'): return ARROW;
161 yylval.str = get_string_out(c);
165 if (c >= '0' && c <= '9'){
167 scanf("%d",&yylval.n);
175 while (is_var_id(c = getchar())){
179 parse_err("Too long identifier, max allowed length is %d",BUFSIZE-1);
182 yylval.str = xstrdup(buf);
192 while (is_alpha(c = getchar())){
195 parse_err("Keyword too long");
199 n = (sizeof(k)/sizeof(struct keys));
200 for (i = 0; i < n; i++){
201 if (!strcmp(buf,k[i].keywords))
205 parse_err("Unknown keyword %s", buf);
208 parse_err("Unknown character %c", c);