t.snap-agent.1.4.2.source-code.grammar.bnf Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-agent Show documentation
Show all versions of snap-agent Show documentation
Dynamic scripting for the JVM
# | represents a logical "or"
# * represents one or more
# + represents at least once
# ? represents one or none
# <> define a production
# () groups productions
# {} group productions, first match wins
# _ represents whitespace
# [] represents a symbol
# '' represents a literal text value
sign = {'-' | '+'};
number = ?{[hexidecimal] | [binary] | [decimal]};
boolean = {'true' | 'false'};
null = 'null';
literal = { | | | [template] | [text]};
# operators
assignment-operator = {'=' | '**=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='};
arithmetic-operator = {'**' | '+' | '-' | '*' | '/' | '%'};
binary-operator = {'&' | '|' | '^' | '>>>' | '>>' | '<<'};
coalesce-operator = '??';
comparison-operator = {'>=' | '<=' | '>' | '<' | '===' | '!==' | '==' | '!=' | 'instanceof' | '!instanceof'};
conditional-operator = {'&&' | '||'};
prefix-operator = {'!' | '~' | '+' | '-'};
increment-operator = '++';
decrement-operator = '--';
reference-operator = {'?.' | '.'};
this = 'this';
class = 'class';
super = 'super';
module = 'module';
# ((array[x])[x] -> ([])
variable = { | | | [identifier] | [type]};
variable-reference = { | };
range = '..';
collection-index = ( '[' ']' ) * { '('')' | '['']' };
constructor = 'new';
function = { | [identifier]};
function-argument-list = ?*(',');
function-invocation = ( '(' ')' )* { '(' ')' | '['']' };
function-reference = '::' ;
reference-invocation = ;
reference-index = ;
reference = { |
} ;
reference-part = { |
|
|
|
|
|
} ;
reference-navigation = *();
reference-type = *();
list-entry = ;
list-entry-list = *(',');
set-entry = ;
set-entry-list = *(',');
map-key = [identifier];
map-entry = ( | )':';
map-entry-list = *(',');
type-reference = *('.');
type-reference-part = [type];
trait-reference = *('.');
trait-reference-part = [type];
construct-object = 'new'_'('?')';
construct-list = '[]' | '['']';
construct-array = 'new'_+('['']');
construct-set = '{}' | ('{''}');
construct-map = '{:}' | ('{''}');
construct = { |
|
|
|
};
argument = { |
|
|
|
} |
|
|
;
argument-list = *(',');
assignment = ?_?_;
assignment-operand = '('')';
prefix-operation = ;
prefix-operand = { | '('')'};
increment = { | };
prefix-increment = ;
postfix-increment = ;
decrement = { | };
prefix-decrement = ;
postfix-decrement = ;
increment-decrement = | ;
increment-decrement-operand = | '('')';
reference-operand = | '('')';
value-operand = | | | ;
comparison-operand = | | | | '('')';
comparison = ?_?_;
conditional-operand = |
|
|
|
|
'('')';
conditional-result = '('')';
conditional = { | | '('')'};
combination = { | }?_?_;
choice = '?'':';
# ?? is done in calculation
null-coalesce = '??';
# use this over ?
substitute = { | };
calculation-operator = { | | };
calculation-operand = | | '('')' | '('')';
calculation-list = ? _ ? _ *();
calculation = | '('')';
expression = { |
|
|
} |
|
|
|
|
|
'('')';
function-constraint = '('')';
type-constraint = ;
array-dimension = '[]';
array-constraint = +;
list-constraint = '[]';
set-constraint = '{}';
map-constraint = '{:}';
constraint = { | | | | | };
return-statement = 'return'*(?_{ | })';';
break-statement = 'break;';
continue-statement = 'continue;';
throw-statement = 'throw'?_( | )';';
assert-statement = 'assert'?_';';
expression-statement = ( | | )';';
compound-statement = '{'+'}';
terminal-statement = ';';
empty-statement = '{}';
group-statement = { | };
control-statement = { | | | };
statement = { |
|
|
|
|
|
|
|
|
};
assignment-variable = [identifier];
assignment-expression = ( | | | | );
assignment-statement = ';';
declaration-modifier = {'var' | 'const'};
declaration = ?(':')?('=');
declaration-statement = _*(',')';';
if-statement = 'if''('')'?('else'?_);
while-statement = 'while''('')';
for-assignment = { | | };
for-assignment-list = *(',');
for-statement = 'for''('( | | )';'?()')';
for-in-statement = 'for''('?('var'_)([identifier])_'in'?_{ | }')';
loop-statement = {'loop' | 'for(;;)'};
conditional-statement = { |
|
|
|
|
|
};
switch-statement = 'switch''('')''{'*?'}';
switch-case = 'case'?_':'*;
switch-default = 'default'':'*;
match-statement = 'match''('')''{'*?'}';
match-case = 'case'?_':';
match-default = 'default'':';
synchronized-statement = 'synchronized' '('