Releases: ruby-next/paco
Releases · ruby-next/paco
v0.2.1
v0.2.0
Added
- Callstack collection for debugging. (@skryukov)
Pass with_callstack: true to the Paco::Parser#parse method to collect a callstack while parsing. To examine the callstack catch the ParseError exception:
begin
string("Paco").parse("Paco!", with_callstack: true)
rescue Paco::ParseError => e
pp e.callstack.stack # You will probably want to use `binding.irb` or `binding.pry`
endPaco::Combinators.indexmethod. (@skryukov)
Call Paco::Combinators.index to get Paco::Index representing the current offset into the parse without consuming the input.
Paco::Index has a 0-based character offset attribute :pos and 1-based :line and :column attributes.
index.parse("Paco") #=> #<struct Paco::Index pos=0, line=1, column=1> - RSpec matcher
#parse. (@skryukov)
Add require "paco/rspec" to spec_helper.rb to enable a special RSpec matcher #parse:
subject { string("Paco") }
it { is_expected.to parse("Paco") } # just checks if parser succeeds
it { is_expected.to parse("Paco").as("Paco") } # checks if parser result is eq to value passed to `#as`
it { is_expected.to parse("Paco").fully } # checks if parser result is the same as value passed to `#parse`Changed
Paco::Combinators.seq_mapmerged intoPaco::Combinators.seq. (@skryukov)Paco::Combinators.sep_by_1renamed toPaco::Combinators.sep_by!. (@skryukov)
Fixed
Paco::Combinators::Char#regexpnow uses\Ainstead of^. (@skryukov)include Paconow works insideirb. (@skryukov)Paco::Combinators#not_followed_byandPaco::Combinators#seqnow don't consume input on error. (@skryukov)
Full Changelog: v0.1.0...v0.2.0