RGBScript is a C-style, imperative programming language that supports basic types, variables, functions, and control structures.
This language gets its name from the fact that it outputs programs and program results in a colorful, fun way.
Types:
Arithmetic (Integer)
Boolean
String
STRING represents a sequence of UTF-8 encoded characters, ex: a, abc, abcdegfh
INT represents an integer in java, ex: 1, 125, 12345
Anything surrounded by single quotes is also a terminal, ex: '(' ')' 'and' 'or' '+'
arithmetic_expression ::= arithmetic_term addop arithmetic_expression | arithmetic_term
arithmetic_term ::= arithmetic_factor mulop arithmetic_term | arithmetic_factor
arithmetic_factor ::= INT | ( arithmetic_expression ) | - arithmetic_factor | arithmetic_factor powop arithmetic_factor | var_name | function_call
addop ::= '+' | '-'
mulop ::= '*' | '/' | '%'
power ::= '^'
atomic_boolean ::= 'true' | 'false'
boolean_expression ::= boolean_term 'or' boolean_expression | boolean_term
boolean_term ::= boolean_factor 'and' boolean_term | boolean_factor
boolean_factor ::= atomic_boolean | 'not' boolean_factor | '(' boolean_literal ')' | relation | var_name | function_call
string_expression ::= string_factor | string_factor '&' string_expression
string_factor ::= '"' STRING '"' | var_name | function_call
function ::= STRING
function_call ::= function '(' function_args ')' | function ( )
functionargs ::= function_arg (, function_arg)*
function_arg ::= expression
var_type ::= 'boolean' | 'int' | 'string' | 'typeless' | 'any'
var_name ::= STRING
var_decl ::= 'var' var_type var_name '<--' expression;
augmented_assignment_operator ::= '<--(+)' | '<--(-)' | '<--(*)' | '<--(/)' | '<--(%)' | '<--(&)'
assignment_operator ::= augmented_assignment_operator | '<--'
assignment ::= var_name assignment_operator expression ';'
relop ::= '>' | '<' | '>=' | '<=' | '==' | '!='
relation ::= arithmetic_expression relop arithmetic_expression
typeless_expression ::= var_name | function_call | '(' typeless_expression ')'
typed_expression ::= arithmetic_expression | boolean_literal | string_expression | typeless_expression
expression ::= typeless_expression | typed_expression
statement ::= function_call ';' | var_decl ';' | assignment ';' | 'terminate' ';'
if_block ::= if '(' boolean_literal ')' (statement | block) | if '(' boolean_literal ')' '{' (statement | block)* '}'
else_block ::= else (statement | block) | else '{' (statement | block)* '}'
conditional_block ::= if_block | if_block else_block
while_block ::= 'while' '(' boolean_literal ')' (statement | block) | 'while' '(' boolean_literal ')' '{' (statement | block)* '}'
block ::= conditional_block | while_block
program ::= (statement | block)*