Beispiel #1
0
func ReadFile(port interface{}) interface{} {
	return readExpr(
		peg.Select(peg.And{
			peg.Bind(peg.Repeat(syntax), func(x interface{}) interface{} {
				return vecToLs(Vector(x.([]interface{})))
			}),
			peg.Eof,
		}, 0),
		port,
	)
}
Beispiel #2
0
			if err != nil {
				SystemError(err)
			}
			return res
		}),
		peg.Bind(_STR, func(x interface{}) interface{} {
			res, err := strconv.Unquote(x.(string))
			if err != nil {
				SystemError(err)
			}
			return res
		}),
		listExpr(_LSTART, expr, _LEND),
		listExpr(_LSTART2, expr, _LEND2),
		peg.Bind(
			peg.Select(peg.And{_VSTART, peg.Repeat(expr), _LEND}, 1),
			func(x interface{}) interface{} {
				return Vector(x.([]interface{}))
			},
		),
		peg.Bind(peg.And{_QUOTE, expr}, func(x interface{}) interface{} {
			qu := x.([]interface{})
			s := ""
			switch qu[0].(string) {
			case "'":
				s = "quote"
			case "`":
				s = "quasiquote"
			case ",":
				s = "unquote"
			case ",@":