syntax

interpreter syntax

DESCRIPTION

This syntax summary attempts to present all the built-in keywords, operators and commands of spec. The grammar rules listed below are very similar to those given in the standard manuals describing the C language. Operators are listed in order of precedence, with the highest precedence operators listed first.

The summary is not a complete representation of the spec syntax. Sub-array syntax is not shown, nor is array element value assignment by initialization, as in arr = [ 1:2, 3:4 ].

The following terms are used:

lvalue
"left value", something that can go on the left side of the equals sign.
binop
Binary operator (+, -, etc.).
asgnop
Assignment operator (=, +=, etc.).
identifier
A variable, which is something that starts with a letter or underscore (_) and can be followed by additional characters consisting only of letters, digits or underscores.
identifier-list
A space- or comma-separated list of identifiers.
pattern
An alphanumeric string possibly containing the metacharacters * which matches any string, ? which matches any single character and [...], which matches any string that contains the characters within the square brackets. Two characters separated by a hyphen specify a range of characters that will match. An initial ^ negates the enclosed character set.
pattern-list-opt
An optional space-separated list of patterns.
expr-opt
An optional expression.
expr-list-opt
An optional expression list.
[;]
A semicolon or a newline. (A semicolon after a statement is optional if the statement is followed by a newline.)

EXPRESSIONS

expression:

lvalue
numeric-constant
string-constant
( expression )
function ( expression-list )
- expression
! expression
~ expression
++ lvalue
-- lvalue
lvalue ++
lvalue --
expression ? expression : expression
expression binop expression
lvalue asgnop expression
expression in identifier

expression-list:

expression , expression
lvalue:
identifier
identifier [ expression ]
identifier [ expression ] [ expression ]
@ lvalue

binop:

* /  %
+ -
>> <<
> <  <=  >=
== !=
&
^
|
&&
||

asgnop:

= +=  -=  *=  /=  %=  >>=  <<=  &=  ^=  |=

array_type:

byte
ubyte
short
ushort
long
ulong
long64
ulong64
float
double
string

array_decl:

[ array_type ] array identifier [ expr ]
[ array_type ] array identifier [ expr ] [ expr ]

array_decl-list:

array_decl [ , ] array_decl

Statements

compound-statement:

{ statement-list }

statement-list:

statement
statement-list statement

statement:

compound-statement
expression [ ; ]
if ( expression ) statement
if ( expression ) statement else statement
while ( expression ) statement
for ( expr-list-opt ; expr-opt ; expr-list-opt ) statement
for ( identifier in identifier ) statement

break [ ; ]
continue [ ; ]
exit [ ; ]
return expr-opt [ ; ]

history expr-opt [ ; ]
lscmd pattern-list-op [ ; ]
syms pattern-list-op [ ; ]

print expression-list [ ; ]
eprint expression-list [ ; ]

global identifier-list [ ; ]
global identifier = expression [ ; ]
constant identifier expression [ ; ]
constant identifier = expression [ ; ]
unglobal identifier-list [ ; ]
local identifier-list [ ; ]
local identifier = expression [ ; ]
delete identifier [ expression ] [ ; ]

array_decl-list [ ; ]
local array_decl-list [ ; ]
global array_decl-list [ ; ]
shared array_decl-list [ ; ]
extern shared array_decl-list [ ; ]

def identifier string-constant [ ; ]
rdef identifier expression [ ; ]
undef pattern-list-op [ ; ]
prdef pattern-list-op [ ; ]
lsdef pattern-list-op [ ; ]

memstat [ ; ]
savstate [ ; ]
reconfig [ ; ]
getcounts [ ; ]
move_all [ ; ]
move_cnt [ ; ]
sync [ ; ]
quit [ ; ]

FUNCTIONS

Utility Functions

  chdir() unix() time() date()
  sleep() file_info() getenv() get_history()
  queue() encode() decode() spec_par()

Evaluation Functions

  eval() eval2()

Command Files

  dofile() qdofile()

Help Functions

  gethelp() whatis()

Controlling Output Files

  open() close() on() off()

Macro-Related Functions

  cdef() clone() strdef()

User Input and Output

  input() getline() printf() tty_cntl()
  yesno() sscanf() fprintf() tty_fmt()
  getval()   eprintf() tty_move()
  getsval() spec_menu()    

Counting and Moving

  mcount() dial() get_lim() wait()
  tcount() user() set_lim() stop()
  cnt_mne() motor_mne() chg_dial() set_sim()
  cnt_name() motor_name() chg_offset()  
  cnt_num() motor_num() read_motors()  
  counter_par() motor_par() move_info()  
         
  mca_get() mca_sget() image_get()  
  mca_put() mca_sput() image_put()  
  mca_par() mca_spar() image_par()  
  mca_sel()      

Plotting and Analysis

  array_copy() plot_cntl() h5_file()
  array_dump() plot_move() h5_attr()
  array_fit() plot_range() h5_data()
  array_op() splot_cntl() h5_link()
  array_plot() fmt_read()  
  array_read() fmt_write()  
  array_pipe() fmt_close()  
       
  data_grp() data_uop() data_read()
  data_info() data_bop() data_plot()
  data_put() data_anal() data_fit()
  data_get() data_dump() data_pipe()
  data_nput()    

CAMAC Hardware

  ca_get()
  ca_put()
  ca_fna()
  ca_cntl()

User Level Access To Hardware Interfaces

  gpib_get() ser_get() sock_get() vme_get()
  gpib_put() ser_put() sock_put() vme_put()
  gpib_par() ser_par() sock_par() vme_get32()
  gpib_poll()     vme_put32()
  gpib_cntl()     vme_move()
         
  ca_get() vxi11_get() fbus_put()  
  ca_put() vxi11_put() fbus_get()  
  ca_fna() vxi11_par()    
  ca_cntl()      
         
  taco_io() tango_io() epics_get() madoca_io()
  taco_dc() tango_get() epics_put()  
  taco_db() tango_put() epics_par()  
    tango_db()    

PC Port Hardware

  port_get() port_getw() port_put() port_putw()

Server/Client Functions

  prop_send() remote_stat() remote_eval()
  prop_get() remote_par() remote_async()
  prop_put() remote_cmd() remote_poll()
  prop_watch()    

Hooks To User-Added C-Code Functions

  calc()

String Handling

  asc() length() substr()
  tolower() index() sprintf()
  toupper() split()  

String Handling With Regular Expressions

  sub() gsub() gensub()
  rsplit() match()  

Useful Conversion Functions

  int() bcd() dcb() rad() deg()

Standard Math Functions

  exp() pow() cos() acos()
  exp10() sqrt() sin() asin()
  log()   tan() atan()
  log10() rand()   atan2()
  fabs() srand()    

SEE ALSO

funcs flow