From 689149370c79120fa98941d408d0219452275f9d Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sun, 3 Aug 2014 06:46:10 +0200 Subject: [PATCH] Temple::Mixins::GrammarDSL - Add some missing match? methods --- lib/temple/mixins/grammar_dsl.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/temple/mixins/grammar_dsl.rb b/lib/temple/mixins/grammar_dsl.rb index ff2032a..0f154f5 100644 --- a/lib/temple/mixins/grammar_dsl.rb +++ b/lib/temple/mixins/grammar_dsl.rb @@ -7,6 +7,12 @@ def initialize(grammar) @grammar = grammar end + def match?(exp) + match(exp, []) + end + alias === match? + alias =~ match? + def |(rule) Or.new(@grammar, self, rule) end @@ -53,10 +59,6 @@ def match(exp, unmatched) success end - def match?(exp) - match(exp, []) - end - def validate!(exp) unmatched = [] unless match(exp, unmatched) @@ -120,14 +122,13 @@ def extended(mod) def match?(exp) const_get(:Expression).match?(exp) end + alias === match? + alias =~ match? def validate!(exp) const_get(:Expression).validate!(exp) end - alias === match? - alias =~ match? - def Value(value) Value.new(self, value) end