input: 'true'
output: ['"some exception"']
+ - title: `?` operator
+ body: |
+
+ The `?` operator, used as `EXP?`, is shorthand for `try EXP`.
+
+ examples:
+ - program: '[.[]|(.a)?]'
+ input: '[{}, true, {"a":1}'
+ output: ['[null, 1]']
+
- title: Advanced features
body: |
Variables are an absolute necessity in most programming languages, but
$$ = $2;
} |
+Exp '?' {
+ $$ = gen_try($1, gen_op_simple(BACKTRACK));
+} |
+
Exp '=' Exp {
$$ = gen_call("_assign", BLOCK(gen_lambda($1), gen_lambda($3)));
[0,1,2,3]
["foo","Cannot index number with string \"a\"",3]
+[.[]|(.a, .a)?]
+[null,true,{"a":1}]
+[null,null,1,1]
+
+[[.[]|[.a,.a]]?]
+[null,true,{"a":1}]
+[]
+
# string operations
[.[]|startswith("foo")]
["fo", "foo", "barfoo", "foobar", "barfoob"]