All Downloads are FREE. Search and download functionalities are using the official Maven repository.

t.snap.1.2.1.source-code.grammar.bnf Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
# |  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' '('  ')' ;

try-block = 'try';
catch-block = 'catch''('  ')' ;
finally-block = 'finally' ;
catch-block-list = +;
try-statement = ? ? };
 
variable-argument = '...';

parameter-name = [identifier];
parameter-declaration = ???(':');
parameter-list = ?(*(','));

closure-parameter-list = '('')' | ?;
closure = ?_'->'?_{ | };

type-name = [type];
trait-name = [type];

annotation-name = [type];
annotation-list = *?_;
annotation-declaration = '@'?;
annotation-attributes = '('?')';
   
field-modifier = {'var' | 'const' | 'static' | 'public' | 'private'};
field-modifier-list = *(_);

function-modifier = {'static' | 'public' | 'private' | 'abstract' | 'override'};
function-modifier-list = *(_);
   
access-modifier = {'public' | 'private'};
access-modifier-list = *(_);
 
super-constructor = 'super''('?')';
this-constructor = 'this''('?')';

class-field-declaration = ?(':')?('=');
class-field = *(',')';';
class-function = '('')'?(':'){';' | };
class-constructor = 'new''('')'?(':'{ | });
class-part = { |  |  |  |  | };
class-hierarchy = ?{_'extends'_ | _'with'_}*(_'with'_);
class-definition = ?'class'_?{'{}' | '{'*'}'};

trait-constant = ?(':')'='';';
trait-hierarchy = *(_'extends'_);
trait-function = ?'('')'?(':'){';' | };
trait-part = { | };
trait-definition = ?'trait'_?{'{}' | '{'*'}'};
   
enum-hierarchy = *(_'with'_)};
enum-key = [identifier];
enum-value = ?('('')');
enum-list = *(',');
enum-constructor = 'new''('')';
enum-field-declaration = ?(':')?('=');
enum-field = *(',')';';
enum-function = '('')'?(':'){';' | };
enum-part = { |  | };
enum-definition = ?'enum'_?'{'?(';'*)'}';
   
inner-class-definition = ;
inner-enum-definition = ;
inner-trait-definition = ;
 
type-definition = { |  | };

full-qualifier = [qualifier]*('.'[qualifier]);
wild-qualifier = [qualifier]*('.'[qualifier])'.*';

import-static = 'import static'_( | )';';
import = 'import'_( | )?(' as '[type])';';
   
module-name = [identifier];
module-import = ;
module-function = '('')'?(':');
module-statement = { |  |  |  |  |  | };
module-definition = ?'module'_{ | '{'*{ |  | }'}'};
   
script-import =  | ;
script-function = 'function'_'('')'?(':');
script-statement = {  | 
				      | 
				      | 
				      | 
				      | 
				      | 
				      | 
				      | 
				      };
				     
script-package = *{ |  | };
script = *{ |  | };




© 2015 - 2024 Weber Informatics LLC | Privacy Policy