book/atccl.lex
changeset 1 866172a16472
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/book/atccl.lex	Wed Mar 23 21:10:10 2011 +0100
     1.3 @@ -0,0 +1,79 @@
     1.4 +%{
     1.5 +#include <stdio.h>
     1.6 +#include <string.h>
     1.7 +#include "atccl_parser.tab.h"
     1.8 +
     1.9 +int line_no = 1;
    1.10 +char line_buffer[1024];
    1.11 +char* installId();
    1.12 +
    1.13 +%}
    1.14 +
    1.15 +%option nounput
    1.16 +
    1.17 +delim			[ \t]
    1.18 +ws			{delim}+
    1.19 +letter 			[A-Za-z]
    1.20 +digit			[0-9]
    1.21 +id			{letter}({letter}|{digit}|_)*
    1.22 +real			{digit}+\.{digit}+
    1.23 +
    1.24 +%%
    1.25 +
    1.26 +copx			{ return COPX; }
    1.27 +adep			{ return ADEP; }
    1.28 +ades			{ return ADES; }
    1.29 +rwy			{ return RWY; }
    1.30 +route			{ return ROUTE; }
    1.31 +atyp			{ return ATYP; }
    1.32 +equip			{ return EQUIP; }
    1.33 +tas			{ return TAS; }
    1.34 +frul			{ return FRUL; }
    1.35 +ftyp			{ return FTYP; }
    1.36 +travel_type 		{ return TRAVEL_TYPE; }
    1.37 +time_separation		{ return TIMESEP; }
    1.38 +time_sep		{ return TIMESEP; }
    1.39 +fl			{ return FL; }
    1.40 +constraint		{ return CONSTRNT; }
    1.41 +pattern			{ return PATTERN; }
    1.42 +flowpoint		{ return FLOWP; }
    1.43 +
    1.44 +
    1.45 +is			{ return IS; }
    1.46 +in			{ return IN; }
    1.47 +not			{ return NOT; }
    1.48 +less			{ return LESS; }
    1.49 +greater			{ return GREATER; }
    1.50 +than			{ return THAN; }
    1.51 +and			{ return AND; }
    1.52 +or			{ return OR; }
    1.53 +at			{ return AT; }
    1.54 +from			{ return FROM; }
    1.55 +until			{ return UNTIL; }
    1.56 +on			{ return ON; }
    1.57 + 
    1.58 +{digit}+		{ yylval.integer = atoi(yytext); return INTEGER; }
    1.59 +{real}			{ yylval.real = atof(yytext); return REAL; }
    1.60 +{id}			{ yylval.string = installId(); return STRING; }
    1.61 +\"			{ return QUOTE; }
    1.62 +#.*$			{ return COM; }
    1.63 +{ws}			{  }
    1.64 +\n.*			{ strcpy(line_buffer, yytext+1); line_no++; yyless(1); }
    1.65 +.			{ return yytext[0]; }
    1.66 +%%
    1.67 +
    1.68 +char* installId()
    1.69 +{
    1.70 +	static char* no_string = "$$$NO STRING$$$";
    1.71 +	char* id = no_string;
    1.72 +	if (id_table_no < MAX_ID_TABLE_NO)
    1.73 +	{
    1.74 +		id = strdup(yytext);
    1.75 +		id_table[id_table_no++] = id;
    1.76 +	}
    1.77 +	else
    1.78 +	{
    1.79 +		yyerror("Maximum number of string literals used");
    1.80 +	}	
    1.81 +	return id;
    1.82 +}