Complete example given here:
https://paulscherrerinstitute.github.io/StreamDevice/protocol.html

================
Complete example
================

# This is an example protocol file

Terminator = CR LF;

# Frequency is a float
# use ai and ao records

getFrequency {
    out "FREQ?"; in "%f";
}

setFrequency {
    out "FREQ %f";
    @init { getFrequency; }
}

# Switch is an enum, either OFF or ON
# use bi and bo records

getSwitch {
    out "SW?"; in "SW %{OFF|ON}";
}

setSwitch {
    out "SW %{OFF|ON}";
    @init { getSwitch; }
}

# Connect a stringout record to this to get
# a generic command interface.
# After processing finishes, the record contains the reply.

debug {
    ExtraInput = Ignore;
    out "%s"; in "%39c"
}

---

(source_file

 (comment)

 (assignment
  (variable_name)
  (string
   (number (ascii_name))
   (number (ascii_name))))

 (comment)
 (comment)

 (function
  (function_name)
  (command
   (command_name)
   (string (quoted_literal)))
  (command
   (command_name)
   (string
	(quoted_literal (format_converter)))))

 (function
  (function_name)
  (command
   (command_name)
   (string
	(quoted_literal (format_converter))))
  (handler
   (handler_name)
   (function_name)))

 (comment)
 (comment)

 (function
  (function_name)
  (command
   (command_name)
   (string (quoted_literal)))
  (command
   (command_name)
   (string
	(quoted_literal
	 (format_converter
	  (format_enum
	   (enum_specifier (enum_constant))
	   (enum_specifier (enum_constant))))))))

 (function
  (function_name)
  (command
   (command_name)
   (string
	(quoted_literal
	 (format_converter
	  (format_enum
	   (enum_specifier (enum_constant))
	   (enum_specifier (enum_constant)))))))
  (handler
   (handler_name)
   (function_name)))

 (comment)
 (comment)
 (comment)

 (function
  (function_name)
  (assignment
   (variable_name)
   (keyword))
  (command
   (command_name)
   (string
	(quoted_literal (format_converter))))
  (command
   (command_name)
   (string
	(quoted_literal
	 (format_converter (number_literal)))))))
