1
0
mirror of https://github.com/emkay/parser-6502.git synced 2025-09-12 04:24:28 +00:00
This commit is contained in:
Michael Matuzak
2016-10-07 15:54:31 -07:00
parent cb0e34d1e3
commit 5e098fe69d
5 changed files with 58 additions and 37 deletions

View File

@@ -1,16 +1,11 @@
const mona = require('mona')
function quotedChar () {
return mona.or(mona.noneOf('"'),
mona.and(mona.string('""'),
mona.value('"')))
}
function alphanum () {
return mona.join(
mona.value('alphanum'),
mona.string('background3')
)
return mona.or(
mona.noneOf('"'),
mona.and(
mona.string('""'),
mona.value('"')))
}
function bit () {
@@ -68,28 +63,39 @@ function address () {
)
}
function parameter () {
return mona.collect(
mona.or(
address(),
binary(),
hex(),
string(),
bit(),
alphanum()
// this is the fallthrough parser
function alphanum () {
return mona.join(
mona.value('alphanum'),
mona.and(
mona.not(bit()),
mona.not(address()),
mona.not(binary()),
mona.not(bit()),
mona.not(string()),
mona.text(mona.alphanum())
)
)
}
function parameter () {
return mona.or(
address(),
binary(),
hex(),
string(),
bit(),
alphanum()
)
}
function parameters () {
return mona.map(a => a.map(b => b[0]),
mona.split(
parameter(),
mona.or(
mona.and(mona.string(','), mona.spaces()),
mona.string(','),
mona.spaces()
)
return mona.split(
parameter(),
mona.or(
mona.and(mona.string(','), mona.spaces()),
mona.string(','),
mona.spaces()
)
)
}