babel-bridge
Version:
a 'runtime' parsing expression grammar parser
40 lines (34 loc) • 962 B
text/coffeescript
{log, wordsArray} = Neptune.Art.StandardLib
{Parser, Nodes} = Neptune.BabelBridge
module.exports = suite: ->
test "three different labels", ->
class MyParser extends Parser
root:
pattern: """
a:'eh'?
b:'bee'?
c:'cee'?
"""
nodeClass:
result: ->
a: ?.text
b: ?.text
c: ?.text
mainNode = MyParser.parse "ehcee"
assert.eq mainNode.result(), a: "eh", b: undefined, c: "cee"
test "three same labels", ->
class MyParser extends Parser
root:
pattern: """
a:'eh'?
a:'bee'?
a:'cee'?
"""
nodeClass:
result: ->
a: .text
"matches.a": (match.text for match in )
mainNode = MyParser.parse "ehcee"
assert.eq mainNode.result(), a: "cee", "matches.a": ["eh", "cee"]