From bb5b4289cfdadeff94c5b7efdeea4f91280370af Mon Sep 17 00:00:00 2001 From: William Joye Date: Wed, 11 Apr 2018 12:52:19 -0400 Subject: add ds9 smooth parser --- ds9/library/smooth.tcl | 18 +++++++++++++ ds9/library/source.tcl | 2 ++ ds9/parsers/smoothlex.fcl | 29 +++++++++++++++++++++ ds9/parsers/smoothparser.tac | 62 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 ds9/parsers/smoothlex.fcl create mode 100644 ds9/parsers/smoothparser.tac diff --git a/ds9/library/smooth.tcl b/ds9/library/smooth.tcl index d1d3b74..a5fd735 100644 --- a/ds9/library/smooth.tcl +++ b/ds9/library/smooth.tcl @@ -345,6 +345,14 @@ proc ProcessSmoothCmd {varname iname} { upvar $varname var upvar $iname i + global debug + if {$debug(tcl,parser)} { + smooth::YY_FLUSH_BUFFER + smooth::yy_scan_string [lrange $var $i end] + smooth::yyparse + incr i [expr $smooth::yycnt-1] + } else { + global smooth switch -- [string tolower [lindex $var $i]] { @@ -410,6 +418,16 @@ proc ProcessSmoothCmd {varname iname} { } } } +} + +proc SmoothCmdSet {which value {cmd {}}} { + global smooth + + set smooth($which) $value + if {$cmd != {}} { + eval $cmd + } +} proc ProcessSendSmoothCmd {proc id param} { global smooth diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index b48a8b3..145aac2 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -230,6 +230,8 @@ source $ds9(root)/library/scaleparser.tcl source $ds9(root)/library/scalelex.tcl source $ds9(root)/library/skyviewparser.tcl source $ds9(root)/library/skyviewlex.tcl +source $ds9(root)/library/smoothparser.tcl +source $ds9(root)/library/smoothlex.tcl source $ds9(root)/library/threedparser.tcl source $ds9(root)/library/threedlex.tcl source $ds9(root)/library/tileparser.tcl diff --git a/ds9/parsers/smoothlex.fcl b/ds9/parsers/smoothlex.fcl new file mode 100644 index 0000000..81fd963 --- /dev/null +++ b/ds9/parsers/smoothlex.fcl @@ -0,0 +1,29 @@ +#tab smoothparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +angle {return $ANGLE_} +boxcar {return $BOXCAR_} +close {return $CLOSE_} +elliptic {return $ELLIPTIC_} +function {return $FUNCTION_} +gaussian {return $GAUSSIAN_} +lock {return $LOCK_} +match {return $MATCH_} +open {return $OPEN_} +radius {return $RADIUS_} +radiusminor {return $RADIUSMINOR_} +sigma {return $SIGMA_} +sigmaminor {return $SIGMAMINOR_} +tophat {return $TOPHAT_} + +#include yesno.fin +#include numeric.fin +#include string.fin + +%% diff --git a/ds9/parsers/smoothparser.tac b/ds9/parsers/smoothparser.tac new file mode 100644 index 0000000..7a59a74 --- /dev/null +++ b/ds9/parsers/smoothparser.tac @@ -0,0 +1,62 @@ +%{ +%} + +#include yesno.tin +#include numeric.tin +#include string.tin + +%start command + +%token ANGLE_ +%token BOXCAR_ +%token CLOSE_ +%token ELLIPTIC_ +%token FUNCTION_ +%token GAUSSIAN_ +%token LOCK_ +%token MATCH_ +%token OPEN_ +%token RADIUS_ +%token RADIUSMINOR_ +%token SIGMA_ +%token SIGMAMINOR_ +%token TOPHAT_ + +%% + +#include yesno.trl +#include numeric.trl + +command : smooth + | smooth {yyclearin; YYACCEPT} STRING_ + ; + + +smooth : yesno {SmoothCmdSet view $1 SmoothUpdate} + | OPEN_ {SmoothDialog} + | CLOSE_ {SmoothDestroyDialog} + | MATCH_ {MatchSmoothCurrent} + | LOCK_ yesno {SmoothCmdSet lock $2 LockSmoothCurrent} + | FUNCTION_ function {SmoothCmdSet function $2 SmoothUpdate} + | RADIUS_ INT_ {SmoothCmdSet radius $2 SmoothUpdate} + | RADIUSMINOR_ INT_ {SmoothCmdSet radius,minor $2 SmoothUpdate} + | SIGMA_ numeric {SmoothCmdSet sigma $2 SmoothUpdate} + | SIGMAMINOR_ numeric {SmoothCmdSet sigma,minor $2 SmoothUpdate} + | ANGLE_ numeric {SmoothCmdSet angle $2 SmoothUpdate} + ; + +function : BOXCAR_ {set _ boxcar} + | ELLIPTIC_ {set _ elliptic} + | TOPHAT_ {set _ tophat} + | GAUSSIAN_ {set _ gaussian} + ; + +%% + +proc smooth::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12