// sattool - visual satellite tracking and prediction tool.
// Copyright 2000 Tom Rothamel <tom-idbg@onegeek.org>
//
// 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.  

/* Input stream parser, used by ReadInput and GetSite */

%{
#include "sattool.h"
#define YYPARSE_PARAM list

int yyerror(char *);
int yylex();

%}

%union {
	char *s;
	int i;
	double d;
	Thing *th;
}

%token <s> STR
%token <d> NUM

%token SGP4SAT
%token EARTHSITE
%token PASS

%type <th> thing

%%

list:
| list thing {
	((List *) list)->add($2);

}
| list error {yyerrok;}
;

thing: '(' SGP4SAT STR STR STR ')' {
	$$ = new Sgp4Sat($3, $4, $5);
}
| '(' EARTHSITE STR NUM NUM NUM ')' {
	$$ = new EarthSite($3, $4, $5, $6);
} 
| '(' PASS thing thing NUM NUM NUM NUM NUM NUM ')' {
	if (!getSat($3) || !getObject($4)) {
		yyerror("problem reading pass.");
		YYERROR;
	}	

	$$ = new Pass (getSat($3), getObject($4), $5, $6,
			$7, $8, $9, $10);
}

;


%%

int yyerror(char *s) {
	error("While reading input: %s\n", s);
}
