Skip to content

Command script parsing

Martin Helmut Fieber edited this page Mar 21, 2021 · 8 revisions

Example

Command script example from the configuration file:

# litr.toml
build = "echo %{param}"

Parsing

Simplified Backus–Naur form (BNF [reference]):

# Entry point:
expression = literal
  | or_statement
  | if_statement
  | function_combinator
  | function
  | variable

literal = string;
string = "'" .* "'";

or_statement = if_statement "or" expression

if_statement = functions expression

functions = function ("and" function)*

function = function_name "(" (expression ("," expression)*)? ")"
function_name = alpha (alpha | digit)*

variable = short_variable | long_variable
short_variable = strict_alpha
long_variable = strict_alpha (alpha | digit)+

digit = 0-9
alpha = A-Za-z_;
strict_alpha = A-Za-z;

Legend:

  • | Or
  • () Grouping
  • ? Optional
  • * Repeat 0 to n times
  • + Repeat 1 to n times

Examples

Todo

Clone this wiki locally