SDLang (Simple Declarative Language) for Java
SDLang is a simple and concise way to textually represent data. It has an XML-like structure – tags, values and attributes – which makes it a versatile choice for data serialization, configuration files, or declarative languages. Its syntax was inspired by the C family of languages (C/C++, C#, D, Java, …).
Adding the dependency to your project
Releases are available from Maven Central
<dependency> <groupId>com.singingbush</groupId> <artifactId>sdlang</artifactId> <version>2.1.0</version> </dependency>
To parse an SDL file simply create an InputStreamReader and pass it into the constructor of Parser:
final InputStream inputStream = new FileInputStream("c:\\data\\myfile.sdl"); final Reader inputStreamReader = new InputStreamReader(inputStream, "UTF-8"); final List<Tag> tags = new Parser(inputStreamReader).parse();
To write SDL from Java objects:
final Tag tag = SDL.tag("thing") .withNamespace("my") .withComment("This text will precede the 'my:thing' when serialised") .withValue(SDL.value('g')) .withChild(SDL.tag("child") .withComment("child tags can also have comments") .withValues(SDL.value(ZonedDateTime.now()), SDL.value("some text")) .build() ) .withAttribute("flt", SDL.value(0.0f)) .withAttribute("lng", SDL.value(1_000L)) .build();
This code was originally dumped in github in May 2011 with a single commit message stating that it was migrated from svn.
Since then there's been no activity in that repository and it seems that issues are ignored. Even the URL for documentation is broken.
As the project appears to be abandoned I've forked it with the goal of
- Adding more unit tests
- Enabling continuous integration using travis-ci.org
- Reporting on Test Coverage using coveralls.io
- Fixing existing bugs
- Overhaul the project and start rewriting the codebase
- Publish build artifacts to maven central
Daniel Leuck, the original author, licensed the source as LGPL v2.1