/* -*-c++-*- */ /* * smeg - A satellite modelling and prediction tool * Copyright (C) 1999 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; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ %{ #include "sts2.h" #include "options_yacc.h" #include #include void DescapeString(char *s); %} %option noyywrap CHAR [-0-9A-Za-z._] %x date %x qstr %% echo { return ECHO; } set { return SET; } def { return DEF; } call { return CALL; } tle { return TLE; } loadtle { return TLE; } filter { return FILTER; } unfilter { return UNFILTER; } noradfilter { return NORADFILTER; } current { return CURRENT; } cur { return CURRENT; } position { return POSITION; } pos { return POSITION; } positions { return POSITION; } satx { return SATX; } look { return LOOK; } predict { return PREDICT; } passes { return PASSES; } pass { return PASSES; } passlist { return PASSES; } pl { return PASSES; } step { return _STEP; } show { return SHOW; } satlist { return SATLIST; } sl { return SATLIST; } sats { return SATLIST; } location { return LOCATION; } live { return LIVE; } page { return PAGER; } pager { return PAGER; } less { return PAGER; } more { return PAGER; } print { return PRINT; } quiet { return QUIET; } verbose { return VERBOSE; } debug { return DEBUG; } test { return TEST; } quit { return QUIT; } exit { return QUIT; } and { return '&'; } or { return '|'; } [=]+ { return '='; } "~=" { return '~'; } [&]+ { return '&'; } [|]+ { return '|'; } lt { return '<'; } gt { return '>'; } true { return TRUE; } false { return FALSE; } {CHAR}+ { yylval.str = (char *) malloc(yyleng+1); strncpy(yylval.str, yytext, yyleng+1); return STR; } \" { BEGIN(qstr); } \\. { yymore(); } [^\"\\]+ { yymore(); } \" { BEGIN(INITIAL); yylval.str = (char *) malloc(yyleng); strncpy(yylval.str, yytext, yyleng); yylval.str[yyleng-1] = 0; DescapeString(yylval.str); return STR; } [ \t\n]+ "{" { BEGIN(date); return STARTDATE;} { "}" { BEGIN(INITIAL); return ENDDATE; } now { return NOW; } yesterday { return YESTERDAY; } today { return TODAY; } tomorrow { return TOMORROW; } midnight { return MIDNIGHT; } noon { return NOON; } second { return SECONDS; } seconds { return SECONDS; } minute { return MINUTES; } minutes { return MINUTES; } hour { return HOURS; } hours { return HOURS; } day { return DAYS; } days { return DAYS; } [0-9]+ { yylval.i = atoi(yytext); return DATENUMBER; } [ \t\n]+ . {return yytext[0]; }; } . { return yytext[0]; } %% void DescapeString(char *s) { char *in; char *out; in = s; out = s; while (*in) { switch(*in) { case '\\': in++; switch(*in) { case 'n': *out++ = '\n'; break; case 't': *out++ = '\t'; break; default: *out++ = *in; } break; default: *out++ = *in; } in++; } *out++ = 0; } void scan_string(char *s) { BEGIN(INITIAL); /* Bail out of quote mode */ yy_scan_string(s); }