Closed m4rw3r closed 8 years ago
Failing on compiletest-fail:
Running `/home/travis/build/m4rw3r/chomp/target/debug/compile_fail_test-5eb103a74b266c25`
running 1 test
running 9 tests
test [compile-fail] compile-fail/ascii_signed_unsigned_type1.rs ... ok
test [compile-fail] compile-fail/ascii_signed_unsigned_type2.rs ... ok
test [compile-fail] compile-fail/ascii_signed_unsigned_type4.rs ... ok
test [compile-fail] compile-fail/ascii_signed_unsigned_type.rs ... ok
test [compile-fail] compile-fail/ascii_signed_unsigned_type3.rs ... ok
test [compile-fail] compile-fail/macros_tailing_bind3.rs ... FAILED
test [compile-fail] compile-fail/macros_tailing_bind1.rs ... FAILED
test [compile-fail] compile-fail/macros_tailing_bind2.rs ... FAILED
test [compile-fail] compile-fail/macros_tailing_bind4.rs ... FAILED
All of the failing tests above compile correctly when they should be failing because of a tailing let
-statement.
Operator precedence is now implemented by expanding Expr
and Term
to group parts of the expression around lower-precedence operators. Can maybe cause some issues with hitting the macro recursion limit (default is 64) but adding specific cases can mitigate this problem (though it is somewhat annoying for the operators since they are not a single token, ;
was much easier).
Tests are still neded for the new features in Expr
.
Expr
and Term
Expr ::= ExprAlt
| ExprAlt ">>" Expr
ExprAlt ::= ExprSkip
| ExprSkip "<|>" ExprAlt
ExprSkip ::= Term
| Term "<*" ExprSkip
Term ::= Ret
| Err
| Inline
| Named
| '(' Expr ')'
Expr ::= Term
| Named Operator Expr
| '(' Expr ')'
| '(' Expr ')' Operator Expr
Term ::= Ret
| Err
| Inline
| Named
Generalizes parts of the syntax (eg. enables
ret
anderr
to be used inlet
-statements) and allows for operators in the expressions forlet
-statements and actions.New grammar
NOTE: This change is backwards incompatible as it does not allow for tailing semicolons in
parse!
macros.Operators
<|>
: Same as Haskell'sAlternative
typeclass, it attempts to parse the left hand side and if it fails it will retry with the right hand side<*
: Same as Haskell'sApplicative
typeclass, it parses the left hand side, then the right hand side and throws away any result from the right hand side while keeping the result of the left hand side>>
: Same as Haskell'sMonad
(and Chomp'sthen
)These operators have the same operator precedence as Haskell but are right-associative (at the moment of writing). The right-associativity and operator precedence follows from the fact that rust-macros parse from left to right and just using plain tt-munching to chain them together will keep that order.
Examples
I am not sure if I want to make the operators left-associative, though there are cases both for and against:
Needs a few more tests before it is good to merge.