diff --git a/docsite/site/content/reference/expressions.md b/docsite/site/content/reference/expressions.md index 02b6f75..1162618 100644 --- a/docsite/site/content/reference/expressions.md +++ b/docsite/site/content/reference/expressions.md @@ -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: Statements \ No newline at end of file diff --git a/docsite/site/content/reference/grammar.md b/docsite/site/content/reference/grammar.md index f7fa9e4..548f191 100644 --- a/docsite/site/content/reference/grammar.md +++ b/docsite/site/content/reference/grammar.md @@ -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 ; ```