Created
January 30, 2009 04:12
-
-
Save okomok/54936 to your computer and use it in GitHub Desktop.
LRule test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Shunsuke Sogame 2008-2009. | |
// Distributed under the terms of an MIT-style license. | |
// See: "Packrat Parsers Can Support Left Recursion" | |
package madatest.peg | |
import mada.Peg._ | |
import junit.framework.Assert._ | |
import mada.Peg.Compatibles._ | |
import mada.Vector.Compatibles._ | |
class LRuleTest { | |
/* | |
val v = madaVector("1-2-3") | |
val lr = new mada.peg.LRules[Char] | |
val expr = lr.makeRule | |
val num = lr.makeRule | |
val x = lr.makeRule | |
def testTrivial: Unit = { | |
num ::= range('0','9') | |
expr ::= ( expr >> "-" >> num | num ) | |
assertEquals(5, expr parse v) | |
} | |
def testIndirect: Unit = { | |
num ::= range('0', '9') | |
x ::= expr | |
expr ::= ( x >> "-" >> num | num ) | |
assertEquals(5, expr parse v) | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment