summaryrefslogtreecommitdiff
path: root/scalatexApi
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-07 08:51:18 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-07 08:51:18 -0800
commit00b8d7005e233bafced3467174e95cf6edb6eec1 (patch)
tree8d10038c70fe81e8c47e7b4e0ca95a51f956f410 /scalatexApi
parent75e505e6a433657cff28501f296605012e1e759a (diff)
downloadhands-on-scala-js-00b8d7005e233bafced3467174e95cf6edb6eec1.tar.gz
hands-on-scala-js-00b8d7005e233bafced3467174e95cf6edb6eec1.tar.bz2
hands-on-scala-js-00b8d7005e233bafced3467174e95cf6edb6eec1.zip
First flesh out of Semantic Differences
Diffstat (limited to 'scalatexApi')
-rw-r--r--scalatexApi/src/main/scala/scalatex/stages/Compiler.scala9
-rw-r--r--scalatexApi/src/main/scala/scalatex/stages/Parser.scala14
2 files changed, 10 insertions, 13 deletions
diff --git a/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala b/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
index 43c23a8..b34e94d 100644
--- a/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
+++ b/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
@@ -50,7 +50,7 @@ object Compiler{
}
- q"$out: $fragType"
+ out
}
def compileBlock(parts: Seq[Ast.Block.Sub], offset: Int): Seq[c.Tree] = {
val res = parts.map{
@@ -69,7 +69,6 @@ object Compiler{
val res = If(incPosRec(cond, offset1 + 2), compileBlockWrapped(parts2, offset2), elseCompiled)
- println("Tree " + res)
incPos(res, offset1)
res
case Ast.Block.For(generators, Ast.Block(parts2, offset2), offset1) =>
@@ -86,11 +85,7 @@ object Compiler{
compileBlockWrapped(parts2, offset2)
}
- val out = rec(tree)
- println(out)
-
- q"$out: $fragType"
-
+ rec(tree)
}
res
}
diff --git a/scalatexApi/src/main/scala/scalatex/stages/Parser.scala b/scalatexApi/src/main/scala/scalatex/stages/Parser.scala
index 3b79878..6929f34 100644
--- a/scalatexApi/src/main/scala/scalatex/stages/Parser.scala
+++ b/scalatexApi/src/main/scala/scalatex/stages/Parser.scala
@@ -109,26 +109,28 @@ class Parser(input: ParserInput, indent: Int = 0, offset: Int = 0) extends Scala
')'
}
def BlockExpr2: Rule0 = rule { '{' ~ Ws ~ (CaseClauses | Block) ~ '}' }
- def BraceBlock: Rule1[Ast.Block] = rule{ '{' ~ Body ~ '}' }
+ def BraceBlock: Rule1[Ast.Block] = rule{ '{' ~ BodyNoBrace ~ '}' }
- def BodyItem: Rule1[Seq[Ast.Block.Sub]] = rule{
+ def BodyItem(exclusions: String): Rule1[Seq[Ast.Block.Sub]] = rule{
ForLoop ~> (Seq(_)) |
LoneForLoop ~> (Seq(_, _)) |
IfElse ~> (Seq(_)) |
LoneScalaChain ~> (Seq(_, _)) |
HeaderBlock ~> (Seq(_)) |
- TextNot("@}") ~> (Seq(_)) |
+ TextNot("@" + exclusions) ~> (Seq(_)) |
(push(offsetCursor) ~ capture(Indent) ~> ((i, x) => Seq(Ast.Block.Text(x, i)))) |
(push(offsetCursor) ~ capture(BlankLine) ~> ((i, x) => Seq(Ast.Block.Text(x, i)))) |
ScalaChain ~> (Seq(_: Ast.Block.Sub))
}
- def Body = rule{
- push(offsetCursor) ~ oneOrMore(BodyItem) ~> {(i, x) =>
+ def Body = rule{ BodyEx() }
+ def BodyNoBrace = rule{ BodyEx("}") }
+ def BodyEx(exclusions: String = "") = rule{
+ push(offsetCursor) ~ oneOrMore(BodyItem(exclusions)) ~> {(i, x) =>
Ast.Block(x.flatten, i)
}
}
def Body0 = rule{
- push(offsetCursor) ~ zeroOrMore(BodyItem) ~> {(i, x) =>
+ push(offsetCursor) ~ zeroOrMore(BodyItem("")) ~> {(i, x) =>
Ast.Block(x.flatten, i)
}
}