%{
/*
 * $Id: fp_lex.l,v 2.4 89/11/14 20:28:11 tynor Exp $
 *----------------------------------------------------------------------------
 *	FPLAN - Flight Planner
 *	Steve Tynor
 *	tynor@prism.gatech.edu
 *
 *	This program is in the public domain. Permission to copy,
 * distribute, modify this program is hearby given as long as this header
 * remains. If you redistribute this program after modifying it, please
 * document your changes so that I do not take the blame (or credit) for
 * those changes.  If you fix bugs or add features, please send me a
 * patch so that I can keep the 'official' version up-to-date.
 *
 *	Bug reports are welcome and I'll make an attempt to fix those
 * that are reported.
 *
 *	USE AT YOUR OWN RISK! I assume no responsibility for any
 * errors in this program, its database or documentation. I will make an
 * effort to fix bugs, but if you crash and burn because, for example,
 * fuel estimates in this program were inaccurate, it's your own fault
 * for trusting somebody else's code! Remember, as PIC, it's _your_
 * responsibility to do complete preflight planning. Use this program as
 * a flight planning aid, but verify its results before using them.
 *----------------------------------------------------------------------------
 */
	
#include "fp_tok.h"

static char rcsid[] = "$Id: fp_lex.l,v 2.4 89/11/14 20:28:11 tynor Exp $";

double yydval;
extern double atof();

%}

%%

\#.*$		;	/* comment */
\"		{ int i;
		  for (i = 0; (yytext[i] = input()) != '\"'; i++) {
		     if (yytext[i] == '\"')
			break;
		     if (yytext[i] == '\\')
			yytext[i] = input();
		  }
		  yytext[i] = '\0';
		  return TOK_STRING;
		};
alt		return TOK_ALT;
via		return TOK_VIA;
from		return TOK_FROM;
to		return TOK_TO;
mi		return TOK_MI;
nm		return TOK_NM;
mph		return TOK_MPH;
kts		return TOK_KTS;
nav		return TOK_NAV;
wind		return TOK_WIND;
tas		return TOK_TAS;
fuel_amt	return TOK_FUEL_AMT;
fuel_rate	return TOK_FUEL_RATE;
fuel_used	return TOK_FUEL_USED;

\@		return TOK_ATSIGN;

[\+\-]?[0-9]+\.[0-9]+	{ yydval = atof (yytext);
		  return TOK_REAL;
		};
[\+\-]?[0-9]+   { yydval = atof (yytext);
		  return TOK_INTEGER;
		};
\_?[0-9A-Za-z]+ return TOK_SYMBOL; /* use a leading _ for personal waypoints */
\:\=		return TOK_ASSIGN;
\;		return TOK_SEMICOLON;
\,		return TOK_COMMA;
\(		return TOK_LPAREN;
\)		return TOK_RPAREN;
[ \t\n]       	;	/* ignore whitespace */
.		;	/* ignore anything else too */
%%
