14 enum yytokentype keytoks;
17 static struct keys kwds[] =
25 void __attribute__ ((noreturn))
31 vfprintf(stderr, msg, args);
42 if (!(ret = malloc(size)))
48 static void __attribute__ ((noreturn))
49 parse_err(char* msg, ...)
54 fprintf(stderr, "Line %d: ", line);
55 vfprintf(stderr, msg, args);
66 if (!(ret = strdup(s)))
73 get_string_out(int delim)
80 while ((c = getchar()) != delim || last == '\\'){
81 if (last=='\\' && c != delim)
89 parse_err("Too long string, max allowed length is %d",BUFSIZE-1);
99 return (c >= '0' && c <= '9' ) ||
100 (c >= 'a' && c <= 'z') ||
101 (c >= 'A' && c <= 'Z') ||
109 return (c >= 'a' && c <= 'z') ||
110 (c >= 'A' && c <= 'Z');
118 while ((c = getchar ()) == ' ' || c == '\t' || c =='\n'){
129 case CC('!','='): yylval.n = CC('!','='); return NEQ;
130 case CC('!','~'): yylval.n = CC('!','='); return NRE;
131 case CC('<','='): yylval.n = CC('<','='); return LE;
132 case CC('>','='): yylval.n = CC('>','='); return GE;
133 case CC('=','='): yylval.n = CC('=','='); return EQ;
134 case CC('~','~'): yylval.n = CC('~','~'); return RE;
135 case CC('-','>'): yylval.n = CC('-','>'); return ARROW;
163 yylval.str = get_string_out(c);
167 if (c >= '0' && c <= '9'){
172 while ((c = getchar())>= '0' && c<= '9'){
176 parse_err("Too long number");
180 yylval.str = xstrdup(buf);
189 while (is_var_id(c = getchar())){
193 parse_err("Too long identifier, max allowed length is %d",BUFSIZE-1);
197 yylval.str = xstrdup(buf);
207 while (is_alpha(c = getchar())){
210 parse_err("Keyword too long");
215 n = (sizeof(kwds)/sizeof(struct keys));
216 for (i = 0; i < n; i++){
217 if (!strcmp(buf,kwds[i].keywords))
218 return kwds[i].keytoks;
221 parse_err("Unknown keyword %s", buf);
224 parse_err("Unknown character %c", c);