Lexical Conventions

From KynetxDocs

Jump to: navigation, search

This section gives an informal account of some of the lexical conventions used in writing KRL rulesets.

Upper and lower case forms of a letter are distinguished--that is KRL is case-sensitive.

Identifiers

Identifiers in KRL are a sequence of letters, digits, and the underscore ``_. Identifiers must begin with a character that cannot be a number. Here are some examples of identifiers:

xyz
xyz_
xyz1
xyz_1
xyz_abc

Identifiers in KRL rulesets are used as variables.

Whitespace and Comments

Whitespace characters are spaces, tabs, and newlines. Whitespace is used for improved readability and as necessary to separate tokens from each other, a token being an indivisible lexical unit such as an identifier or number, but is otherwise insignificant. Whitespace may occur between any two tokens, but not within a token. Whitespace may also occur inside a string, where it is significant.

A double slash(//) indicates the start of a comment. The comment continues to the end of the line on which the double slash appears. Comments are invisible to KRL, but the end of the line is visible as whitespace. This prevents a comment from appearing in the middle of an identifier or number.

// this is a comment
ruleset foo {
...
}

Other Notations

  • . + - These are used in numbers.
  • ( ) Parentheses are used for grouping
  • " The double quote character is used to delimit strings.
  • [ ] { } | Left and right square brackets and curly braces and vertical bar are used in KRL to delimit blocks, arrays, etc.
Personal tools