// sattool - visual satellite tracking and prediction tool. // Copyright 2000 Tom Rothamel // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. /* Parser for filter expressions */ %{ #include "sattool.h" #include "filter.h" #define YYPARSE_PARAM stout void filter_error(char *); extern int yylex(); %} %union { char *s; Step *step; } %token STR %token AND %token OR %type step %type level1 %type level2 %% start: level1 { *((Step **) stout) = $1; } ; level1: level2 { $$ = $1 } | level1 OR level1 { $$ = new MergeStep($1, $3, merge_or); } ; level2: step { $$ = $1 } | level2 AND level2 { $$ = new MergeStep($1, $3, merge_and); } ; step: STR '<' STR { $$ = GetCompareStep($1, '<', $3); free($1); free($3); if (!$$) YYERROR; } | STR '>' STR { $$ = GetCompareStep($1, '>', $3); free($1); free($3); if (!$$) YYERROR; } | STR '=' STR { $$ = GetCompareStep($1, '=', $3); free($1); free($3); if (!$$) YYERROR; } | STR { $$ = GetCompareStep($1, ' ', ""); free($1); if (!$$) YYERROR; } | '(' level1 ')' { $$ = $2; } ; %% void filter_error(char *s) { error("While parsing filter expression: %s\n", s); }