paper/atccl.lex
author Eugen Sawin <sawine@me73.com>
Tue, 29 Mar 2011 13:44:35 +0200
changeset 13 06d39950b727
permissions -rw-r--r--
Finalisations.
     1 %{
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include "atccl_parser.tab.h"
     5 
     6 int line_no = 1;
     7 char line_buffer[1024];
     8 char* installId();
     9 
    10 %}
    11 
    12 %option nounput
    13 
    14 delim			[ \t]
    15 ws			{delim}+
    16 letter 			[A-Za-z]
    17 digit			[0-9]
    18 id			{letter}({letter}|{digit}|_)*
    19 real			{digit}+\.{digit}+
    20 
    21 %%
    22 
    23 copx			{ return COPX; }
    24 adep			{ return ADEP; }
    25 ades			{ return ADES; }
    26 rwy			{ return RWY; }
    27 route			{ return ROUTE; }
    28 atyp			{ return ATYP; }
    29 equip			{ return EQUIP; }
    30 tas			{ return TAS; }
    31 frul			{ return FRUL; }
    32 ftyp			{ return FTYP; }
    33 travel_type 		{ return TRAVEL_TYPE; }
    34 time_separation		{ return TIMESEP; }
    35 time_sep		{ return TIMESEP; }
    36 fl			{ return FL; }
    37 constraint		{ return CONSTRNT; }
    38 pattern			{ return PATTERN; }
    39 flowpoint		{ return FLOWP; }
    40 
    41 
    42 is			{ return IS; }
    43 in			{ return IN; }
    44 not			{ return NOT; }
    45 less			{ return LESS; }
    46 greater			{ return GREATER; }
    47 than			{ return THAN; }
    48 and			{ return AND; }
    49 or			{ return OR; }
    50 at			{ return AT; }
    51 from			{ return FROM; }
    52 until			{ return UNTIL; }
    53 on			{ return ON; }
    54  
    55 {digit}+		{ yylval.integer = atoi(yytext); return INTEGER; }
    56 {real}			{ yylval.real = atof(yytext); return REAL; }
    57 {id}			{ yylval.string = installId(); return STRING; }
    58 \"			{ return QUOTE; }
    59 #.*$			{ return COM; }
    60 {ws}			{  }
    61 \n.*			{ strcpy(line_buffer, yytext+1); line_no++; yyless(1); }
    62 .			{ return yytext[0]; }
    63 %%
    64 
    65 char* installId()
    66 {
    67 	static char* no_string = "$$$NO STRING$$$";
    68 	char* id = no_string;
    69 	if (id_table_no < MAX_ID_TABLE_NO)
    70 	{
    71 		id = strdup(yytext);
    72 		id_table[id_table_no++] = id;
    73 	}
    74 	else
    75 	{
    76 		yyerror("Maximum number of string literals used");
    77 	}	
    78 	return id;
    79 }