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('!','='): yylval.n = CC('!','='); return NEQ;
133 case CC('!','~'): yylval.n = CC('!','='); return NRE;
134 case CC('<','='): yylval.n = CC('<','='); return LE;
135 case CC('>','='): yylval.n = CC('>','='); return GE;
136 case CC('=','='): yylval.n = CC('=','='); return EQ;
137 case CC('~','~'): yylval.n = CC('~','~'); return RE;
138 case CC('-','>'): yylval.n = CC('-','>'); return ARROW;
163 yylval.str = get_string_out(c);
167 if (c >= '0' && c <= '9'){
169 scanf("%d",&yylval.n);
177 while (is_var_id(c = getchar())){
181 parse_err("Too long identifier, max allowed length is %d",BUFSIZE-1);
185 yylval.str = xstrdup(buf);
195 while (is_alpha(c = getchar())){
198 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);