--- title: Variable declaration version: 1.0.0 state: draft --- # Variable declaration ## Terms - list: multiple tokens seperated by spaces - token: a particular fully formed symbol or set of symbols representing a specific meaning in rabbitscript and that has no more specific underlying meaning. (i.e. a VARNAME is a token but not an EXPRESSION, however a LITERAL or an OPERAND are tokens) - meaning: something that a parser of the grammar could act on to verify syntaxic validity (is a token valid in relation to the token that follows or precedes it) - representation: something that defines meaning and that a parser of the grammar could act on to verify a token's validity (is a token properly represented or does it contain a symbol that breaks the validity of its representation) ## Grammar ### Declaration ``` VARNAME = EXPRESSION ``` ### VARNAME A VARNAME is represented by a series of alphanumeric characters: ``` alphanum+ ``` ### EXPRESSION ``` (OPERATION | LITERAL) ``` ### LITERAL A literal is represented by a set of alphanumeric symbols. If the symbols can be parsed as a number then the type is a number, otherwise it is a a string. ``` (number|string) ``` ### OPERATION Operations are calculations on numbers using reverse polish notation. An operation is defined as a list of n operands (where n>1) followed by a a list of n-1 operators, or otherwise said an operand followed by n>=1 operands followed by n operators: ``` OPERAND (OPERAND ){N} OPERATOR{N} ``` An operand is defined strictly as a number (integer or floating). An operator is defined by the addition, subtraction, multiplication and division symbols as follows: ``` (+|-|*|/) ``` ## Example Declares a variable `a` with the number value 15. ``` a=15 ``` Declares a variable `b` with the string value "a string". ``` s=a string ``` Declares the variable `o` that is an operation resulting in the number value 6. ``` o=1 5 + ``` The same as above can be specified with an arbitrary number of spaces around the tokens. They should be trimmed by parsers: ``` o = 1 5 + ```