1
0
mirror of https://github.com/emkay/parser-6502.git synced 2024-12-21 15:29:19 +00:00
parser-6502/parsers/directive.js

38 lines
671 B
JavaScript
Raw 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'
])
}
// <directive> ::= <directive-name> [<spaces> <parameter>]*
function directive () {
return mona.sequence((s) => {
const d = s(directiveName())
2016-10-07 17:45:55 +00:00
const space = s(mona.spaces())
const args = s(parameters())
2016-10-02 21:54:14 +00:00
// const nl = s(mona.eol())
return mona.value({
directive: d,
args: args
})
})
}
module.exports = directive