csdltools

Tools for working with DataSift's CSDL language

License

License

GroupId

GroupId

com.github.jond3k
ArtifactId

ArtifactId

csdltools
Last Version

Last Version

0.5
Release Date

Release Date

Type

Type

jar
Description

Description

csdltools
Tools for working with DataSift's CSDL language
Source Code Management

Source Code Management

https://github.com/jond3k/csdltools

Download csdltools

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.jond3k/csdltools/ -->
<dependency>
    <groupId>com.github.jond3k</groupId>
    <artifactId>csdltools</artifactId>
    <version>0.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.jond3k/csdltools/
implementation 'com.github.jond3k:csdltools:0.5'
// https://jarcasting.com/artifacts/com.github.jond3k/csdltools/
implementation ("com.github.jond3k:csdltools:0.5")
'com.github.jond3k:csdltools:jar:0.5'
<dependency org="com.github.jond3k" name="csdltools" rev="0.5">
  <artifact name="csdltools" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.jond3k', module='csdltools', version='0.5')
)
libraryDependencies += "com.github.jond3k" % "csdltools" % "0.5"
[com.github.jond3k/csdltools "0.5"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.9.1
org.apache.commons : commons-lang3 jar 3.1
org.apache.commons : commons-io jar 1.3.2

test (2)

Group / Artifact Type Version
org.scalatest : scalatest_2.9.1 jar 2.0.M3
org.mockito : mockito-all jar 1.9.0

Project Modules

There are no modules declared in this project.

#CsdlTools

Tools for working with DataSift's Csdl query language

##Csdl Parser

You can start parsing Csdl straight away. Just use the Csdl.parse method

val csdl = Csdl.parse("interaction.content contains \"cheese\"")

The object you'll get back is some form of CsdlBody. Using pattern matching you can decide what to do next.

csdl match {
  case And(l, r) =>
    println("The left hand side is: %s" format l)
    println("The right hand side is: %s" format r)
  case _ => // ..

The hierarchy of AST classes is:

CsdlNode
|- CsdlBody
| |- And
| |- Or
| |- Not
| |- CsdlTaggedBody
| |- Returns
| |- Rule
| |- Stream
|- Argument
| |- Operator
| |- Target
| |- Text
| |- TextList
|- Tag

The parser is implemented using Scala's built-in parser combinators and doesn't provide very good error-handling so isn't too good for use inside editors, etc. It can be pretty useful for automated analysis and optimzation of CSDL we already know is well-formed.

##Future Goals

Right now I'm interested in adding the following:

  • Conversion to other languages
  • Optimization
  • Pretty-printing
  • Versioning, to automatically upgrade statements to newer version of the language

Versions

Version
0.5
0.4
0.3
0.2
0.1