Docs/Scripting Dialect EBNF.txt

Tue, 06 Jul 2021 10:22:49 +0300

author
cemkalyoncu
date
Tue, 06 Jul 2021 10:22:49 +0300
branch
4.x-dev
changeset 1701
b168349a931d
parent 830
dc937409ad24
permissions
-rw-r--r--

* Image/Bitmap rotate

(* missing: operator keyword *)

(* Language Productions *)

statement = keyword_call | function_call | assignment, [";" | "\n"];

variable = identifier;

namespace = [identifier, ":"], identifier, ":"

element_series = ".", identifier, {".", identifier}

assignment = variable, [element_series], "=", expression;

function_call = term, "(", function_parameters, ")";
function_parameters = expression, {",", expression};

keyword_call = variable_identifier, [keyword_parameters];
keyword_parameters = expression, {" ", expression};

(* identifier is for constant or in function call, for function name *)
term = "(", expression, ")" | postfix_expression_operator | function_call | literal | [namespace], identifier | variable, [element_series]

expression = term, {function_identifier, term};

postfix_expression_operator = term, ("[", {parameter}, "]") | ("{", {parameter}, "}");

(* Literals & Identifiers *)
int_literal = ["-"], digit, {digit};

float_literal = int_literal, ".", {digit}; (* numbers after . is not required, thus 1. is valid *)

string_atom = letter | digit | symbol, {letter | digit | symbol};

string_literal = '"', string_atom, '"' | "'", string_atom, "'";

boolean_literal = "true" | "false";

literal = int_literal | float_literal | string_literal | boolean_literal;

function_identifier = "_" | symbol | letter, {"_" | digit | symbol | letter};

variable_identifier = letter | digit | "_",  { letter | digit | "_" };

identifier = letter | "_",  { letter | digit | "_" };

(* Terminals *)
letter = "A" | "B" | ... | "Z" | "a" | ... | "z";

non_zero_digit  = "1" | ... | "9";

zero = "0";

digit = non_zero_digit | zero;

symbol = "+" | "-" | "*" | "/" | "<" | ">" | "=" | "|" | ...;

white_space = "\n" | "\t" | "\r" | " ";



(* TEST CASES

fn(2, 3)
fn(2, 3)()
fn($a)[2]
$a = fn(){2, "dsf"}

*)

mercurial