Example #1
0
 def test_not_p(self):
     eq_(eval(not_p(fail)), True)
     assert_raises(NoSolutionFound, eval, not_p(succeed))
Example #2
0
 def test_not_p(self):
   eq_(eval(not_p(fail)), True)
   assert_raises(NoSolutionFound, eval, not_p(succeed))
Example #3
0
    ([exp_list], and_p(char('['), spaces0(_), from_sexp(sexpression_list)(exp_list), spaces0(_), char(']'))))),
  
  define(punct_expression, function(
    ([L(quote, exp)], and_p(char("'"), from_sexp(sexpression)(exp))),
    ([L(quasiquote, exp)], and_p(char("`"), from_sexp(sexpression)(exp))),
    ([L(unquote_splice, exp)], and_p(literal(",@"), from_sexp(sexpression)(exp))),
    ([L(unquote, exp)], and_p(char(","), from_sexp(sexpression)(exp))))),
  
  define(sexpression_list, function(
    ([Cons(exp, exp_list)], and_p(from_sexp(sexpression)(exp), from_sexp(maybe_spaces)(), from_sexp(sexpression_list)(exp_list))),
    ([nil], null))),
  
  define(sexpression1, function(
    ([exp], and_p(spaces0(_), from_sexp(sexpression_list)(exp), spaces0(_))))),
  
  define(maybe_spaces, function(
    ([], or_p(if_p(and_p(not_lead_chars('([])'), not_follow_chars('([])'), not_p(eoi)),
                   spaces(_)),
          spaces0(_) ) ) ) ),
  
  define(sexpression, function(
     # dynamic grammar arises!
    ([result], and_p(char('{'), from_sexp(sexpression)(exp2), char('}'), 
                     setvalue(result, eval_(pycall(cons2tuple, exp2))))),

    ([exp], from_sexp(atom)(exp)),
    ([exp], from_sexp(bracket_expression)(exp)),
    ([exp], from_sexp(punct_expression)(exp))),
   ),
  )