Skip to content

Commit

Permalink
fixes for parsers (after migration to scala 2.10) + scala 2.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-klyuchnikov committed Jun 8, 2013
1 parent b34c9da commit fbe9267
Show file tree
Hide file tree
Showing 22 changed files with 113 additions and 135 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.10.1"
scalaVersion := "2.10.2"

name := "tapl-scala"

Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/tapl/arith/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package tapl.arith

import scala.util.parsing.combinator.ImplicitConversions
import scala.util.parsing.combinator.syntactical.StandardTokenParsers
import scala.util.parsing.input.{ CharSequenceReader => Reader }

object ArithParsers extends StandardTokenParsers with ImplicitConversions {
lexical.reserved += ("true", "false", "if", "then", "else", "iszero", "succ", "pred")
lexical.delimiters += ("(", ")", ";")

private def topLevel: Parser[List[Command]] =
eof ^^ { _ => List() } |
(command <~ ";") ~ topLevel ^^ { case c ~ cs => c :: cs }
(command <~ ";") ~ topLevel ^^ { case c ~ cs => c :: cs } |
success(List())

private def command: Parser[Command] =
term ^^ Eval
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/tapl/bot/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object BotParsers extends StandardTokenParsers with PackratParsers with Implicit
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
} | success{ ctx: Context => (List(), ctx) }

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/equirec/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ object EquirecParsers extends StandardTokenParsers with PackratParsers with Impl
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullequirec/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object FullEquirecParsers extends StandardTokenParsers with PackratParsers with
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullerror/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ object FullErrorParsers extends StandardTokenParsers with PackratParsers with Im
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullfomsub/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ object FullFomSubParsers extends StandardTokenParsers with PackratParsers with I
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullfomsubref/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ object FullFomSubRefParsers extends StandardTokenParsers with PackratParsers wit
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullfsub/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object FullFSubParsers extends StandardTokenParsers with PackratParsers with Imp
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullisorec/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object FullIsorecParsers extends StandardTokenParsers with PackratParsers with I
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullomega/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ object FullOmegaParsers extends StandardTokenParsers with PackratParsers with Im
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullpoly/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object FullPolyParsers extends StandardTokenParsers with PackratParsers with Imp
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullrecon/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object FullReconParsers extends StandardTokenParsers with PackratParsers with Im
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullref/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object FullRefParsers extends StandardTokenParsers with PackratParsers with Impl
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullsimple/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ object FullSimpleParsers extends StandardTokenParsers with PackratParsers with I
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fullsub/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object FullSubParsers extends StandardTokenParsers with PackratParsers with Impl
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/fulluntyped/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object FullUntypedParsers extends StandardTokenParsers with PackratParsers with
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/rcdsubbot/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object RcdSubBotParsers extends StandardTokenParsers with PackratParsers with Im
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/recon/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ object ReconParsers extends StandardTokenParsers with PackratParsers with Implic
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/tapl/simplebool/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ object SimpleBoolParsers extends StandardTokenParsers with PackratParsers with I
type Res1[A] = Context => (A, Context)

lazy val topLevel: PackratParser[Res1[List[Command]]] =
eof ^^ { _ => ctx: Context => (List(), ctx) } |
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
}
((command <~ ";") ~ topLevel) ^^ {
case f ~ g => ctx: Context =>
val (cmd1, ctx1) = f(ctx)
val (cmds, ctx2) = g(ctx1)
(cmd1 :: cmds, ctx2)
} | success{ctx: Context => (List(), ctx)}

lazy val command: PackratParser[Res1[Command]] =
lcid ~ binder ^^ { case id ~ bind => ctx: Context => (Bind(id, bind(ctx)), ctx.addName(id)) } |
Expand Down
4 changes: 1 addition & 3 deletions src/main/scala/tapl/tyarith/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package tapl.tyarith

import scala.util.parsing.combinator.ImplicitConversions
import scala.util.parsing.combinator.syntactical.StandardTokenParsers
import scala.util.parsing.input.{ CharSequenceReader => Reader }

object ArithParsers extends StandardTokenParsers with ImplicitConversions {
lexical.reserved += ("true", "false", "if", "then", "else", "iszero", "succ", "pred")
lexical.delimiters += ("(", ")", ";")

private def topLevel: Parser[List[Command]] =
eof ^^ { _ => List() } |
(command <~ ";") ~ topLevel ^^ { case c ~ cs => c :: cs }
(command <~ ";") ~ topLevel ^^ { case c ~ cs => c :: cs } | success(List())

private def command: Parser[Command] =
term ^^ Eval
Expand Down
Loading

0 comments on commit fbe9267

Please sign in to comment.