Skip to content

Commit

Permalink
* lib/racc/grammar.rb (separated_by): last commit was wrong. use opti…
Browse files Browse the repository at this point in the history
…onal default return value of #option.

git-svn-id: file:///Users/aaron/Desktop/public/racc/trunk@3695 1b9489fe-b721-0410-924e-b54b9192deb8
  • Loading branch information
aamine committed Feb 20, 2007
1 parent dca110a commit d59522b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Tue Feb 20 18:45:45 2007 Minero Aoki <[email protected]>

* lib/racc/grammar.rb (separated_by): last commit was wrong. use
optional default return value of #option.

Tue Feb 20 18:27:48 2007 Minero Aoki <[email protected]>

* lib/racc/grammar.rb (separated_by): return [] for empty list.
Expand Down
9 changes: 3 additions & 6 deletions lib/racc/grammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ def action(&block)

alias _ action

def option(sym, &block)
def option(sym, default = nil, &block)
_defmetasyntax("option", _intern(sym), block) {|target|
seq() | seq(sym)
seq() { default } | seq(sym)
}
end

Expand All @@ -305,10 +305,7 @@ def many1(sym, &block)
end

def separated_by(sep, sym, &block)
_defmetasyntax("separated_by", _intern(sym), block) {|target|
seq() { [] }\
| seq(target, sep, sym) {|list, _, x| list.push x; list }
}
option(separated_by1(sep, sym), [], &block)
end

def separated_by1(sep, sym, &block)
Expand Down

0 comments on commit d59522b

Please sign in to comment.