~tim/scheme-vm

42da5429336f1a4dcde4db0eaee0655060ea0b70 — Tim Morgan 3 years ago 350ad62
Fix parser bug

(foo)(bar) could not be parsed
2 files changed, 9 insertions(+), 2 deletions(-)

M spec/parser_spec.rb
M src/lisp.rustpeg
M spec/parser_spec.rb => spec/parser_spec.rb +7 -0
@@ 32,5 32,12 @@ describe Parser do
               ['foo', ['bar', ['baz', '"this is a string"']]]]
      ])
    end

    it 'parses touching parens' do
      expect(described_class.new('(foo)(bar)').parse).to eq([
        ['foo'],
        ['bar']
      ])
    end
  end
end

M src/lisp.rustpeg => src/lisp.rustpeg +2 -2
@@ 6,7 6,7 @@ use atom::atom;
use quotes::QUOTES;

whitespace
	= [ \t\n]+
	= [ \t\n]*

escape
	= "\\" .


@@ 54,7 54,7 @@ datum_comment
	= "#;" " "? (atom / sexp)

expressions -> Value
  = whitespace* s:(expression ** whitespace) whitespace* { rb::vec2rbarr(s.into_iter().filter_map(|i| i).collect()) }
  = whitespace s:(expression ** whitespace) whitespace { rb::vec2rbarr(s.into_iter().filter_map(|i| i).collect()) }

pub program -> Value
	= expressions