kdrag.parsers.sexp.parse

kdrag.parsers.sexp.parse(s: str) list[Sexp]

Parse an s-expression

>>> parse("(foo (bar X Y) Z); yoyoyo \n (foo)")
[['foo', ['bar', 'X', 'Y'], 'Z'], ['foo']]
>>> parse("     (define-const x Int)     (define-fun f ((a Int) (b Int)) Int)     (assert (= (f x 3) 4 4.7))     (check-sat)     ")
[['define-const', 'x', 'Int'],
 ['define-fun', 'f', [['a', 'Int'], ['b', 'Int']], 'Int'],
 ['assert', ['=', ['f', 'x', 3], 4, 4.7]],
 ['check-sat']]
>>> parse("(-17)")
[[-17]]
>>> parse("(- 1 2 3 -3.6)")
[['-', 1, 2, 3, -3.6]]
>>> parse("(foo @@@)")
Traceback (most recent call last):
 ...
ValueError: ('unexpected characters', '@@@', '(foo @@@)')
Parameters:

s (str)

Return type:

list[Sexp]