ConfigScript
Description
- Derived from
-
ConfigNode abstract
Represents a configuration script.
This is the Grammar of a configuration script:
# := '//' ~newline* newline | '/*' ~'*/'* '*/' ; !config := script? using* member* ; member := function | variable ; script := 'script' qualified-identifier ';' ; using := 'using' qualified-identifier ';' ; !function := comment* 'intern'? identifier '(' (function-param .. ',')? ')' type-constraint-value ';' ; !variable := comment* 'intern'? identifier type-constraint-value ';' ; function-param := comment* identifier type-constraint-value ; comment := '`' ' '? ~newline* newline ; type-constraint-value := (':' type)? ('{' expr '}')? ('=' expr)? ; newline := '\r\n' | [\r\n] ; !expr := expr-each ; expr-additive := expr-multiplicative !> (expr-additive-op expr-multiplicative)+ ; expr-array := '[' (type ':' \ '::')? expr-list ','? ']' ; expr-call := qualified-identifier '::' <! identifier !> '(' expr-list ')' ; expr-chain := '@' type-named ('(' expr-list ')' | '{' expr-init '}') ; expr-conditional := expr-conditional-or !> '?' expr ':' expr ; expr-conditional-and := expr-logic-or !> ('&&' expr-logic-or)+ ; expr-conditional-or := expr-conditional-and !> ('||' expr-conditional-and)+ ; expr-each := expr-conditional !> (expr-each-op expr-conditional)+ ; expr-element := '[' expr ']' ; expr-equality := expr-relational !> (expr-equality-op expr-relational)+ ; expr-init := ((identifier '=' expr .. ',') ','?)? ; expr-list := (expr .. ',')? ; expr-logic-and := expr-equality !> ('&' expr-equality)+ ; expr-logic-or := expr-logic-xor !> ('|' expr-logic-xor)+ ; expr-logic-xor := expr-logic-and !> ('^' expr-logic-and)+ ; expr-multiplicative := expr-power !> (expr-multiplicative-op expr-power)+ ; expr-object := type-named? '{' expr-init '}' | '{' (type-named '}' | (type-named ':')? expr-list '}') ; expr-power := expr-unary !> (expr-power-op expr-unary)+ ; expr-primary := expr-literal | expr-array | expr-object | expr-call | '(' expr ')' | expr-value | expr-environment ; expr-relational := expr-shift !> (expr-relational-op expr-shift)+ ; expr-shift := expr-additive !> (expr-shift-op expr-additive)+ ; expr-suffix := expr-primary !> expr-suffix-op+ ; expr-suffix-op := expr-member | expr-element | expr-chain ; expr-unary := (expr-literal-primary !> expr-suffix-op+) | (expr-unary-op <! expr-suffix) ; !type := type-simple | type-named !> '[]'+ ; !type-named := qualified-identifier \ ('nan' | 'null' | 'true' | 'false') ; expr-environment := '$' identifier ; expr-literal := expr-literal-hex | expr-literal-decimal | expr-literal-string | expr-literal-bool | expr-literal-null | expr-literal-path ; expr-member := '.' identifier | '->' identifier ; qualified-identifier := identifier .. '.' ; expr-literal-decimal := expr-literal-number ; expr-literal-hex := ('0x' | '#') hex-digit+ ; expr-literal-primary := 'nan' | '+inf' | '-inf' | '-' expr-literal-number ; identifier := identifier-start identifier-char* ; expr-literal-number := digit+ ('.' digit+)? (('e' | 'E') ('+' | '-') digit+)? ; hex-digit := digit | 'A'..'F' ; identifier-char := letter | digit ; identifier-start := letter ; digit := '0'..'9' ; expr-additive-op := '+' | '-' ; expr-each-op := '=>' | '?>' | '+>'; expr-equality-op := '==' | '!=' ; expr-literal-bool := 'true' | 'false' ; expr-literal-null := 'null' ; expr-literal-path := '<' ]\r>\n[* '>' | '`' ]`\r\n[* '`' ; expr-literal-string := '"' (]"\r\n[ | '""')* '"' | '\'' (]\r'\n[ | '\'\'')* '\'' ; expr-multiplicative-op := '*' | '/' | '%' ; expr-power-op := '**' | '\\\\' ; expr-relational-op := '<=' | '<' | '>=' | '>' ; expr-shift-op := '<<' | '>>' ; expr-unary-op := '-' | '+' | '!' | '~' ; expr-value := '#' | '@' ; letter := 'a'..'z' | 'A'..'Z' | '_' ; type-simple := 'bool' | 'string' | 'path' | 'number' ;
Public / Constructors
From
2 overloads
Parses the given configuration script.
The config domain opt that is passed to this method will be used to resolve references to other config scripts. The returned config script will not be added to the given domain opt by this method (see ConfigDomain.Add).
- ValidatingException
-
If one or more parsing errors have occurred.
Parses the given configuration script.
The config domain opt that is passed to this method will be used to resolve references to other config scripts. The returned config script will not be added to the given domain opt by this method (see ConfigDomain.Add).
- ValidatingException
-
If one or more parsing errors have occurred.
Load
Loads a config script from a file.
The config domain opt that is passed to this method will be used to resolve references to other config scripts. The returned config script will not be added to the given domain opt by this method (see ConfigDomain.Add).
- IOException
-
If an I/O error has occurred.
- ValidatingException
-
If one or more parsing errors have occurred.
Public / Methods
CallFunction
Calls a public script function.
- ConfigException
-
If an unexpected error has occurred while obtaining the config value, for example while evaluating default argument expressions for the function call.
DependsOn
Does this config script depend on the given one by referring to one of its members using an external name 'ScriptName::MemberName'
?
Evaluate
Evaluates the given expression within the scope of this config script.
- ValidatingException
-
If the given expression in source code is malformed.
- ConfigException
-
If an error has occurred while evaluating the expression (e.g. identifier not found).
ImplementFunction
Provides an external implementation for a script function, replacing the current external implementation, if existent.
- ConfigException
-
If there is no script function of the given name in.
If the script function already has an implementation in the script code.
MakeIdentifier
Generates a valid config script identifier (see grammar rule identifier
) from the given string value by replacing all sequences of invalid characters with a single underscore ('_'
) character.
Member
Returns a public script member (i.e. function or variable) by its name.
- ConfigException
-
If there is no script member of the given name in.
MemberAt
Returns the script member at the given source code offset (see ICodeRange.Range).
If no member contains the given offset in, the next member is returned (if existent).
MemberNull
2 overloads
Returns a public script member (i.e. function or variable) by its name.
Returns the public script variable which current value is stored in the given config value.
- ConfigException
-
If an unexpected error has occurred while finding the config value, for example while retrieving a virtual field of a class value.