diff --git a/index.js b/index.js index dfc449f..5be0be1 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,8 @@ function assembler (input) { directive(), instruction(), label(), - mona.eol() + mona.eol(), + mona.eof() ) ), input diff --git a/parsers/instruction.js b/parsers/instruction.js index 7a1a852..7d5634f 100644 --- a/parsers/instruction.js +++ b/parsers/instruction.js @@ -24,16 +24,24 @@ function instructionName () { function instruction () { return mona.sequence((s) => { - const i = s(instructionName()) + const i = s( + mona.followedBy( + instructionName(), + mona.maybe(mona.eol()) + ) + ) + const args = s( mona.maybe( mona.and( mona.spaces(), - parameters() + mona.followedBy( + parameters(), + mona.maybe(mona.eol()) + ) ) ) ) - const nl = s(mona.eol()) return mona.value({ instruction: i, args: args diff --git a/test/assembler.js b/test/assembler.js index 7531d1f..0994321 100644 --- a/test/assembler.js +++ b/test/assembler.js @@ -8,10 +8,9 @@ tap.test('should parse the basics', (t) => { { directive: '.org', args: [ - [ - 'address', - 'C000' - ] + { + 'address': 'C000' + } ] }, { diff --git a/test/instruction.js b/test/instruction.js index d02a5e7..ee70e8c 100644 --- a/test/instruction.js +++ b/test/instruction.js @@ -5,7 +5,7 @@ const instructionParser = require('../parsers/instruction') tap.test('will parse an instruction', (t) => { t.plan(1) t.deepEqual(mona.parse(instructionParser(), 'sei\n'), { - args: [], + args: null, instruction: 'sei' }) })