diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2020-03-19 14:52:02 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2020-03-19 14:52:02 (GMT) |
commit | d464af4522b4ecc906eb726a55fb01dc2db44930 (patch) | |
tree | fe8613cbd93424e933229e7ad7cc7d5ceae11fd8 /fitsy/envilex.L | |
parent | 36b673794f503c76e7dca7360bea4cd1ebf1e660 (diff) | |
download | blt-d464af4522b4ecc906eb726a55fb01dc2db44930.zip blt-d464af4522b4ecc906eb726a55fb01dc2db44930.tar.gz blt-d464af4522b4ecc906eb726a55fb01dc2db44930.tar.bz2 |
libfitsy
Diffstat (limited to 'fitsy/envilex.L')
-rw-r--r-- | fitsy/envilex.L | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/fitsy/envilex.L b/fitsy/envilex.L new file mode 100644 index 0000000..5621a04 --- /dev/null +++ b/fitsy/envilex.L @@ -0,0 +1,194 @@ +/* Copyright (C) 1999-2018 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + + #include "util.h" + #include "enviparser.H" + + extern YYSTYPE* envilval; + extern enviFlexLexer* envilexx; +%} + +%x DISCARD +%x BRACKET + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +<DISCARD>[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(envilval->str,""); // feed a blank string + return STRING; + } + +<DISCARD>[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + +\{ { + BEGIN BRACKET; + return '{'; + } + +<BRACKET>\} { + BEGIN INITIAL; + return '}'; + } + +debug {return DEBUG_;} +on {return ON_;} +off {return OFF_;} + +average {return AVERAGE_;} +band {return BAND_;} +bands {return BANDS_;} +bbl {return BBL_;} +bil {return BIL_;} +bip {return BIP_;} +bsq {return BSQ_;} +byte {return BYTE_;} +envi {return ENVI_;} +data {return DATA_;} +default {return DEFAULT_;} +description {return DESCRIPTION_;} +factor {return FACTOR_;} +frame {return FRAME_;} +file {return FILE_;} +fwhm {return FWHM_;} +gain {return GAIN_;} +header {return HEADER_;} +info {return INFO_;} +ignore {return IGNORE_;} +interleave {return INTERLEAVE_;} +limits {return LIMITS_;} +lines {return LINES_;} +major {return MAJOR_;} +map {return MAP_;} +minor {return MINOR_;} +names {return NAMES_;} +offset {return OFFSET_;} +offsets {return OFFSETS_;} +order {return ORDER_;} +pixel {return PIXEL_;} +pixels {return PIXELS_;} +plot {return PLOT_;} +projection {return PROJECTION_;} +range {return RANGE_;} +reflectance {return REFLECTANCE_;} +samples {return SAMPLES_;} +scale {return SCALE_;} +scanner {return SCANNER_;} +sensor {return SENSOR_;} +size {return SIZE_;} +stretch {return STRETCH_;} +titles {return TITLES_;} +type {return TYPE_;} +units {return UNITS_;} +value {return VALUE_;} +values {return VALUES_;} +wavelength {return WAVELENGTH_;} + + +<BRACKET>[+-]?{D}+ { // Integer + envilval->integer = atoi(yytext); + return INT; + } + +<BRACKET>[+-]?{D}+"."?({E})? | +<BRACKET>[+-]?{D}*"."{D}+({E})? { // Real Number + envilval->real = atof(yytext); + return REAL; + } + + +<BRACKET>[0-9A-Za-z\-]+ { // General String + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + +<BRACKET>, { + return ','; + } + +<BRACKET>[ \t]+ { // White Spaces + } + +<BRACKET>\n { // linefeed + } + +<BRACKET>. { // other chars, eat it + } + +[+-]?{D}+ { // Integer + envilval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + envilval->real = atof(yytext); + return REAL; + } + + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<<EOF>> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% + +void enviDiscard(int doit) +{ + if (envilexx) + envilexx->begin(DISCARD, doit); +} + +void enviFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} |