Skip to main content
Version: 2.4

ARMR Language Syntax

The structure of the ARMR language and syntax is loosely based on the YAML syntax. Users familiar with
YAML and its syntax will be comfortable with programming ARMR Mods. ARMR Mods use a file
extension of .armr; the content of the file is plain-text and can be written/viewed in any text editor.
The following is a high-level overview of what the ARMR language syntax looks like.

app("Security Rules"):
    requires(version: "ARMR/2.0")

http("An ARMR HTTP Rule"):
        ...
    endhttp



marshal("An ARMR Marshal Rule"):
        ...
    endmarshal



dns("An ARMR DNS Rule"):
        ...
    enddns



socket("An ARMR Socket Rule"):
        ...
    endsocket



filesystem("An ARMR FileSystem Rule"):
        ...
    endfilesystem



sql("An ARMR SQL Rule"):
        ...
    endsql



library("An ARMR Library Rule"):
        ...
    endlibrary



patch("An ARMR Patch Rule"):
        ...
    endpatch

endapp

Studying the syntax at a high-level, we can see a pattern of block declarations, where each block has an
opening declaration, and an ending declaration. Blocks can also take statements, which are child
components of each block. Statements are used to describe configuration for the block.

Block

All blocks must abide by the following rules,

  • Blocks must have an opening and closing declaration.

  • The opening declaration starts with the <block-name>.

  • followed by a unique quoted string inside parenthesis to name the block.

  • followed by a colon, which indicates to the ARMR engine that the block is open and should expect a closing declaration.

  • Each proceeding line after a block is opened will be a statement of that block until it is closed.

  • Each open block must be closed with the keyword end<block-name>.

Block Example


http("An ARMR HTTP Rule"):
    ...
endhttp

Statement

All statements must abide by the following rules,

  • A statements is a declaration that is not open or closed.

  • Notice that statements do not have a colon after the parenthesis.

  • All the configuration for the statement exists within the parenthesis.

  • The configuration is made up of key:value pairs.

  • Some key:value pairs may be optional. If optional, they can be omitted.

  • If only one key:value pair is mandatory, for most cases it is not necessary to state the key, and just pass the value. Otherwise it is recommended to provide both the key and the value.

  • Some values are keywords, and do not need to be quoted. It is only necessary to quote strings that are user defined, such as a file path, or the name of parameter in a http request.

  • The order of the key:value pairs is not strict and can be presented in any order.

Statement Example


requires(version: "ARMR/2.0")

Types Of Values

Values can be of any of these types,

  • keyword: an unquoted string that has a defined meaning within the ARMR language.

  • string: any sequence of characters surrounded by double quotes. eg: "an example string".

  • integer: an unquoted whole number without decimal point.

  • float: an unquoted number with decimal point.

  • boolean: an unquoted true or false. The value is not case sensitive.

  • dictionary: a collection of different key:value types separated by commas, and encapsulated within curly brackets. example: {"personal data form", id: 32, name: "John"}.

  • list: a collection of values of the same type, separated by commas, and encapsulated within square brackets. example: [2, 3, 32, 100].

  • dictionary and a list value can contain other dictionaries and lists inside them.

Comments

It is possible to include comments in an ARMR File. There are two scenarios to mention,

  • The hash symbol (also know as the pound symbol) # can be used throughout the entire ARMR File. This is used for commenting on a per-line basis. There is no block comment equivalent.

  • When inside an ARMR App declaration, it is possible to use a double forward-slash // for a single line comment or the forward-slash with star /* */ for block comments.


# This kind of comment

# can be used anywhere

# in an ARMR File.

app("Security Rules"):
    requires(version: "ARMR/2.0")

// This is a line comment
    // and can be used within
    // an ARMR App.
    http("An ARMR HTTP Rule"):
        ...
    endhttp

/_
        This is a block comment
        that can be used within
        an ARMR App.
    _/

endapp

Escape Character

Any character is legal as part of the string, even double-quotes, as long as they are escaped. Escaping can be achieved by using the back-slash character \. A backslash literal should also be escaped with a backslash to distinguish it from an escape character. Not escaping backslashes \ or double quotes " could lead to unexpected behaviour.

ValidInvalid
"hello\\ world\"""hello world\"
"hello w"rld"
"hello w\\"orld"

The following ARMR App name is valid,


app("App name with \\ and \""):
endapp

The following ARMR App name is invalid,


app("App name ending slash\"):
endapp

Formatting

Blocks do not need to be separated by new line characters, meaning that the entire contents of an ARMR file could be written on a single line. However, it is strongly recommend that users do not write rules in this fashion as this will make it extremely difficult to read.


app("Security Rules"):requires(version:"ARMR/2.0")endapp

Blocks, components, and keywords must be declared in lowercase as the parser is case-sensitive. The following will not be allowed to load. Notice the malformed ApP and EnDapp.


app("Security Rules"):
    requires (version: "ARMR/2.0")

endapp