Edgescript® Statements Grammar
*** Lexical Structure ***
* Grammar of whitespace *
whitespace -> whitespace-item (opt)whitespace [WhitespaceHook]
whitespace-item -> line-break
whitespace-item -> inline-space
line-break -> "\n"
line-break -> "\r"
line-break -> "\r\n"
inline-space -> "\t" | " "
* Grammar of an identifier *
identifier-lower -> identifier-head-lower (opt)identifier-characters [IdentifierLowerHook]
identifier-upper -> identifier-head-upper (opt)identifier-characters [IdentifierUpperHook]
identifier-head-lower -> Lowercase letter a through z
identifier-head-lower -> "_"
identifier-head-upper -> Uppercase letter A through Z
identifier-head-upper -> "_"
identifier-character -> Upper- or lowercase letter a through z
identifier-character -> decimal-literal
identifier-character -> "_"
identifier-characters -> identifier-character (opt)identifier-characters
* Grammar of a literal *
literal -> numeric-literal | string-literal | boolean-literal | nil-literal | self-literal
boolean-literal -> boolean-literal-true | boolean-literal-false
boolean-literal-true -> [TrueHook]
boolean-literal-false -> [FalseHook]
nil-literal -> [NilHook]
self-literal -> [SelfHook]
* Grammar of an numeric literal *
numeric-literal -> decimal-literal
decimal-literal -> [DecimalSequenceHook]
* Grammar of a string literal *
string-literal -> static-string-literal
static-string-literal -> string-literal-apostrophe-delimiter quoted-apostrophe-text string-literal-apostrophe-delimiter
static-string-literal -> string-literal-quotation-delimiter quoted-quotation-text string-literal-quotation-delimiter
string-literal-apostrophe-delimiter -> "'"
quoted-apostrophe-text -> quoted-text-item (opt)quoted-apostrophe-text [ApostropheTextHook]
string-literal-quotation-delimiter -> "\""
quoted-quotation-text -> quoted-text-item (opt)quoted-quotation-text [QuotationTextHook]
quoted-text-item -> escape-sequence
quoted-text-item -> quoted-text-character | interpolated-text-expression
quoted-text-character -> Any Unicode scalar value except delimiter, \, U+000A, or U+000D
interpolated-text-expression -> "\\(" expression ")"
escape-sequence -> "\\" escaped-character
escaped-character -> "0" | "\\" | "t" | "n" | "r" | "'" | "\""
* Grammar of operators *
operator -> operator-expression
operator-expression -> operator-head (opt)operator-characters
operator-head -> "/" | "-" | "+" | "!" | "*" | "%" | "<" | ">" | "&" | "|" | "^" | "~" | "?"
operator-character -> operator-head
operator-character -> "="
operator-characters -> operator-character (opt)operator-characters
operator-characters -> "=="
infix-operator -> operator [InfixOperatorHook]
prefix-operator -> operator [PrefixOperatorHook]
postfix-operator -> operator [PostfixOperatorHook]
*** Types ***
* Grammar of a type *
type-identifier -> type [TypeIdentifierHook]
type -> class-identifier
type -> type-array-identifier
type -> type-dictionary-identifier
* Grammar of a class identifier *
class-identifier -> class-name (opt)class-argument-clause
class-name -> identifier-upper
* Grammar of an array type identifier *
type-array-identifier -> "[" type-identifier "]"
* Grammar of a dictionary type identifier *
type-dictionary-identifier -> "[" type-identifier ":" type-identifier "]"
*** Expressions ***
* Grammar of an expression *
expression -> prefix-expression (opt)infix-expressions (opt)formatting
* Grammar of a prefix expression *
prefix-expression -> (opt)prefix-operator postfix-expression
* Grammar of a postfix expression *
postfix-expression -> primary-expression (opt)postfix-operator
postfix-expression -> parenthesis
parenthesis -> "(" expression ")" [ParenthesisHook]
* Grammar of an infix expression *
infix-expression -> infix-operator postfix-expression (opt)infix-expression
infix-expression -> explicit-member-call (opt)infix-expression
infix-expression -> subscript-expression (opt)infix-expression
infix-expression -> assignment-expression
infix-expressions -> infix-expression (opt)infix-expressions
* Grammar of an assignment expression *
assignment-expression -> assignment-operator expression [AssignmentHook]
assignment-operator -> "="
* Grammar of a primary expression *
primary-expression -> access-expression
primary-expression -> literal-expression
primary-expression -> closure-expression
primary-expression -> branch-expression
primary-expression -> edge-path-expression
primary-expression -> function-call-expression
primary-expression -> lookup-expression
primary-expression -> initializer-call
primary-expression -> super-initializer-call
* Grammar of an access expression *
access-expression -> identifier-lower [ScopeAccessHook]
access-expression -> type-identifier [ScopeAccessHook]
* Grammar of a literal expression *
literal-expression -> literal | array-literal | dictionary-literal
* Grammar of a closure expression *
closure-expression -> attributes closure-declaration [ClosureDeclarationHook]
closure-declaration -> closure-signature expression
closure-declaration -> (opt)closure-signature code-block
closure-signature -> parameter-clause (opt)class-argument-clause (opt)closure-result "->"
closure-result -> ":" attributes type-identifier
* Grammar of a branch expression *
branch-expression -> if-expression
* Grammar of an if expression *
if-expression -> "if" condition-list if-block (opt)else-clause [IfHook]
if-block -> expression
if-block -> code-block
else-clause -> "else" else-block
else-block -> expression
else-block -> code-block
else-block -> if-expression
* Grammar of a code block *
code-block -> "{" statements "}"
array-literal -> "[" array-literal-items "]"
array-literal-items -> array-literal-item (opt)array-literal-continuation [ArrayLiteralItemsHook]
array-literal-continuation -> "," array-literal-items
array-literal-item -> expression
dictionary-literal -> "[" dictionary-literal-items "]"
dictionary-literal-items -> dictionary-literal-item (opt)dictionary-literal-continuation [DictionaryLiteralItemsHook]
dictionary-literal-continuation -> "," dictionary-literal-items
dictionary-literal-item -> expression ":" expression [DictionaryItemHook]
* Grammar of a edge-path expression *
edge-path-expression -> "\\" edge-path-list
edge-path-list -> (opt)edge-path-root edge-path-components (opt)edge-path-function [EdgePathHook]
edge-path-root -> edge-space-name
edge-space-name -> identifier-lower
edge-space-name -> type-identifier
edge-path-components -> edge-path-component (opt)edge-path-continuation
edge-path-continuation -> "." edge-path-components
edge-path-function -> "." identifier-lower
edge-path-component -> "." edge-path-element (opt)edge-path-postfix [EdgePathPartHook]
edge-path-element -> identifier-lower
edge-path-element -> "(" expression ")"
edge-path-postfix -> "?" | "!"
* Grammar of a function call expression *
function-call-expression -> identifier-lower function-call-argument-clause [FunctionCallHook]
function-call-argument-clause -> "(" (opt)function-call-argument-list ")"
function-call-argument-list -> function-call-argument (opt)function-call-argument-continuation [ArgumentListHook]
function-call-argument-continuation -> "," function-call-argument-list
function-call-argument -> (opt)argument-head expression [ArgumentHook]
argument-head -> argument-name ":"
argument-name -> identifier-lower
* Grammar of an initializer expression *
initializer-call -> identifier-upper function-call-argument-clause [InitializerCallHook]
* Grammar of an explicit member expression *
explicit-member-call -> "." identifier-lower (opt)function-call-argument-clause [ExplicitMemberHook]
* Grammar of a subscript expression *
subscript-expression -> "[" array-literal-items "]" [SubscriptExpressionHook]
*** Statements ***
* Grammar of a statement *
statement -> expression
statement -> declaration
statement -> control-transfer-statement
statements -> statement (opt)statements [StatementsHook]
condition-list -> condition
condition -> expression
* Grammar of a control transfer statement *
control-transfer-statement -> return-statement
* Grammar of a return statement *
return-statement -> "return" (opt)expression [ReturnHook]
*** Declarations ***
* Grammar of a declaration *
declaration -> class-declaration
declaration -> constant-declaration
declaration -> variable-declaration
declaration -> function-declaration
declaration -> initializer-declaration
* Grammar of a constant declaration *
constant-declaration -> attributes declaration-modifiers constant-match pattern-initializer-list [LetDeclarationHook]
constant-match -> "let" | "state"
* Grammar of a variable declaration *
variable-declaration -> attributes declaration-modifiers "var" pattern-initializer-list [VarDeclarationHook]
* Grammar of a pattern *
pattern-initializer-list -> pattern-initializer (opt)pattern-initializer-continuation [PatternInitializerListHook]
pattern-initializer-continuation -> "," pattern-initializer-list
pattern-initializer -> variable-definition (opt)initializer [PatternInitializerHook]
initializer -> "=" expression
variable-definition -> variable-name (opt)variable-class
variable-class -> ":" type-identifier
variable-name -> identifier-lower
* Grammar of a function declaration *
function-declaration -> function-head function-name function-signature function-body [FunctionDeclarationHook]
function-head -> declaration-modifiers (opt)attributes "func"
function-name -> identifier-lower
function-signature -> parameter-clause (opt)function-result
function-result -> ":" attributes type-identifier
function-body -> code-block
parameter-clause -> "(" (opt)parameter-list ")"
parameter-list -> parameter (opt)parameter-continuation [ParameterListHook]
parameter-continuation -> "," parameter-list
parameter -> (opt)external-parameter-name local-parameter-name type-annotation [ParameterHook]
external-parameter-name -> identifier-lower
local-parameter-name -> identifier-lower
type-annotation -> ":" attributes type-identifier (opt)type-array
type-array -> "..."
* Grammar of an initializer declaration *
initializer-declaration -> initializer-head parameter-clause initializer-body [InitializerDeclarationHook]
initializer-head -> declaration-modifiers "init"
initializer-body -> code-block
super-initializer-call -> "super" function-call-argument-clause [SuperInitializerCallHook]
* Grammar of a declaration modifier *
declaration-modifiers -> (opt)access-level-modifier (opt)class-modifier
access-level-modifier -> "private" | "public"
class-modifier -> "class"
* Grammar of a class declaration *
class-declaration -> attributes "class" class-name (opt)class-parameter-clause (opt)class-inheritance-clause class-body [ClassDeclarationHook]
class-name -> identifier-upper
class-inheritance-clause -> ":" class-inheritance-list
class-inheritance-list -> class-name (opt)class-inheritance-continuation [ClassInheritanceListHook]
class-inheritance-continuation -> "," class-inheritance-list
class-body -> "{" statements "}"
*** Attributes ***
* Grammar of an attribute *
attribute -> "@" attribute-name (opt)parameter-clause [AttributeHook]
attribute-name -> identifier-lower
attributes -> attribute (opt)attributes [AttributesHook]
*** Class parameters and arguments ***
* Grammar of a class parameter clause *
class-parameter-clause -> "<" class-parameter-list ">"
class-parameter-list -> class-parameter (opt)class-parameter-continuation [TypeParameterListHook]
class-parameter-continuation -> "," class-parameter-list
class-parameter -> class-argument-name
class-parameter -> class-argument-name ":" type-identifier
* Grammar of a class argument clause *
class-argument-clause -> "<" class-argument-list ">"
class-argument-list -> class-argument (opt)class-argument-continuation [TypeArgumentListHook]
class-argument-continuation -> "," class-argument-list
class-argument -> (opt)class-argument-label expression [ClassArgumentHook]
class-argument-label -> class-argument-name ":"
class-argument-name -> identifier-upper
*** Lookup ***
* Grammar of a lookup *
lookup-expression -> ".?" lookup-class "." lookup-property lookup-argument-clause [LookupHook]
lookup-class -> class-name
lookup-property -> identifier-lower
lookup-argument-clause -> "(" (opt)lookup-argument-list ")"
lookup-argument-list -> lookup-argument-key (opt)lookup-argument-continuation [LookupArgumentListHook]
lookup-argument-continuation -> "," lookup-argument-list
lookup-argument-key -> [ArgumentHook]
*** Formatting ***
* Grammar of a formatting *
formatting -> ".%" expression [FormattingHook]