JCLL
JCLL

Reputation: 5545

well-formness/schema of S-expressions

I am looking for tools that check the well-formness/schema of S-expressions.

Are you aware of such tools ?

As precised by Paul Nathan, what I'm exactly looking for is a Schema validator for sexp.

Upvotes: 3

Views: 710

Answers (2)

SK-logic
SK-logic

Reputation: 9714

I suspect that OP question is about replacing the XML technology stack with S-expressions and Lisp.

An idiomatic approach with S-expressions is to implement ad hoc validators and transformers, tailored for specific data formats. Since Lisps are nearly declarative (and they allow defining countless possible declarative languages on top of them) there is no need in a specialised, common solution like XML Schema or DTD.

Depending on the Lisp flavour you're using, you can choose a pattern matching library suitable for your needs. Embedded Prolog implementations (like Schelog) can help too.

Upvotes: 2

Vatine
Vatine

Reputation: 21258

S-expressions don't really have schemas, as such. Well-formed S-expressions in something approaching a normal grammar description conform to (very roughly):

atom := <character>+
sexp := atom | '(' sexp* ')'

That is, an S-exp is either a single atom or a list of zero or more S-expressions. Writing a validator for that shouldn't be too hard.

Upvotes: -1

Related Questions