1
0
mirror of https://github.com/emkay/parser-6502.git synced 2024-12-30 12:31:29 +00:00
parser-6502/parsers/directive.js
Michael Matuzak dfe822b086 working
2016-10-12 16:41:28 -07:00

45 lines
704 B
JavaScript

const mona = require('mona')
const parameters = require('./parameters').parameters
function directiveName () {
return mona.oneOf([
'.inesprg',
'.ineschr',
'.inesmap',
'.inesmir',
'.bank',
'.org',
'.db',
'.byte',
'.dw',
'.word',
'.incbin',
'.rsset',
'.rs'
])
}
function directive () {
return mona.sequence((s) => {
const d = s(directiveName())
const args = s(
mona.maybe(
mona.and(
mona.spaces(),
mona.followedBy(
parameters(),
mona.eol()
)
)
)
)
return mona.value({
directive: d,
args: args
})
})
}
module.exports = directive