Add error/exception handling. Custom error types. Data conversion
This commit is contained in:
parent
40209417c5
commit
e72d8835f8
|
|
@ -1,4 +1,4 @@
|
|||
<type> ::= <primitive_type> | <complex_type> | <array_type>
|
||||
<type> ::= <primitive_type> | <complex_type> | <array_type> | <error_type>
|
||||
|
||||
<primitive_type> ::= "String" | "Integer" | "Decimal" | "Boolean"
|
||||
|
||||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
<array_type> ::= <type> "<>"
|
||||
|
||||
<parameter_type> ::= <type> | "Runnable"
|
||||
<parameter_type> ::= <type>
|
||||
| "Runnable"
|
||||
| <error_type>
|
||||
| "Any"
|
||||
|
||||
<return_type_list> ::= "[" <type> ("," <type>)* "]" | "Runnable"
|
||||
|
|
|
|||
7
grammar/declarations/error_declarations.bnf
Normal file
7
grammar/declarations/error_declarations.bnf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<error_declaration> ::= <identifier>
|
||||
["/" <identifier>]?
|
||||
"{" <error_body>? "}"
|
||||
|
||||
<error_body> ::= (<variable_declaration>
|
||||
| <constant_declaration>
|
||||
| <function_declaration>)*
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
<function_declaration> ::= <accessibility_modifier>"fn" <identifier>
|
||||
<function_signature>
|
||||
["fails" "with" <error_type_list>]?
|
||||
"{" <statement>* "}"
|
||||
|
||||
<function_signature> ::= "(" <parameter_list>? ")"
|
||||
"->" <return_type_list>
|
||||
|
||||
<error_type_list> ::= <error_type> ("," <error_type>)*
|
||||
|
||||
<error_type> ::= <identifier> ["/" <identifier>]?
|
||||
|
||||
<parameter_list> ::= <required_parameter>
|
||||
("," <required_parameter>)*
|
||||
[("," <default_parameter>)*]
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
| <return_statement>
|
||||
| <using_statement>
|
||||
| <attempt_statement>
|
||||
| <fail_statement>
|
||||
|
||||
<assignment_statement> ::= <my_identifier> ".set(" <expression> ")" ";"
|
||||
|
||||
|
|
@ -35,3 +36,5 @@
|
|||
<attempt_statement> ::= <expression> ".attempt" "{" <attempt_handler>* "}"
|
||||
|
||||
<attempt_handler> ::= ("ok" | <identifier> | "error") "{" <statement>* "}"
|
||||
|
||||
<fail_statement> ::= <my_identifier> ".fail(" <error_type> ["(" <argument_list>? ")"]? ")" ";"
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@
|
|||
| <object_method_call>
|
||||
| <constant_expression>
|
||||
| <object_instantiation>
|
||||
| <type_conversion_expression>
|
||||
| "(" <expression> ")"
|
||||
| <lambda_expression>
|
||||
|
||||
<type_conversion_expression> ::= <my_identifier> ".as(" <type> ")"
|
||||
|
||||
<boolean_expression> ::=
|
||||
<boolean_literal>
|
||||
| "(" <boolean_expression> ")"
|
||||
|
|
@ -28,4 +31,4 @@
|
|||
| Boolean.gte(<boolean_expression>, <boolean_expression>)
|
||||
| Boolean.lte(<boolean_expression>, <boolean_expression>)
|
||||
|
||||
<constant_expression> ::= <my_identifier> ".define(" <literal> ")"
|
||||
<constant_expression> ::= <my_identifier> ".define(" <literal> ")"
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
<object_method_call> ::= <my_identifier> "." <method_name> "(" <argument_list>? ")"
|
||||
| <my_identifier> ".sum()"
|
||||
| <my_identifier> ".as(" <type> ")"
|
||||
|
||||
<method_name> ::= "set"
|
||||
| "define"
|
||||
| "as"
|
||||
| "length" | "reverse" | "split" | "format"
|
||||
| "search" | "concat" | "replace"
|
||||
| "add" | "subtract" | "multiply" | "divide" | "idivide"
|
||||
|
|
|
|||
Loading…
Reference in a new issue