mirror of
https://github.com/emkay/parser-6502.git
synced 2024-12-30 12:31:29 +00:00
45 lines
704 B
JavaScript
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
|