This topic describes the conventions of annotations, identifiers, data types, variables, operators, clauses, and functions in the EdgeScript (ES) syntax.

Note You must not use double quotation marks (") in ES.
Syntax Rule
Annotations All annotations must start with a number sign (#). Example: # This is annotation.
Identifiers When you use identifiers, you must comply with the following rules:
  • Identifiers are case-sensitive. An identifier can contain letters, digits, and underscores (_). It must start with a letter or an underscore (_).
  • All names of built-in variables, custom variables, built-in functions, and custom functions must comply with the identifier conventions.
Data types The following data types and rules are supported in ES syntax:
  • String

    Use a pair of single quotation marks (') to quote a string, for example, 'hello, EdgeScript'.

  • Number

    Use decimal numbers, for example, 10, -99, or 1.1.

  • Boolean
    • true
    • false
  • Dictionary
    Data is stored in the form of key-value pairs in a dictionary.
    • []: empty string.
    • ['key1', 'key2', 'key3']:
      • 1 -> 'key1'
      • 2 -> 'key2'
      • 3 -> 'key3'
    • ['key1' = 'value1', 'key2' = 1000]:
      • 'key1' -> 'value1'
      • 'key2' -> 1000
Variables
  • Definition: A variable is a symbolic name associated with a value that may change. The meaning assigned to a variable indicates the usage of the variable.
  • How to use: Variables contain built-in variables and custom variables. Both built-in and custom variables are referenced by using their names. Example: host.
    Notice
    • To indicate that the variable is a built-in variable, add a dollar sign $ before the variable name. Example: $host.
    • A custom variable and a built-in variable cannot use the same name.
Operators
  • =: the assignment operator.
    • Example: seckey = 'ASDLFJ234dxvf34sDF'
    • Example: seckeys = ['key1', 'key2']
  • -: the minus operator.

    Example: inum = -10

  • Built-in functions are used to process different types of data. No additional operators are provided.
Clauses
  • Condition clause
    if condition {   
       ...
    }
    
    if condition1 {   
       if conditon2 {
            ...
       }
    }
    
    if condition {
       ...
    } else {
       ...
    }
  • Clause descriptions
    • A condition contains one of the following elements: literal constant, variable, and function call.
    • Body
      • The body can be empty.
      • Multiple statements are allowed. Only one statement is allowed on each line.
    • Statement wrapping is allowed.
    • Coding style

      The opening brace ({) must follow if condition and must be on the same line with if condition.

Functions
  • Syntax
    def Function name(Parameter list) {
       ...
    }
  • Descriptions
    • Parameter list
      • The parameter list can be empty.
      • Multiple parameters are allowed. Separate parameters with commas (,).
    • Body
      • The body can be empty.
      • Multiple statements are allowed. Only one statement is allowed on each line.
      • The return clause is supported for the return value.
    • Coding style

      The opening brace ({) must follow def function name(Parameter list) and must be on the same line with def.

  • Function call

    You must use Function name() to call both built-in and custom functions.