Sha256: b0bd644e5644a60e2187fe786dd056b109f4492a33468f0d2bd2d6da0a1f08ba
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
module Treetop module Compiler class Predicate < ParsingExpression def compile(address, builder, parent_expression) super begin_comment(parent_expression) use_vars :result, :start_index obtain_new_subexpression_address parent_expression.prefixed_expression.compile(subexpression_address, builder) builder.if__(subexpression_success?) { when_success } builder.else_ { when_failure } end_comment(parent_expression) end def assign_failure reset_index super(start_index_var) end def assign_success reset_index assign_result epsilon_node end end class AndPredicate < Predicate def when_success assign_success end def when_failure assign_failure end end class NotPredicate < Predicate def when_success assign_failure if (e = parent.atomic.expected) builder << "terminal_parse_failure(#{e}, true)" end end def when_failure if (e = parent.atomic.expected) builder << "@terminal_failures.pop" end assign_success end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
treetop-1.6.5 | lib/treetop/compiler/node_classes/predicate.rb |
treetop-1.6.4 | lib/treetop/compiler/node_classes/predicate.rb |