parser-6502/parsers/directive.js

45 lines
704 B
JavaScript
Raw Permalink Normal View History

2016-10-02 21:54:14 +00:00
const mona = require('mona')
2016-10-07 17:45:55 +00:00
const parameters = require('./parameters').parameters
2016-10-02 21:54:14 +00:00
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())
2016-10-12 23:41:28 +00:00
const args = s(
mona.maybe(
mona.and(
mona.spaces(),
mona.followedBy(
parameters(),
mona.eol()
)
)
)
)
2016-10-02 21:54:14 +00:00
return mona.value({
directive: d,
args: args
})
})
}
module.exports = directive