diff options
author | Johannes Rudolph <johannes.rudolph@gmail.com> | 2014-09-01 11:51:17 +0200 |
---|---|---|
committer | Johannes Rudolph <johannes.rudolph@gmail.com> | 2014-09-01 11:51:17 +0200 |
commit | ead8d3df2e155762fc426b8d3fcd7d97af83a235 (patch) | |
tree | 03573513c169806c22376225df778e0ad7aec561 /src/main/scala | |
parent | 3416a1479075cee8c1ec14ba2803458a674e3311 (diff) | |
download | sbt-boilerplate-ead8d3df2e155762fc426b8d3fcd7d97af83a235.tar.gz sbt-boilerplate-ead8d3df2e155762fc426b8d3fcd7d97af83a235.tar.bz2 sbt-boilerplate-ead8d3df2e155762fc426b8d3fcd7d97af83a235.zip |
fix infinite parser loop with Scala <= 2.9
Diffstat (limited to 'src/main/scala')
-rw-r--r-- | src/main/scala/spray/boilerplate/TemplateParser.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main/scala/spray/boilerplate/TemplateParser.scala b/src/main/scala/spray/boilerplate/TemplateParser.scala index 2d186c7..3e20fb1 100644 --- a/src/main/scala/spray/boilerplate/TemplateParser.scala +++ b/src/main/scala/spray/boilerplate/TemplateParser.scala @@ -36,20 +36,22 @@ object TemplateParser extends RegexParsers { type Tokens = TemplateElement override val skipWhitespace = false + val EOI = 26.toChar + def elements: Parser[TemplateElement] = rep1(element) ^^ maybeSequence def element: Parser[TemplateElement] = offset | literalString | expand def offset: Parser[Offset] = offsetChars ^^ (s ⇒ Offset(s.toInt)) def literalString: Parser[LiteralString] = rep1(escapedLiteralNumber | literalChar) ^^ (chs ⇒ LiteralString(chs.mkString)) def literalChar: Parser[Char] = - not(expandStart | """#[^\]]*\]""".r | offsetChars) ~> elem("Any character", _ ⇒ true) + not(expandStart | """#[^\]]*\]""".r | offsetChars) ~> elem("Any character", _ != EOI) def offsetChars = "[012]".r def escapedLiteralNumber: Parser[Char] = "##" ~> offsetChars ^^ (_.head) def outsideLiteralString: Parser[LiteralString] = rep1(outsideLiteralChar) ^^ (chs ⇒ LiteralString(chs.mkString)) - def outsideLiteralChar: Parser[Char] = not(expandStart | """#[^\]]*\]""".r) ~> elem("Any character", _ ⇒ true) + def outsideLiteralChar: Parser[Char] = not(expandStart | """#[^\]]*\]""".r) ~> elem("Any character", _ != EOI) def expand: Parser[Expand] = expandStart ~ elements ~ "#" ~ separatorChars <~ "]" ^^ { case range ~ els ~ x ~ sep ⇒ Expand(els, sep.getOrElse(Expand.defaultSeparator), range) |