Permalink
Browse files

Modify SyncSpec parser to make ground for syncing rules support

  • Loading branch information...
1 parent 0dca985 commit 6325fca31176e8874fb903f34c60c0b8aae0311f @slothspot committed Nov 21, 2010
Showing with 13 additions and 8 deletions.
  1. +13 −8 src/name/dmitrym/syncspec/SyncSpec.scala
@@ -14,20 +14,20 @@ class SyncSpec extends StandardTokenParsers {
val Source, Destination = Value
}
- lexical.reserved += ("copy", "move", "sync", "from", "to")
+ lexical.reserved += ("copy", "move", "sync", "from", "to", "with")
- def operation = (command ~ source ~ destination | command ~ destination ~ source) ^^ {
+ def operation : Parser[(Command.Command, String, String)] = (command ~ source ~ destination | command ~ destination ~ source ) ^^ {
case Command.Copy ~ l1 ~ l2 => (l1,l2) match {
- case ((Location.Source, src), (Location.Destination, dest)) => Worker.copy(src, dest)
- case ((Location.Destination, dest), (Location.Source, src)) => Worker.copy(src,dest)
+ case ((Location.Source, src), (Location.Destination, dest)) => (Command.Copy, src, dest)
+ case ((Location.Destination, dest), (Location.Source, src)) => (Command.Copy, src, dest)
}
case Command.Move ~ l1 ~ l2 => (l1,l2) match {
- case ((Location.Source, src), (Location.Destination, dest)) => Worker.move(src, dest)
- case ((Location.Destination, dest), (Location.Source, src)) => Worker.move(src, dest)
+ case ((Location.Source, src), (Location.Destination, dest)) => (Command.Move, src, dest)
+ case ((Location.Destination, dest), (Location.Source, src)) => (Command.Move, src, dest)
}
case Command.Sync ~ l1 ~ l2 => (l1,l2) match {
- case ((Location.Source, src), (Location.Destination, dest)) => Worker.sync(src, dest)
- case ((Location.Destination, dest), (Location.Source, src)) => Worker.sync(src, dest)
+ case ((Location.Source, src), (Location.Destination, dest)) => (Command.Sync, src, dest)
+ case ((Location.Destination, dest), (Location.Source, src)) => (Command.Sync, src, dest)
}
}
@@ -45,7 +45,12 @@ class SyncSpec extends StandardTokenParsers {
case "to" ~ loc => (Location.Destination, loc)
}
+ def rule : Parser[String] = ("with" ~ ruleloc) ^^ {
+ case "with" ~ loc => loc
+ }
+
def location = stringLit
+ def ruleloc = stringLit
def doMatchOperation( op : String ) = {
operation( new lexical.Scanner( op ) ) match {

0 comments on commit 6325fca

Please sign in to comment.