Click Notes II - Click Script Language

The Click programming language was developed to configure Click routers, but nowadays you also can use it to write test cases for Click elements.

  1. Basic Syntax
  2. Element Group
  3. Compound Element
  4. Script
  5. Testie

Basic Syntax

The Click Script Language defines a configuration graph, which consists of connected elements. Each element has an element class specified by class name. Elements are connected through their input and output ports. Input and output ports are distinguished by number, while elements are distinguished by name.

Click configuration strings are comma-separated lists of arguments delimited by parentheses. The fundamental syntax of Click Script Language is:

 
  
  1. name :: class(config-string); // declare element object
  2. name1, name2, ..., nameN :: class(config); // declaration shorhand
  3. name1[port1] -> [port2]name2; // connect two elements
  4. name1[port1] -> [port2a]name2[port2b] -> [port3]name3; // piggyback connections
  5. name1 -> name2 :: class(config-string) -> name3; // declaring elements inside connections is allowed
  6. name1 -> class(config-string) -> name3; // anonymous element
  7. require(requirement[, requirement …]); // list config requirements
  8. n1, n2 :: class -> n3; // many-to-one connections
  9. // many-to-many connections:
  10. // A many-to-many connection matches output ports to input ports.
  11. // There must be as many ports on the left as on the right.
  12. // '=>' is the many-to-many connector.
  13. c[0], c[1], c[2] => Paint(0), Paint(1), Paint(2) -> next;
  14. c => Paint(0), Paint(1), Paint(2) -> next;

- See more at: http://www.bo-yang.net/2015/01/07/click-notes-click-language/#sthash.ayG2hR5q.dpuf

你可能感兴趣的:(网络/通信)