-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a1b7ba2
Showing
5 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.swp | ||
frontend/target | ||
frontend/.idea | ||
frontend/project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name := "frontend" | ||
|
||
version := "1.0" | ||
|
||
scalaVersion := "2.11.8" | ||
|
||
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4" |
35 changes: 35 additions & 0 deletions
35
frontend/src/main/scala/edu/berkeley/cs/sdb/ConfigParser.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package edu.berkeley.cs.sdb | ||
|
||
import scala.util.parsing.combinator._ | ||
|
||
class ConfigParser extends JavaTokenParsers { | ||
def path: Parser[String] = """/?([a-zA-z\._\-]+/)*[a-zA-z\._\-]+""".r | ||
def entity = "entity" ~> path | ||
|
||
|
||
def URI: Parser[String] = """([a-zA-z\._\-]/)*[a-zA-Z\._\-](/\* | /\+)?""".r | ||
def spawnpointList: Parser[Seq[String]] = "spawnpoints" ~> "{" ~> rep1sep(URI, ",") <~ "}" | ||
|
||
|
||
def value: Parser[Any] = stringLiteral | | ||
wholeNumber ^^ (_.toInt) | | ||
floatingPointNumber ^^ (_.toDouble) | ||
|
||
def valueSequence: Parser[Seq[Any]] = "[" ~> rep1sep(value, ",") <~ "]" | ||
|
||
def parameter: Parser[(String, Any)] = ident ~ ":" ~ (ident | value | valueSequence) ^^ { case k ~ ":" ~ v => (k,v) } | ||
|
||
def parameterSequence: Parser[Seq[(String, Any)]] = "{" ~> repsep(parameter, ",") <~ "}" | ||
|
||
def spawnpointSpec: Parser[Either[String, Seq[(String, Any)]]] = | ||
"on" ~> (ident | stringLiteral) ^^ (Left(_)) | ||
"where" ~> parameterSequence ^^ (Right(_)) | ||
|
||
def serviceDeployment: Parser[Service] = "deploy" ~ path ~ "as" ~ ident ~ "with" ~ parameterSequence ~ spawnpointSpec ^^ | ||
{ case "deploy" ~ imgName ~ "as" ~ svcName ~ "with" ~ params ~ spec => Service(svcName, imgName, params, spec) } | ||
|
||
def svcGraph: Parser[Seq[(String, String)]] = repsep(ident, "->") ^^ (_.sliding(2).map { case Seq(x, y) => (x, y) }.toSeq) | ||
|
||
def deployment: Parser[Deployment] = entity ~ spawnpointList ~ rep(serviceDeployment) ~ rep(svcGraph) ^^ | ||
{ case ent ~ spawnpoints ~ svcs ~ connList => Deployment(ent, spawnpoints, svcs, connList.flatten) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package edu.berkeley.cs.sdb | ||
|
||
case class Deployment(entity: String, spawnPointUris: Seq[String], services: Seq[Service], | ||
topology: Seq[(String, String)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package edu.berkeley.cs.sdb | ||
|
||
case class Service(name: String, imageName: String, params: Seq[(String, Any)], | ||
spawnpointSpec: Either[String, Seq[(String, Any)]]) |