mirror of
https://github.com/emkay/parser-6502.git
synced 2024-09-12 11:55:20 +00:00
yep
This commit is contained in:
parent
3a52f4399c
commit
e8ca1f9bcd
3
index.js
3
index.js
@ -11,7 +11,8 @@ function assembler (input) {
|
||||
directive(),
|
||||
instruction(),
|
||||
label(),
|
||||
mona.eol()
|
||||
mona.eol(),
|
||||
mona.eof()
|
||||
)
|
||||
),
|
||||
input
|
||||
|
@ -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
|
||||
|
@ -8,10 +8,9 @@ tap.test('should parse the basics', (t) => {
|
||||
{
|
||||
directive: '.org',
|
||||
args: [
|
||||
[
|
||||
'address',
|
||||
'C000'
|
||||
]
|
||||
{
|
||||
'address': 'C000'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -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'
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user