1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Add the sexpr grammar to the tests.

This commit is contained in:
Rob Rix 2015-09-15 14:28:32 -04:00
parent 29dcc19069
commit 02de7f075e

View File

@ -1,3 +1,18 @@
final class DoubtTests: XCTestCase {}
let atom = Syntax<Fix>.Variable <^> ^("abcdefghijklmnopqrstuvwxyz".characters.map { String($0) })
let ws = ^(" \t\n".characters.map { String($0) })
let sexpr: String -> State<Fix>? = fix { sexpr in
let list = Syntax<Fix>.Apply <^> (ws* *> ^"(" *> ws* *> sexpr <*> sexpr* <* ^")")
return Fix.init <^> (atom <|> list) <* ws*
}
func fix<T, U>(f: (T -> U) -> T -> U) -> T -> U {
return { f(fix(f))($0) }
}
import Doubt
import XCTest