This commit is contained in:
Michael Matuzak 2016-10-11 17:59:26 -07:00
parent 3a52f4399c
commit e8ca1f9bcd
4 changed files with 17 additions and 9 deletions

View File

@ -11,7 +11,8 @@ function assembler (input) {
directive(),
instruction(),
label(),
mona.eol()
mona.eol(),
mona.eof()
)
),
input

View File

@ -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

View File

@ -8,10 +8,9 @@ tap.test('should parse the basics', (t) => {
{
directive: '.org',
args: [
[
'address',
'C000'
]
{
'address': 'C000'
}
]
},
{

View File

@ -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'
})
})