From 32752f6a7d87c794ac91c88e355fce0fa95dfbcb Mon Sep 17 00:00:00 2001 From: William Joye Date: Sat, 3 Mar 2018 16:26:35 -0500 Subject: simplify ds9 parsers --- ds9/parsers/base.fin | 35 ++++++++++++++++++++ ds9/parsers/coords.fin | 40 +++++++++++++++++++++++ ds9/parsers/panlex.fcl | 86 ++++--------------------------------------------- ds9/parsers/zoomlex.fcl | 36 +++++---------------- 4 files changed, 89 insertions(+), 108 deletions(-) create mode 100644 ds9/parsers/base.fin create mode 100644 ds9/parsers/coords.fin diff --git a/ds9/parsers/base.fin b/ds9/parsers/base.fin new file mode 100644 index 0000000..a1c6932 --- /dev/null +++ b/ds9/parsers/base.fin @@ -0,0 +1,35 @@ +# INT +[+-]?{D}+ {set yylval $yytext; return $INT_} + +# REAL +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? {set yylval $yytext; return $REAL_} + +# SEXAGESIMAL +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ {set yylval $yytext; return $SEXSTR_} + +# HMS +[+-]?{D}+h{D}+m{D}+"."?s | +[+-]?{D}+h{D}+m{D}*"."{D}+s {set yylval $yytext; return $HMSSTR_} + +# DMS +[+-]?{D}+d{D}+m{D}+"."?s | +[+-]?{D}+d{D}+m{D}*"."{D}+s {set yylval $yytext; return $SMSSTR_} + +# Quoted STRING +\"[^\"]*\" {set yylval [string range $yytext 1 end-1]; return $STRING_} + +# Quoted STRING +\'[^\']*\' {set yylval [string range $yytext 1 end-1]; return $STRING_} + +# Quoted STRING +\{[^\}]*\} {set yylval [string range $yytext 1 end-1]; return $STRING_} + +# STRING +\S+\S+ {set yylval $yytext; return $STRING_} + +\s # ignore whitespace + +. {set yylval $yytext; return $yylval} + diff --git a/ds9/parsers/coords.fin b/ds9/parsers/coords.fin new file mode 100644 index 0000000..3c72e46 --- /dev/null +++ b/ds9/parsers/coords.fin @@ -0,0 +1,40 @@ +wcs {return $WCS_} +wcsa {return $WCSA_} +wcsb {return $WCSB_} +wcsc {return $WCSC_} +wcsd {return $WCSD_} +wcse {return $WCSE_} +wcsf {return $WCSF_} +wcsg {return $WCSG_} +wcsh {return $WCSH_} +wcsi {return $WCSI_} +wcsj {return $WCSJ_} +wcsk {return $WCSK_} +wcsl {return $WCSL_} +wcsm {return $WCSM_} +wcsn {return $WCSN_} +wcso {return $WCSO_} +wcsp {return $WCSP_} +wcsq {return $WCSQ_} +wcsr {return $WCSR_} +wcss {return $WCSS_} +wcst {return $WCST_} +wcsu {return $WCSU_} +wcsv {return $WCSV_} +wcsw {return $WCSW_} +wcsx {return $WCSX_} +wcsy {return $WCSY_} +wcsz {return $WCSZ_} + +image {return $IMAGE_} +physical {return $PHYSICAL_} +amplifier {return $AMPLIFIER_} +detector {return $DETECTOR_} + +fk4 {return $FK4_} +b1950 {return $FK4_} +fk5 {return $FK5_} +j2000 {return $FK5_} +galactic {return $GALACTIC_} +ecliptic {return $ECLIPTIC_} + diff --git a/ds9/parsers/panlex.fcl b/ds9/parsers/panlex.fcl index 056dfc5..37488da 100644 --- a/ds9/parsers/panlex.fcl +++ b/ds9/parsers/panlex.fcl @@ -1,5 +1,4 @@ %{ -source $ds9(root)/library/panparser.tab.tcl %} %option noyywrap @@ -15,87 +14,14 @@ E [Ee][+-]?{D}+ %% -close {return $pan::CLOSE_} -open {return $pan::OPEN_} -to {return $pan::TO_} +#tab panparser.tab.tcl -wcs {return $pan::WCS_} -wcsa {return $pan::WCSA_} -wcsb {return $pan::WCSB_} -wcsc {return $pan::WCSC_} -wcsd {return $pan::WCSD_} -wcse {return $pan::WCSE_} -wcsf {return $pan::WCSF_} -wcsg {return $pan::WCSG_} -wcsh {return $pan::WCSH_} -wcsi {return $pan::WCSI_} -wcsj {return $pan::WCSJ_} -wcsk {return $pan::WCSK_} -wcsl {return $pan::WCSL_} -wcsm {return $pan::WCSM_} -wcsn {return $pan::WCSN_} -wcso {return $pan::WCSO_} -wcsp {return $pan::WCSP_} -wcsq {return $pan::WCSQ_} -wcsr {return $pan::WCSR_} -wcss {return $pan::WCSS_} -wcst {return $pan::WCST_} -wcsu {return $pan::WCSU_} -wcsv {return $pan::WCSV_} -wcsw {return $pan::WCSW_} -wcsx {return $pan::WCSX_} -wcsy {return $pan::WCSY_} -wcsz {return $pan::WCSZ_} +close {return $CLOSE_} +open {return $OPEN_} +to {return $TO_} -image {return $pan::IMAGE_} -physical {return $pan::PHYSICAL_} -amplifier {return $pan::AMPLIFIER_} -detector {return $pan::DETECTOR_} - -fk4 {return $pan::FK4_} -b1950 {return $pan::FK4_} -fk5 {return $pan::FK5_} -j2000 {return $pan::FK5_} -galactic {return $pan::GALACTIC_} -ecliptic {return $pan::ECLIPTIC_} - -# INT -[+-]?{D}+ {set yylval $yytext; return $pan::INT_} - -# REAL -[+-]?{D}+"."?({E})? | -[+-]?{D}*"."{D}+({E})? {set yylval $yytext; return $pan::REAL_} - -# SEXAGESIMAL -[+-]?{D}+:{D}+:{D}+"."? | -[+-]?{D}+:{D}+:{D}*"."{D}+ {set yylval $yytext; return $pan::SEXSTR_} - -# HMS -[+-]?{D}+h{D}+m{D}+"."?s | -[+-]?{D}+h{D}+m{D}*"."{D}+s {set yylval $yytext; return $pan::HMSSTR_} - -# DMS -[+-]?{D}+d{D}+m{D}+"."?s | -[+-]?{D}+d{D}+m{D}*"."{D}+s {set yylval $yytext; return $pan::SMSSTR_} - -# Quoted STRING -\"[^\"]*\" {set yylval [string range $yytext 1 end-1]; return $pan::STRING_} - -# Quoted STRING -\'[^\']*\' {set yylval [string range $yytext 1 end-1]; return $pan::STRING_} - -# Quoted STRING -\{[^\}]*\} {set yylval [string range $yytext 1 end-1]; return $pan::STRING_} - -# CMD -#-\S+\S+ {set yylval $yytext; return $pan::CMD_} - -# STRING -\S+\S+ {set yylval $yytext; return $pan::STRING_} - -\s # ignore whitespace - -. {set yylval $yytext; return $yylval} +#include coords.fin +#include base.fin %% diff --git a/ds9/parsers/zoomlex.fcl b/ds9/parsers/zoomlex.fcl index 11244ed..370b31c 100644 --- a/ds9/parsers/zoomlex.fcl +++ b/ds9/parsers/zoomlex.fcl @@ -1,5 +1,4 @@ %{ -source $ds9(root)/library/zoomparser.tab.tcl %} %option noyywrap @@ -15,35 +14,16 @@ E [Ee][+-]?{D}+ %% -close {return $zoom::CLOSE_} -in {return $zoom::IN_} -fit {return $zoom::FIT_} -open {return $zoom::OPEN_} -out {return $zoom::OUT_} -to {return $zoom::TO_} +#tab zoomparser.tab.tcl -# INT -[+-]?{D}+ {set yylval $yytext; return $zoom::INT_} +close {return $CLOSE_} +in {return $IN_} +fit {return $FIT_} +open {return $OPEN_} +out {return $OUT_} +to {return $TO_} -# REAL -[+-]?{D}+"."?({E})? | -[+-]?{D}*"."{D}+({E})? {set yylval $yytext; return $zoom::REAL_} - -# Quoted STRING -\"[^\"]*\" {set yylval [string range $yytext 1 end-1]; return $zoom::STRING_} - -# Quoted STRING -\'[^\']*\' {set yylval [string range $yytext 1 end-1]; return $zoom::STRING_} - -# Quoted STRING -\{[^\}]*\} {set yylval [string range $yytext 1 end-1]; return $zoom::STRING_} - -# STRING -\S+\S+ {set yylval $yytext; return $zoom::STRING_} - -\s # ignore whitespace - -. {set yylval $yytext; return $yylval} +#include base.fin %% -- cgit v0.12