diff --git a/.travis.yml b/.travis.yml index 013ec4d..c4eb50c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,6 @@ rvm: - 1.9.2 - 1.9.3 - 2.0.0 +- 2.2.8 +- 2.3.5 +- 2.4.2 diff --git a/Manifest.txt b/Manifest.txt index 81748d5..0570881 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -1,12 +1,15 @@ .autotest +.bundle/config .hoeignore .travis.yml Gemfile +Gemfile.lock History.txt LICENSE Manifest.txt README.rdoc Rakefile +appveyor.yml bin/kpeg examples/calculator/calculator.kpeg examples/calculator/calculator.rb diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..1394018 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,35 @@ +version: '{build}' +skip_tags: true +clone_depth: 5 +build: off +deploy: off + +init: + - mklink /d C:\git "C:\Program Files\Git" + - if %ruby_version%==_trunk ( + appveyor DownloadFile https://ci.appveyor.com/api/projects/MSP-Greg/ruby-loco/artifacts/ruby_trunk.7z -FileName C:\ruby_trunk.7z & + 7z x C:\ruby_trunk.7z -oC:\ruby_trunk ) + +install: + - gem install hoe --no-document + - if "%ruby_version%" LSS "22" ( gem update minitest ) + +test_script: +- rake test +on_finish: +- ruby -v + +environment: + PATH: C:/ruby%ruby_version%/bin;C:/Program Files/7-Zip;C:/Program Files/AppVeyor/BuildAgent;C:/git/cmd;C:/Program Files (x86)/GNU/GnuPG/pub;C:/Windows/system32;C:\Windows; + matrix: + - ruby_version: 200 + - ruby_version: 200-x64 + - ruby_version: 21 + - ruby_version: 21-x64 + - ruby_version: 22 + - ruby_version: 22-x64 + - ruby_version: 23 + - ruby_version: 23-x64 + - ruby_version: 24 + - ruby_version: 24-x64 + - ruby_version: _trunk diff --git a/lib/kpeg/format_parser.rb b/lib/kpeg/format_parser.rb index 299e185..63c7ffe 100644 --- a/lib/kpeg/format_parser.rb +++ b/lib/kpeg/format_parser.rb @@ -914,7 +914,7 @@ def _dbl_not_quote break end _tmp = apply(:_dbl_escapes) - s = @result +# warning unused s = @result unless _tmp self.pos = _save3 end @@ -924,7 +924,7 @@ def _dbl_not_quote break if _tmp self.pos = _save2 _tmp = apply(:_dbl_seq) - s = @result +# warning unused s = @result break if _tmp self.pos = _save2 break diff --git a/lib/kpeg/grammar.rb b/lib/kpeg/grammar.rb index fab8ad2..b7532f7 100644 --- a/lib/kpeg/grammar.rb +++ b/lib/kpeg/grammar.rb @@ -129,6 +129,12 @@ def initialize(reg, opts=nil) end end end + # Windows - force to UTF-8 if reg contains a Unicode character property + # of the \p{**} style + if reg =~ /\{[LMNPSZC][c-u]?\}/ && RUBY_PLATFORM =~ /mswin|mingw/ && + reg.encoding == Encoding::IBM437 + reg.force_encoding('UTF-8') + end @regexp = Regexp.new(reg, flags, lang) else diff --git a/test/test_kpeg.rb b/test/test_kpeg.rb index a463ebd..fc8ed94 100644 --- a/test/test_kpeg.rb +++ b/test/test_kpeg.rb @@ -22,7 +22,7 @@ def test_str end assert_match KPeg.match("hello", gram), "hello" - assert_equal nil, KPeg.match("vador", gram) + assert_nil KPeg.match("vador", gram) end def test_reg @@ -48,7 +48,7 @@ def test_any assert_match KPeg.match("hello", gram), "hello" assert_match KPeg.match("chicken", gram), "chicken" - assert_equal nil, KPeg.match("vador", gram) + assert_nil KPeg.match("vador", gram) end def test_maybe @@ -78,7 +78,7 @@ def test_many assert_match sm, "run" end - assert_equal nil, KPeg.match("vador", gram) + assert_nil KPeg.match("vador", gram) end def test_kleene @@ -124,9 +124,9 @@ def test_multiple assert_match sm, "run" end - assert_equal nil, KPeg.match("run", gram) - assert_equal nil, KPeg.match("runrunrunrunrun", gram) - assert_equal nil, KPeg.match("vador", gram) + assert_nil KPeg.match("run", gram) + assert_nil KPeg.match("runrunrunrunrun", gram) + assert_nil KPeg.match("vador", gram) end def test_seq @@ -141,8 +141,8 @@ def test_seq assert_equal m.value, ["hello", ", world"] - assert_equal nil, KPeg.match("vador", gram) - assert_equal nil, KPeg.match("hello, vador", gram) + assert_nil KPeg.match("vador", gram) + assert_nil KPeg.match("hello, vador", gram) end def test_andp @@ -346,7 +346,7 @@ def test_left_recursion parser = KPeg::Parser.new "hello", gram m = parser.parse - assert_equal nil, m + assert_nil m end def test_math_grammar diff --git a/test/test_kpeg_code_generator.rb b/test/test_kpeg_code_generator.rb index b6e5986..c040bf5 100644 --- a/test/test_kpeg_code_generator.rb +++ b/test/test_kpeg_code_generator.rb @@ -1079,7 +1079,7 @@ def _root code = cg.make("") assert code.parse - assert_equal nil, code.result + assert_nil code.result end diff --git a/test/test_kpeg_string_escape.rb b/test/test_kpeg_string_escape.rb index 6f9d977..c712e65 100644 --- a/test/test_kpeg_string_escape.rb +++ b/test/test_kpeg_string_escape.rb @@ -39,4 +39,3 @@ def parse(str, embed = false) end end -