DOCS: Updated grammar and expression reference

`is` operator and the `fail` expression.
This commit is contained in:
Jeremy Wall 2019-01-19 11:47:39 -06:00
parent 6d5d4c79de
commit 9b84444feb
2 changed files with 24 additions and 1 deletions

View File

@ -492,4 +492,17 @@ let embedded_with_params = embedded_mod{deep_value = "Some"};
embedded_with_params.embedded.value == "Some";
```
Fail Expression
---------------
UCG has a way to declaratively trigger a build failure using the `fail` expression.
Fail expression start with the `fail` keyword and are followed with either a string or a format expression with the build failure message.
```
fail "Oh No This was not what we wanted!";
fail "Expected foo but got @" % ("bar");
```
Next: <a href="/reference/statements">Statements</a>

View File

@ -56,8 +56,10 @@ module_keyword: "module" ;
mod_keyword: "mod" ;
out_keyword: "out" ;
assert_keyword: "assert" ;
fail_keyword: "fail" ;
null_keyword: "NULL" ;
in_keyword: "in" ;
is_keyword: "in" ;
escaped: "\", VISIBLE_CHAR ;
str: quot, { escaped | UTF8_CHAR }, quot ;
float: (DIGIT+, dot, { DIGIT }) | (dot, DIGIT+) ;
@ -158,6 +160,13 @@ include_expr: include_keyword, bareword, str ;
```
import_expr: import_keyword, str ;
```
#### Fail expressions
```
fail_expr: fail_keyword, (str | format_expr) ;
```
#### Non Operator Expression
```
@ -166,6 +175,7 @@ non_operator_expr: literal
| import_expr
| macrodef
| module_def
| fail_expr
| format_expr
| range_expr
| include_expr
@ -179,7 +189,7 @@ non_operator_expr: literal
```
sum_op: plus | minus ;
product_op: start | slash ;
compare_op: equalequal | gtequal | ltequal | gt | lt | in_keyword ;
compare_op: equalequal | gtequal | ltequal | gt | lt | in_keyword | is_keyword ;
binary_op: sum_op | product_op | dot | compare_op ;
binary_expr: non_operator_expr, binary_op, expr ;
```