ast-parser


License

License

GroupId

GroupId

com.github.kardapoltsev
ArtifactId

ArtifactId

ast-parser_2.10
Last Version

Last Version

5.0.8
Release Date

Release Date

Type

Type

jar
Description

Description

ast-parser
ast-parser
Project URL

Project URL

https://github.com/kardapoltsev/astparser
Project Organization

Project Organization

Alexey Kardapoltsev
Source Code Management

Source Code Management

https://github.com/kardapoltsev/astparser

Download ast-parser_2.10

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.10.7
org.apache.logging.log4j : log4j-api jar 2.11.1
org.apache.logging.log4j : log4j-api-scala_2.10 jar 11.0

test (2)

Group / Artifact Type Version
org.apache.logging.log4j : log4j-core jar 2.11.1
org.scalatest : scalatest_2.10 jar 3.0.5

Project Modules

There are no modules declared in this project.

astparser Build Status Coverage Status

Schema parser for different code generators

DSL description

Type

Defines a model. Animal is called Type, Catand Dog are called classes in this documentation

type Animal {

  cat

  dog ::
   name: String

}

Example above is equivalent to:

abstract class Animal
class Cat extends Animal
class Dog(name: String) extends Animal

Call

Defines a API request definition

call requestName ::
  param1: Int
  => Long

It's equivalent to a request which returns Long as a result

class RequestName(param1: Int)

Trait

Defines a trait (mixin). <: is used to specify traits for call or type

trait TraitName1
trait TraitName2

call CallName <: TraitName1 TraitName2 ::
  param1: Int
  => Int

Type alias

Defines a type alias

type AliasName = Int

External type

Defines a predefined schema type like Int, Long, String etc

external type Int

Package

Defines a package (scope of visibility)

package packageName {
}

Import

Defines an import

package a {
  type X {
    x
  }
}
package b {
  import a.x
  call Y ::
    param1: x
  => Int
}

Supported features

Inheritance

Type, Call and class could extend any number of Traits. Any class inherit traits from the enclosing Type

trait T1
trait T2
type Type1 <: T1 {
  className <: T2
}

References

package1.package2.TypeName is called reference. Both absolute and relative reference are supported

package p1 {
  package p2 {
    type T1 {
      t1
    }
    type T2 {
      t2
    }
    type T3 {
      t3
    }
    type T4 {
      t4
    }
  }
  package p3 {
    import p2.T1
    import p1.p2.T2
    type AliasT4 = p2.T4

    call C1 ::
      param1: T1
      param2: T2
      param3: p1.p3.T3
      param4: AliasT4
    => Int

  }
}

Documentation

Documentation could include references to another schema elements. `` is used for it.

/** Docs for type with a link to some other `T2` */
type T1 {
  /** Docs for class
      with a multipe lines
   */
  t1 ::
    field1: Int -- docs for field1
}

Versioning

Any class or Call may refer to a specific API version. (1-3) means that c1 is available from the 1st to the 3rd versions. (1-) means that c1 is available from the 1st to the latest versions (-3) means that call is available from the oldest to the 3rd versions

/** Parameterless call */
call c1 (1-3)
  => Int

Quotation

Any schema keyword may be used as a Type or parameter name. Use `type`: Int for it.

Http definiton

Call may have an http definition.

  • param1 is a path parameter
  • param2 is a query parameter
  • param3 is a body parameter

Supported HTTP methods are GET, POST, PUT, PATCH, DELETE

@POST /api/{param1}?{param2}
call C1 <: Request ::
  param1 : Int
  param2 : Option[Long]
  param3 : String
  => String

Versions

Version
5.0.8
5.0.7
5.0.6
5.0.5
5.0.4
5.0.1
5.0.0
4.0.13
4.0.12
4.0.11
4.0.10
4.0.9
4.0.8
4.0.7
4.0.6
4.0.5
4.0.4
4.0.3
4.0.2
4.0.1
3.1.25
3.1.24
3.1.20
3.1.19
3.1.18
3.1.17
3.1.16
3.1.15
3.1.14
3.1.13
3.1.12
3.1.11
3.1.10
3.1.9
3.1.8
3.1.7
3.1.6
3.1.5
3.1.4
3.1.3
3.1.2
3.1.1
3.1.0
3.0.3
3.0.2
2.0.0
1.1.0
1.0.4
1.0.3