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:
parent
29dcc19069
commit
02de7f075e
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user