Permalink
Browse files

aliased :recursive with :iterative

  • Loading branch information...
1 parent 4ce1730 commit e30c4741df78332e01910ef59425864a17541730 @mcollina committed Jul 11, 2007
View
@@ -7,6 +7,7 @@
* 1 minor enhacement
* spec loading fixed
* added a simple REPL based on Ariteval
+ * aliased :recursive with :iterative because it's more intuitive
== 0.1.0 / 2007-06-09
@@ -53,7 +53,7 @@ def evaluate(source)
token ")".to_sym, '\) *'
- token :ident, "[a-zA-Z] *"
+ token :ident, "[a-Z] *"
token :assign, "= *"
@@ -65,7 +65,7 @@ def evaluate(source)
scope :exp
- production(:exp,:recursive) do |prod|
+ production(:exp,:iterative) do |prod|
prod.default do |scanner,parser|
#this is needed to trim spaces from the beginning of the string to parse
while scanner.current == :space
@@ -88,7 +88,7 @@ def evaluate(source)
end
end
- production(:term,:recursive) do |prod|
+ production(:term,:iterative) do |prod|
prod.default { |scanner,parser| parser.parse_factor }
prod.token(:mul) do |factor_seq,scanner,parser|
@@ -27,8 +27,8 @@ class ProductionSpecification
# They are specified through ProductionSpecification#token.
attr_reader :tokens
- # The mode of the production. It can be :single or :recursive.
- attr_accessor :mode
+ # The mode of the production. It can be :single or :recursive (:iterative is just an alias for :recursive).
+ attr_reader :mode
# This attribute specifies if the production should raise an exception if the current token hasn't been recognized.
# It's important only for :single productions.
@@ -75,5 +75,13 @@ def default(block=nil,&b)
@default
end
+ # see ProductionSpecification#mode
+ def mode=(value)
+ if value == :iterative
+ value = :recursive
+ end
+ @mode = value
+ end
+
end
end
@@ -71,4 +71,9 @@
@production.raise_on_error=false
@production.raise_on_error.should == false
end
+
+ it "should alias :recursive with :iterative" do
+ @production.mode = :iterative
+ @production.mode.should == :recursive
+ end
end

0 comments on commit e30c474

Please sign in to comment.