mirror of https://github.com/emkay/parser-6502.git
yep
This commit is contained in:
parent
3a52f4399c
commit
e8ca1f9bcd
3
index.js
3
index.js
|
@ -11,7 +11,8 @@ function assembler (input) {
|
||||||
directive(),
|
directive(),
|
||||||
instruction(),
|
instruction(),
|
||||||
label(),
|
label(),
|
||||||
mona.eol()
|
mona.eol(),
|
||||||
|
mona.eof()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
input
|
input
|
||||||
|
|
|
@ -24,16 +24,24 @@ function instructionName () {
|
||||||
|
|
||||||
function instruction () {
|
function instruction () {
|
||||||
return mona.sequence((s) => {
|
return mona.sequence((s) => {
|
||||||
const i = s(instructionName())
|
const i = s(
|
||||||
|
mona.followedBy(
|
||||||
|
instructionName(),
|
||||||
|
mona.maybe(mona.eol())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
const args = s(
|
const args = s(
|
||||||
mona.maybe(
|
mona.maybe(
|
||||||
mona.and(
|
mona.and(
|
||||||
mona.spaces(),
|
mona.spaces(),
|
||||||
parameters()
|
mona.followedBy(
|
||||||
|
parameters(),
|
||||||
|
mona.maybe(mona.eol())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
const nl = s(mona.eol())
|
|
||||||
return mona.value({
|
return mona.value({
|
||||||
instruction: i,
|
instruction: i,
|
||||||
args: args
|
args: args
|
||||||
|
|
|
@ -8,10 +8,9 @@ tap.test('should parse the basics', (t) => {
|
||||||
{
|
{
|
||||||
directive: '.org',
|
directive: '.org',
|
||||||
args: [
|
args: [
|
||||||
[
|
{
|
||||||
'address',
|
'address': 'C000'
|
||||||
'C000'
|
}
|
||||||
]
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ const instructionParser = require('../parsers/instruction')
|
||||||
tap.test('will parse an instruction', (t) => {
|
tap.test('will parse an instruction', (t) => {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
t.deepEqual(mona.parse(instructionParser(), 'sei\n'), {
|
t.deepEqual(mona.parse(instructionParser(), 'sei\n'), {
|
||||||
args: [],
|
args: null,
|
||||||
instruction: 'sei'
|
instruction: 'sei'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue