mirror of
https://github.com/emkay/parser-6502.git
synced 2026-04-21 03:19:39 +00:00
first
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
const tap = require('tap')
|
||||
const parser = require('..')
|
||||
|
||||
tap.test('should parse the basics', (t) => {
|
||||
t.plan(1)
|
||||
const input = '.org $C000\nRESET:\n'
|
||||
t.deepEqual(parser(input), [
|
||||
{
|
||||
directive: '.org',
|
||||
args: [
|
||||
'$,C000'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'RESET:'
|
||||
}
|
||||
])
|
||||
})
|
||||
@@ -0,0 +1,86 @@
|
||||
const tap = require('tap')
|
||||
const mona = require('mona')
|
||||
const directiveParser = require('../parsers/directive')
|
||||
|
||||
tap.test('will parse a directive', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(directiveParser(), '.inesprg 1'), {
|
||||
args: [
|
||||
'1'
|
||||
],
|
||||
directive: '.inesprg'
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('will parse a directive with direct address', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(directiveParser(), '.inesprg $0000'), {
|
||||
args: [
|
||||
'$,0000'
|
||||
],
|
||||
directive: '.inesprg'
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('will parse a directive with hex arg', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(directiveParser(), '.inesprg #$FE'), {
|
||||
args: [
|
||||
'#,$,FE'
|
||||
],
|
||||
directive: '.inesprg'
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('will parse a directive with binary arg', (t) => {
|
||||
t.plan(2)
|
||||
t.deepEqual(mona.parse(directiveParser(), '.db %00010001'), {
|
||||
args: [
|
||||
'%,00010001'
|
||||
],
|
||||
directive: '.db'
|
||||
})
|
||||
|
||||
t.deepEqual(mona.parse(directiveParser(), '.db #%00010001'), {
|
||||
args: [
|
||||
'#,%,00010001'
|
||||
],
|
||||
directive: '.db'
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('will parse a directive with multiple args', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(directiveParser(), '.db %00010001,%00010001,%00010001,%00010001'), {
|
||||
args: [
|
||||
'%,00010001',
|
||||
'%,00010001',
|
||||
'%,00010001',
|
||||
'%,00010001'
|
||||
],
|
||||
directive: '.db'
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('will parse a directive with multiple args with spaces between them', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(directiveParser(), '.db %00010001, %00010001, %00010001, %00010001'), {
|
||||
args: [
|
||||
'%,00010001',
|
||||
'%,00010001',
|
||||
'%,00010001',
|
||||
'%,00010001'
|
||||
],
|
||||
directive: '.db'
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('will parse a directive with string arg', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(directiveParser(), '.incbin "mario.chr"'), {
|
||||
args: [
|
||||
'mario.chr'
|
||||
],
|
||||
directive: '.incbin'
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
const tap = require('tap')
|
||||
const mona = require('mona')
|
||||
const instructionParser = require('../parsers/instruction')
|
||||
|
||||
tap.test('will parse an instruction', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(instructionParser(), 'sei'), {
|
||||
args: null,
|
||||
instruction: 'sei'
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('will parse an instruction with args', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(instructionParser(), 'stx $2000'), {
|
||||
args: ['$,2000'],
|
||||
instruction: 'stx'
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('will parse an instruction with multiple args', (t) => {
|
||||
t.plan(1)
|
||||
t.deepEqual(mona.parse(instructionParser(), 'lda background3, x'), {
|
||||
args: ['background3', 'x'],
|
||||
instruction: 'lda'
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
const tap = require('tap')
|
||||
const mona = require('mona')
|
||||
const labelParser = require('../parsers/label')
|
||||
|
||||
tap.test('should parse a label', (t) => {
|
||||
t.plan(2)
|
||||
t.deepEqual(mona.parse(labelParser(), 'SOMETHING:'), {
|
||||
label: 'SOMETHING:'
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user