PHPackages                             maths22/sexp-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. maths22/sexp-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

maths22/sexp-php
================

S-expression parser for PHP

0401PHP

Since Aug 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/maths22/sexp-php)[ Packagist](https://packagist.org/packages/maths22/sexp-php)[ RSS](/packages/maths22-sexp-php/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

S-expression parser and serializer for PHP
==========================================

[](#s-expression-parser-and-serializer-for-php)

A simple class to work with [S-expressions](http://en.wikipedia.com/wiki/S-expression)(symbolic expressions). From the Wikipedia:

> S-expressions or sexps (for "symbolic expression") are list-based data structures that represent semi-structured data. An S-expression may be a nested list of smaller S-expressions. S-expressions are probably best known for their use in the Lisp family of programming languages.

Note that this parser is not suitable to work with very large files (several megabytes and above), since the whole file is parsed and stored in a memory structure based on arrays.

Supported syntax
----------------

[](#supported-syntax)

This implementation supports the following syntax (in BNF format):

```
    	::  |
   	::  |  |  |  ;
    	:: + ;
  	:: "|" (  |  | "+" | "/" | "=" )* "|" ;
   	:: "#" (  | "A" ... "F" | "a" ... "f" |  )* "#" ;
 	:: "\""  "\"" | "'"  "'" ;
     	:: "(" (  |  )* ")" ;
 ::  |  |  ;
		:: ( " " | "\t" | "\r" | "\n" )* ;
		:: "0" ... "9" ;
     :: "A" ... "Z" | "a" ... "z" |  ;
 		:: "-" | "." | "/" | "_" | ":" | "*" | "+" | "=" ;
	:: ";"  -- until the end of line

```

Example s-expression syntax
---------------------------

[](#example-s-expression-syntax)

```
(foo
	"this is a \"quoted\" string"
	"also supporting\nnew lines"
	"The following number will be automatically casted to an integer"
	1231
	"unless you call ->setCastNumbers(false)"
	(bar
		; Line comment
		(int 10) ; This is a comment too
		(float 3.1415)
		(string "foobar")
		(string 'single quotes')
		(base64 |YWJj|)     ; "abc" encoded in base64
		(hex #61 62 63#)    ; "abc" encoded as hex octets
	)
)

```

Library usage
-------------

[](#library-usage)

```
$sexp = new \DrSlump\Sexp();

// Parse an s-expression and return an array with the data
$arr = $sexp->parse('(foo (bar 10) baz)');

print_r($arr);

// Array
// (
//    [0] => foo
//    [1] => Array
//        (
//            [0] => bar
//            [1] => 10
//        )
//
//    [2] => baz
// )

// Serialize an array structure into an s-expression string
$exp = $sexp->serialize($arr);

```

LICENSE
-------

[](#license)

```
The MIT License

Copyright (c) 2011 Iván -DrSlump- Montes

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3067361?v=4)[Jacob Burroughs](/maintainers/maths22)[@maths22](https://github.com/maths22)

---

Top Contributors

[![maths22](https://avatars.githubusercontent.com/u/3067361?v=4)](https://github.com/maths22 "maths22 (3 commits)")[![tobbi](https://avatars.githubusercontent.com/u/583169?v=4)](https://github.com/tobbi "tobbi (1 commits)")

### Embed Badge

![Health badge](/badges/maths22-sexp-php/health.svg)

```
[![Health](https://phpackages.com/badges/maths22-sexp-php/health.svg)](https://phpackages.com/packages/maths22-sexp-php)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M42](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

112.9k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
