diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2016-10-27 18:59:29 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2016-10-27 18:59:29 (GMT) |
commit | d4d595fa7fb12903db9227d33d48b2b00120dbd1 (patch) | |
tree | 7d18365de0d6d1b29399b6a17c7eb01c2eb3ed49 /tksao/fitsy++/lex.L | |
parent | 949f96e29bfe0bd8710d775ce220e597064e2589 (diff) | |
download | blt-d4d595fa7fb12903db9227d33d48b2b00120dbd1.zip blt-d4d595fa7fb12903db9227d33d48b2b00120dbd1.tar.gz blt-d4d595fa7fb12903db9227d33d48b2b00120dbd1.tar.bz2 |
Initial commit
Diffstat (limited to 'tksao/fitsy++/lex.L')
-rw-r--r-- | tksao/fitsy++/lex.L | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/tksao/fitsy++/lex.L b/tksao/fitsy++/lex.L new file mode 100644 index 0000000..a25e7be --- /dev/null +++ b/tksao/fitsy++/lex.L @@ -0,0 +1,156 @@ +/* Copyright (C) 1999-2016 + * 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 "parser.H" + + extern YYSTYPE* fflval; + extern ffFlexLexer* fflexx; + + extern char ff_filter[]; + #define RET(x) {strcat(ff_filter,yytext);return x;} + #define CLEARFILTER {ff_filter[0]='\0';} +%} + +%x EXT +%x FILTER +%x ARRAY + +/* rules */ + +%% + +[^[\]\t]+ { // File + strcpy(fflval->str,yytext); + return STRING; + } + +\[ { // first bracket + BEGIN EXT; + CLEARFILTER + return yytext[0]; + } + +[ \t]+ { // White Spaces + } + +. { // Else, return the char + return yytext[0]; + } + +<EXT>{ + +arch {RET(ARCH_)} +array {RET(ARRAY_)} +big {RET(BIG_)} +bigendian {RET(BIGENDIAN_)} +bin {RET(BIN_)} +binkey {RET(BINKEY_)} +bincol {RET(BINCOL_)} +bitpix {RET(BITPIX_)} +col {RET(COL_)} +dim {RET(DIM_)} +dims {RET(DIMS_)} +ecliptic {RET(ECLIPTIC_)} +endian {RET(ENDIAN_)} +equatorial {RET(EQUATORIAL_)} +galactic {RET(GALACTIC_)} +key {RET(KEY_)} +layout {RET(LAYOUT_)} +little {RET(LITTLE_)} +littleendian {RET(LITTLEENDIAN_)} +nested {RET(NESTED_)} +north {RET(NORTH_)} +order {RET(ORDER_)} +quad {RET(QUAD_)} +ring {RET(RING_)} +skip {RET(SKIP_)} +south {RET(SOUTH_)} +system {RET(SYSTEM_)} +unknown {RET(UNKNOWN_)} +xdim {RET(XDIM_)} +ydim {RET(YDIM_)} +zdim {RET(ZDIM_)} + +[-+]?[0-9]+ { // Integer + fflval->integer = atoi(yytext); + RET(INT) + } + +[0-9A-Za-z_.-]+ { // Extn/Col Name + strcpy(fflval->str,yytext); + RET(STRING) + } + +\[ { // bracket + CLEARFILTER + return yytext[0]; + } + +, { // comma + CLEARFILTER + return yytext[0]; + } + +[ \t]+ { // White Spaces + strcat(ff_filter,yytext); + } + +. { // Else, return the char + strcat(ff_filter,yytext); + return yytext[0]; + } + +} + +<FILTER>.* { // rest of Filter + strcpy(fflval->str,yytext); + fflval->str[yyleng-1] = '\0'; // Remove the ']' + strcat(ff_filter,fflval->str); + return STRING; + } + +<ARRAY>{ + +[-+]?[0-9]+ { // Integer + fflval->integer = atoi(yytext); + return INT; + } + +. { // Else, return the char + return yytext[0]; + } + +} + +%% + +void ffFilter(int doit) +{ + if (fflexx) + fflexx->begin(FILTER, doit); +} + +void ffArray(int doit) +{ + if (fflexx) + fflexx->begin(ARRAY, doit); +} + +void ffFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} |