From 008b58aed410034000a2398ef97e93ea8d5eb549 Mon Sep 17 00:00:00 2001 From: William Joye Date: Mon, 26 Feb 2018 11:56:59 -0500 Subject: cmd parsers --- ds9/library/zoomlex.fcl | 49 ---------------------------------------------- ds9/library/zoomparser.tac | 46 ------------------------------------------- ds9/parsers/zoomlex.fcl | 49 ++++++++++++++++++++++++++++++++++++++++++++++ ds9/parsers/zoomparser.tac | 46 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 95 deletions(-) delete mode 100644 ds9/library/zoomlex.fcl delete mode 100644 ds9/library/zoomparser.tac create mode 100644 ds9/parsers/zoomlex.fcl create mode 100644 ds9/parsers/zoomparser.tac diff --git a/ds9/library/zoomlex.fcl b/ds9/library/zoomlex.fcl deleted file mode 100644 index 79ff034..0000000 --- a/ds9/library/zoomlex.fcl +++ /dev/null @@ -1,49 +0,0 @@ -%{ -source $ds9(root)/library/zoomparser.tab.tcl -%} - -%option noyywrap -%option caseless -%option nodefault -%option nointeractive -#%option stack -%option yylineno -#%option debug - -D [0-9] -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_} - -# INT -[+-]?{D}+ {set zoom::yylval $yytext; return $zoom::INT_} - -# REAL -[+-]?{D}+"."?({E})? | -[+-]?{D}*"."{D}+({E})? {set zoom::yylval $yytext; return $zoom::REAL_} - -# Quoted STRING -\"[^\"]*\" {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_} - -# Quoted STRING -\'[^\']*\' {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_} - -# Quoted STRING -\{[^\}]*\} {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_} - -# STRING -\S+\S+ {set zoom::yylval $yytext; return $zoom::STRING_} - -\s # ignore whitespace - -. {set zoom::yylval $yytext; return $zoom::yylval} - -%% - diff --git a/ds9/library/zoomparser.tac b/ds9/library/zoomparser.tac deleted file mode 100644 index 16d7ade..0000000 --- a/ds9/library/zoomparser.tac +++ /dev/null @@ -1,46 +0,0 @@ -%{ -%} - -%token INT_ -%token REAL_ -%token STRING_ - -%start command - -%token CLOSE_ -%token IN_ -%token FIT_ -%token OPEN_ -%token OUT_ -%token TO_ - -%% - -command : {ProcessRealizeDS9} zoom - ; - -zoom : numeric {Zoom $1 $1} - | numeric numeric {Zoom $1 $2} - | OPEN_ {PanZoomDialog} - | CLOSE_ {PanZoomDestroyDialog} - | IN_ {Zoom 2 2} - | OUT_ {Zoom .5 .5} - | TO_ zoomTo - ; - -zoomTo: FIT_ {ZoomToFit} - | numeric {global zoom; set current(zoom) " $1 $1 "; ChangeZoom} - | numeric numeric {global zoom; set current(zoom) " $1 $2 "; ChangeZoom} - ; - -numeric : INT_ {set _ $1} - | REAL_ {set _ $1} - ; - -%% - -proc zoom::yyerror {msg} { - puts stderr "$msg:" - puts stderr "$zoom::yy_current_buffer" - puts stderr [format "%*s" $zoom::index_ ^] -} diff --git a/ds9/parsers/zoomlex.fcl b/ds9/parsers/zoomlex.fcl new file mode 100644 index 0000000..79ff034 --- /dev/null +++ b/ds9/parsers/zoomlex.fcl @@ -0,0 +1,49 @@ +%{ +source $ds9(root)/library/zoomparser.tab.tcl +%} + +%option noyywrap +%option caseless +%option nodefault +%option nointeractive +#%option stack +%option yylineno +#%option debug + +D [0-9] +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_} + +# INT +[+-]?{D}+ {set zoom::yylval $yytext; return $zoom::INT_} + +# REAL +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? {set zoom::yylval $yytext; return $zoom::REAL_} + +# Quoted STRING +\"[^\"]*\" {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_} + +# Quoted STRING +\'[^\']*\' {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_} + +# Quoted STRING +\{[^\}]*\} {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_} + +# STRING +\S+\S+ {set zoom::yylval $yytext; return $zoom::STRING_} + +\s # ignore whitespace + +. {set zoom::yylval $yytext; return $zoom::yylval} + +%% + diff --git a/ds9/parsers/zoomparser.tac b/ds9/parsers/zoomparser.tac new file mode 100644 index 0000000..16d7ade --- /dev/null +++ b/ds9/parsers/zoomparser.tac @@ -0,0 +1,46 @@ +%{ +%} + +%token INT_ +%token REAL_ +%token STRING_ + +%start command + +%token CLOSE_ +%token IN_ +%token FIT_ +%token OPEN_ +%token OUT_ +%token TO_ + +%% + +command : {ProcessRealizeDS9} zoom + ; + +zoom : numeric {Zoom $1 $1} + | numeric numeric {Zoom $1 $2} + | OPEN_ {PanZoomDialog} + | CLOSE_ {PanZoomDestroyDialog} + | IN_ {Zoom 2 2} + | OUT_ {Zoom .5 .5} + | TO_ zoomTo + ; + +zoomTo: FIT_ {ZoomToFit} + | numeric {global zoom; set current(zoom) " $1 $1 "; ChangeZoom} + | numeric numeric {global zoom; set current(zoom) " $1 $2 "; ChangeZoom} + ; + +numeric : INT_ {set _ $1} + | REAL_ {set _ $1} + ; + +%% + +proc zoom::yyerror {msg} { + puts stderr "$msg:" + puts stderr "$zoom::yy_current_buffer" + puts stderr [format "%*s" $zoom::index_ ^] +} -- cgit v0.12