summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.idea/libraries/SBT__com_chuusai_shapeless_2_11_1_2_4.xml13
-rw-r--r--.idea/libraries/SBT__com_typesafe_akka_akka_actor_2_11_2_3_6.xml13
-rw-r--r--.idea/libraries/SBT__com_typesafe_config_1_2_1.xml14
-rw-r--r--.idea/libraries/SBT__io_spray_spray_can_2_11_1_3_2.xml14
-rw-r--r--.idea/libraries/SBT__io_spray_spray_http_2_11_1_3_2.xml14
-rw-r--r--.idea/libraries/SBT__io_spray_spray_httpx_2_11_1_3_2.xml14
-rw-r--r--.idea/libraries/SBT__io_spray_spray_io_2_11_1_3_2.xml14
-rw-r--r--.idea/libraries/SBT__io_spray_spray_routing_2_11_1_3_2.xml14
-rw-r--r--.idea/libraries/SBT__io_spray_spray_util_2_11_1_3_2.xml14
-rw-r--r--.idea/libraries/SBT__org_jvnet_mimepull_mimepull_1_9_4.xml13
-rw-r--r--.idea/libraries/SBT__org_parboiled_parboiled_core_1_1_6.xml14
-rw-r--r--.idea/libraries/SBT__org_parboiled_parboiled_scala_2_11_1_1_6.xml14
-rwxr-xr-xbook/src/main/resources/css/side-menu.css331
-rw-r--r--book/src/main/scala/book/Book.scala91
-rw-r--r--book/src/main/scala/book/BookData.scala17
-rw-r--r--book/src/main/scala/book/Main.scala93
-rw-r--r--book/src/main/scala/book/Utils.scala152
-rw-r--r--book/src/main/scalatex/book/Index.scalatex12
-rw-r--r--book/src/main/scalatex/book/Intro.scalatex9
-rw-r--r--build.sbt10
-rw-r--r--examples/crossBuilds/clientserver/build.sbt2
-rw-r--r--examples/crossBuilds/clientserver/client/src/main/scala/simple/Client.scala4
-rw-r--r--examples/crossBuilds/clientserver2/build.sbt2
-rw-r--r--examples/crossBuilds/clientserver2/client/src/main/scala/simple/Client.scala2
-rw-r--r--examples/crossBuilds/clientserver2/server/src/main/scala/simple/Server.scala5
-rw-r--r--examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala2
-rw-r--r--examples/crossBuilds/simple2/js/src/main/scala/simple/Platform.scala2
-rw-r--r--examples/demos/build.sbt2
-rw-r--r--examples/demos/src/main/scala/Splash.scala13
-rw-r--r--examples/demos/src/main/scala/advanced/Async.scala2
-rw-r--r--examples/demos/src/main/scala/advanced/BasicRx.scala4
-rw-r--r--examples/demos/src/main/scala/advanced/Futures.scala6
-rw-r--r--examples/demos/src/main/scala/canvasapp/Clock.scala4
-rw-r--r--examples/demos/src/main/scala/canvasapp/FlappyLine.scala2
-rw-r--r--examples/demos/src/main/scala/canvasapp/ScratchPad.scala30
-rw-r--r--examples/demos/src/main/scala/scrollmenu/Controller.scala4
-rw-r--r--examples/demos/src/main/scala/scrollmenu/ScrollSpy.scala2
-rw-r--r--examples/demos/src/main/scala/webpage/HelloWorld0.scala10
-rw-r--r--examples/demos/src/main/scala/webpage/HelloWorld1.scala9
-rw-r--r--examples/demos/src/main/scala/webpage/Inputs.scala2
-rw-r--r--examples/demos/src/main/scala/webpage/Search0.scala2
-rw-r--r--examples/demos/src/main/scala/webpage/Search1.scala2
-rw-r--r--examples/demos/src/main/scala/webpage/Weather0.scala4
-rw-r--r--examples/demos/src/main/scala/webpage/Weather1.scala4
-rw-r--r--examples/demos/src/main/scala/webpage/Weather2.scala4
-rw-r--r--examples/demos/src/main/scala/webpage/Weather3.scala4
-rw-r--r--examples/demos/src/main/scala/webpage/WeatherSearch.scala6
-rw-r--r--scalatex/api/src/main/scala/scalatex/package.scala98
-rw-r--r--scalatex/api/src/main/scala/scalatex/stages/Compiler.scala103
-rw-r--r--scalatex/api/src/main/scala/scalatex/stages/Omg/scala.scala8
-rw-r--r--scalatex/api/src/main/scala/scalatex/stages/Parser.scala170
-rw-r--r--scalatex/api/src/main/scala/scalatex/stages/Trim.scala29
-rw-r--r--scalatex/api/src/test/scala/scalatex/BasicTests.scala468
-rw-r--r--scalatex/api/src/test/scala/scalatex/ErrorTests.scala373
-rw-r--r--scalatex/api/src/test/scala/scalatex/ParserTests.scala424
-rw-r--r--scalatex/api/src/test/scala/scalatex/TestUtil.scala16
-rw-r--r--scalatex/build.sbt44
-rwxr-xr-xscalatex/compilerPlugin/src/main/resources/scalac-plugin.xml4
-rwxr-xr-xscalatex/compilerPlugin/src/main/scala/scalatex/CompilerPlugin.scala79
-rw-r--r--scalatex/project/build.properties1
-rw-r--r--scalatex/project/build.sbt1
-rw-r--r--scalatex/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala416
-rw-r--r--scalatex/scalaParser/src/main/scala/scalaParser/syntax/Basic.scala51
-rw-r--r--scalatex/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala35
-rw-r--r--scalatex/scalaParser/src/main/scala/scalaParser/syntax/Literals.scala58
-rw-r--r--scalatex/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala448
-rw-r--r--scalatex/scalatexSbtPlugin/src/main/scala/SbtPlugin.scala16
67 files changed, 313 insertions, 3544 deletions
diff --git a/.idea/libraries/SBT__com_chuusai_shapeless_2_11_1_2_4.xml b/.idea/libraries/SBT__com_chuusai_shapeless_2_11_1_2_4.xml
deleted file mode 100644
index 0ef1f4a..0000000
--- a/.idea/libraries/SBT__com_chuusai_shapeless_2_11_1_2_4.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: com.chuusai:shapeless_2.11:1.2.4">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.chuusai/shapeless_2.11/jars/shapeless_2.11-1.2.4.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.chuusai/shapeless_2.11/docs/shapeless_2.11-1.2.4-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.chuusai/shapeless_2.11/srcs/shapeless_2.11-1.2.4-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__com_typesafe_akka_akka_actor_2_11_2_3_6.xml b/.idea/libraries/SBT__com_typesafe_akka_akka_actor_2_11_2_3_6.xml
deleted file mode 100644
index d697090..0000000
--- a/.idea/libraries/SBT__com_typesafe_akka_akka_actor_2_11_2_3_6.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: com.typesafe.akka:akka-actor_2.11:2.3.6">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.typesafe.akka/akka-actor_2.11/jars/akka-actor_2.11-2.3.6.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.typesafe.akka/akka-actor_2.11/docs/akka-actor_2.11-2.3.6-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.typesafe.akka/akka-actor_2.11/srcs/akka-actor_2.11-2.3.6-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__com_typesafe_config_1_2_1.xml b/.idea/libraries/SBT__com_typesafe_config_1_2_1.xml
deleted file mode 100644
index 6a5807f..0000000
--- a/.idea/libraries/SBT__com_typesafe_config_1_2_1.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: com.typesafe:config:1.2.1">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.typesafe/config/bundles/config-1.2.1.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/com.typesafe/config/jars/config-1.2.1.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.typesafe/config/docs/config-1.2.1-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/com.typesafe/config/srcs/config-1.2.1-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__io_spray_spray_can_2_11_1_3_2.xml b/.idea/libraries/SBT__io_spray_spray_can_2_11_1_3_2.xml
deleted file mode 100644
index ba16743..0000000
--- a/.idea/libraries/SBT__io_spray_spray_can_2_11_1_3_2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: io.spray:spray-can_2.11:1.3.2">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-can_2.11/bundles/spray-can_2.11-1.3.2.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-can_2.11/jars/spray-can_2.11-1.3.2.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-can_2.11/docs/spray-can_2.11-1.3.2-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-can_2.11/srcs/spray-can_2.11-1.3.2-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__io_spray_spray_http_2_11_1_3_2.xml b/.idea/libraries/SBT__io_spray_spray_http_2_11_1_3_2.xml
deleted file mode 100644
index 6882c9d..0000000
--- a/.idea/libraries/SBT__io_spray_spray_http_2_11_1_3_2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: io.spray:spray-http_2.11:1.3.2">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-http_2.11/jars/spray-http_2.11-1.3.2.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-http_2.11/bundles/spray-http_2.11-1.3.2.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-http_2.11/docs/spray-http_2.11-1.3.2-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-http_2.11/srcs/spray-http_2.11-1.3.2-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__io_spray_spray_httpx_2_11_1_3_2.xml b/.idea/libraries/SBT__io_spray_spray_httpx_2_11_1_3_2.xml
deleted file mode 100644
index 52bd2f3..0000000
--- a/.idea/libraries/SBT__io_spray_spray_httpx_2_11_1_3_2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: io.spray:spray-httpx_2.11:1.3.2">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-httpx_2.11/jars/spray-httpx_2.11-1.3.2.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-httpx_2.11/bundles/spray-httpx_2.11-1.3.2.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-httpx_2.11/docs/spray-httpx_2.11-1.3.2-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-httpx_2.11/srcs/spray-httpx_2.11-1.3.2-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__io_spray_spray_io_2_11_1_3_2.xml b/.idea/libraries/SBT__io_spray_spray_io_2_11_1_3_2.xml
deleted file mode 100644
index 5e6ac51..0000000
--- a/.idea/libraries/SBT__io_spray_spray_io_2_11_1_3_2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: io.spray:spray-io_2.11:1.3.2">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-io_2.11/bundles/spray-io_2.11-1.3.2.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-io_2.11/jars/spray-io_2.11-1.3.2.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-io_2.11/docs/spray-io_2.11-1.3.2-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-io_2.11/srcs/spray-io_2.11-1.3.2-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__io_spray_spray_routing_2_11_1_3_2.xml b/.idea/libraries/SBT__io_spray_spray_routing_2_11_1_3_2.xml
deleted file mode 100644
index 070e877..0000000
--- a/.idea/libraries/SBT__io_spray_spray_routing_2_11_1_3_2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: io.spray:spray-routing_2.11:1.3.2">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-routing_2.11/jars/spray-routing_2.11-1.3.2.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-routing_2.11/bundles/spray-routing_2.11-1.3.2.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-routing_2.11/docs/spray-routing_2.11-1.3.2-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-routing_2.11/srcs/spray-routing_2.11-1.3.2-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__io_spray_spray_util_2_11_1_3_2.xml b/.idea/libraries/SBT__io_spray_spray_util_2_11_1_3_2.xml
deleted file mode 100644
index 4eb7798..0000000
--- a/.idea/libraries/SBT__io_spray_spray_util_2_11_1_3_2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: io.spray:spray-util_2.11:1.3.2">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-util_2.11/bundles/spray-util_2.11-1.3.2.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-util_2.11/jars/spray-util_2.11-1.3.2.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-util_2.11/docs/spray-util_2.11-1.3.2-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/io.spray/spray-util_2.11/srcs/spray-util_2.11-1.3.2-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__org_jvnet_mimepull_mimepull_1_9_4.xml b/.idea/libraries/SBT__org_jvnet_mimepull_mimepull_1_9_4.xml
deleted file mode 100644
index 7fcd3a6..0000000
--- a/.idea/libraries/SBT__org_jvnet_mimepull_mimepull_1_9_4.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: org.jvnet.mimepull:mimepull:1.9.4">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.jvnet.mimepull/mimepull/jars/mimepull-1.9.4.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.jvnet.mimepull/mimepull/docs/mimepull-1.9.4-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.jvnet.mimepull/mimepull/srcs/mimepull-1.9.4-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__org_parboiled_parboiled_core_1_1_6.xml b/.idea/libraries/SBT__org_parboiled_parboiled_core_1_1_6.xml
deleted file mode 100644
index 8cf44a6..0000000
--- a/.idea/libraries/SBT__org_parboiled_parboiled_core_1_1_6.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: org.parboiled:parboiled-core:1.1.6">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.parboiled/parboiled-core/jars/parboiled-core-1.1.6.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/org.parboiled/parboiled-core/bundles/parboiled-core-1.1.6.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.parboiled/parboiled-core/docs/parboiled-core-1.1.6-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.parboiled/parboiled-core/srcs/parboiled-core-1.1.6-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/.idea/libraries/SBT__org_parboiled_parboiled_scala_2_11_1_1_6.xml b/.idea/libraries/SBT__org_parboiled_parboiled_scala_2_11_1_1_6.xml
deleted file mode 100644
index fd53a7a..0000000
--- a/.idea/libraries/SBT__org_parboiled_parboiled_scala_2_11_1_1_6.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="SBT: org.parboiled:parboiled-scala_2.11:1.1.6">
- <CLASSES>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.parboiled/parboiled-scala_2.11/bundles/parboiled-scala_2.11-1.1.6.jar!/" />
- <root url="jar://$USER_HOME$/.ivy2/cache/org.parboiled/parboiled-scala_2.11/jars/parboiled-scala_2.11-1.1.6.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.parboiled/parboiled-scala_2.11/docs/parboiled-scala_2.11-1.1.6-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$USER_HOME$/.ivy2/cache/org.parboiled/parboiled-scala_2.11/srcs/parboiled-scala_2.11-1.1.6-sources.jar!/" />
- </SOURCES>
- </library>
-</component> \ No newline at end of file
diff --git a/book/src/main/resources/css/side-menu.css b/book/src/main/resources/css/side-menu.css
index 6439a28..ed06b5f 100755
--- a/book/src/main/resources/css/side-menu.css
+++ b/book/src/main/resources/css/side-menu.css
@@ -1,12 +1,4 @@
-body {
- color: #777;
-}
-*{
- position: relative;
-}
-p{
- text-align: justify;
-}
+
#main{
position: fixed;
max-width: 100%;
@@ -15,11 +7,39 @@ p{
height: 100%;
overflow-y: scroll
}
+
.pure-img-responsive {
max-width: 100%;
height: auto;
}
+
+.header {
+ margin: 0;
+ color: #333;
+ text-align: center;
+ padding: 2.5em 2em 0;
+ border-bottom: 1px solid #eee;
+}
+.header h1 {
+ margin: 0.2em 0;
+ font-size: 3em;
+ font-weight: 300;
+}
+.header h2 {
+ font-weight: 300;
+ color: #ccc;
+ padding: 0;
+ margin-top: 0;
+}
+
+.content-subhead {
+ margin: 50px 0 20px 0;
+ font-weight: 300;
+ color: #888;
+}
+
+
/*
Add transition to containers so they can push in and out.
*/
@@ -33,62 +53,6 @@ Add transition to containers so they can push in and out.
transition: all 0.2s ease-out;
}
-/*
-This is the parent `<div>` that contains the menu and the content area.
-*/
-#layout {
- position: relative;
- padding-left: 0;
-}
- #layout.active {
- position: relative;
- left: 250px;
- }
- #layout.active #menu {
- left: 250px;
- width: 250px;
- }
-
- #layout.active .menu-link {
- left: 250px;
- }
-/*
-The content `<div>` is where all your content goes.
-*/
-.content {
- margin: 0 auto;
- padding: 0 2em;
- max-width: 800px;
- margin-bottom: 50px;
- line-height: 1.6em;
-}
-
-.header {
- margin: 0;
- color: #333;
- text-align: center;
- padding: 2.5em 2em 0;
- border-bottom: 1px solid #eee;
- }
- .header h1 {
- margin: 0.2em 0;
- font-size: 3em;
- font-weight: 300;
- }
- .header h2 {
- font-weight: 300;
- color: #ccc;
- padding: 0;
- margin-top: 0;
- }
-
-.content-subhead {
- margin: 50px 0 20px 0;
- font-weight: 300;
- color: #888;
-}
-
-
/*
The `#menu` `<div>` is the parent `<div>` that contains the `.pure-menu` that
@@ -108,61 +72,61 @@ appears on the left side of the page.
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
}
- /*
- All anchors inside the menu should be styled like this.
- */
- #menu a {
- color: #999;
- border: none;
- padding: 0.6em 0 0.6em 0.6em;
- }
+/*
+All anchors inside the menu should be styled like this.
+*/
+#menu a {
+ color: #999;
+ border: none;
+ padding: 0.6em 0 0.6em 0.6em;
+}
- /*
- Remove all background/borders, since we are applying them to #menu.
- */
- #menu .pure-menu,
- #menu .pure-menu ul {
- border: none;
- background: transparent;
- }
+/*
+Remove all background/borders, since we are applying them to #menu.
+*/
+#menu .pure-menu,
+#menu .pure-menu ul {
+ border: none;
+ background: transparent;
+}
- /*
- Add that light border to separate items into groups.
- */
- #menu .pure-menu ul,
- #menu .pure-menu .menu-item-divided {
- border-top: 1px solid #333;
- }
- /*
- Change color of the anchor links on hover/focus.
- */
- #menu .pure-menu li a:hover,
- #menu .pure-menu li a:focus {
- background: #333;
- }
-
- /*
- This styles the selected menu item `<li>`.
- */
- #menu .pure-menu-selected,
- #menu .pure-menu-heading {
- background: #1f8dd6;
- }
- /*
- This styles a link within a selected menu item `<li>`.
- */
- #menu .pure-menu-selected {
- color: #fff;
- }
-
- /*
- This styles the menu heading.
- */
- #menu .pure-menu-heading {
- font-size: 110%;
- color: #fff;
- margin: 0;
- }
+/*
+Add that light border to separate items into groups.
+*/
+#menu .pure-menu ul,
+#menu .pure-menu .menu-item-divided {
+ border-top: 1px solid #333;
+}
+/*
+Change color of the anchor links on hover/focus.
+*/
+#menu .pure-menu li a:hover,
+#menu .pure-menu li a:focus {
+ background: #333;
+}
+
+/*
+This styles the selected menu item `<li>`.
+*/
+#menu .pure-menu-selected,
+#menu .pure-menu-heading {
+ background: #1f8dd6;
+}
+/*
+This styles a link within a selected menu item `<li>`.
+*/
+#menu .pure-menu-selected {
+ color: #fff;
+}
+
+/*
+This styles the menu heading.
+*/
+#menu .pure-menu-heading {
+ font-size: 110%;
+ color: #fff;
+ margin: 0;
+}
/* -- Dynamic Button For Responsive Menu -------------------------------------*/
@@ -189,34 +153,34 @@ small screens.
padding: 2.1em 1.6em;
}
- .menu-link:hover,
- .menu-link:focus {
- background: #000;
- }
+.menu-link:hover,
+.menu-link:focus {
+ background: #000;
+}
- .menu-link span {
- position: relative;
- display: block;
- }
+.menu-link span {
+ position: relative;
+ display: block;
+}
- .menu-link span,
- .menu-link span:before,
- .menu-link span:after {
- background-color: #fff;
- width: 100%;
- height: 0.2em;
- }
+.menu-link span,
+.menu-link span:before,
+.menu-link span:after {
+ background-color: #fff;
+ width: 100%;
+ height: 0.2em;
+}
- .menu-link span:before,
- .menu-link span:after {
- position: absolute;
- margin-top: -0.6em;
- content: " ";
- }
+.menu-link span:before,
+.menu-link span:after {
+ position: absolute;
+ margin-top: -0.6em;
+ content: " ";
+}
- .menu-link span:after {
- margin-top: 0.6em;
- }
+.menu-link span:after {
+ margin-top: 0.6em;
+}
/* -- Responsive Styles (Media Queries) ------------------------------------- */
@@ -253,55 +217,7 @@ Hides the menu at `48em`, but modify this based on your app's needs.
left: 250px;
}
}
-/* Custom Stuff */
-a:link {
- color: #479;
- text-decoration: none;
-}
-a:visited {
- color: #858;
- text-decoration: none;
-}
-a:hover {
- text-decoration: underline;
-}
-a:active {
- color: #000;
- text-decoration: underline;
-}
-code{
- color: #000;
-}
-.half-table{
- width: 100%;
-}
-.half-table td{
- width: 50%;
-}
-.half-table th{
- width: 50%;
-}
-.header-link{
- position: absolute;
- right: 0px;
-}
-*:hover > .header-link:hover{
- opacity: 1.0;
-}
-*:hover > .header-link:active{
- opacity: 0.75;
-}
-*:hover > .header-link{
- text-align: right;
- text-decoration: none;
- opacity: 0.5;
-}
-.header-link > i{
- color: #777;
-}
-.header-link{
- opacity: 0.05;
-}
+
#menu .collapsed .menu-item-list .hide ul li > a{
padding-top: 0px;
padding-bottom: 0px;
@@ -338,7 +254,34 @@ code{
top: 0px;
}
-/*Workaround for bug in highlight.js IDEA theme*/
-span.hljs-tag, span.hljs-symbol{
- background: none;
+
+.half-table{
+ width: 100%;
}
+.half-table td{
+ width: 50%;
+}
+.half-table th{
+ width: 50%;
+}
+
+
+/*
+This is the parent `<div>` that contains the menu and the content area.
+*/
+#layout {
+ position: relative;
+ padding-left: 0;
+}
+#layout.active {
+ position: relative;
+ left: 250px;
+}
+#layout.active #menu {
+ left: 250px;
+ width: 250px;
+}
+
+#layout.active .menu-link {
+ left: 250px;
+} \ No newline at end of file
diff --git a/book/src/main/scala/book/Book.scala b/book/src/main/scala/book/Book.scala
deleted file mode 100644
index 71c0d65..0000000
--- a/book/src/main/scala/book/Book.scala
+++ /dev/null
@@ -1,91 +0,0 @@
-package book
-import acyclic.file
-
-import scalatags.Text.tags2
-import scalatags.Text.all._
-
-/**
- * Created by haoyi on 10/26/14.
- */
-object Book {
- val autoResources = Set(
- "META-INF/resources/webjars/highlightjs/8.2-1/highlight.min.js",
- "META-INF/resources/webjars/highlightjs/8.2-1/styles/idea.min.css",
- "META-INF/resources/webjars/highlightjs/8.2-1/languages/scala.min.js",
- "META-INF/resources/webjars/highlightjs/8.2-1/languages/javascript.min.js",
- "META-INF/resources/webjars/highlightjs/8.2-1/languages/bash.min.js",
- "META-INF/resources/webjars/highlightjs/8.2-1/languages/diff.min.js",
- "META-INF/resources/webjars/highlightjs/8.2-1/languages/xml.min.js",
- "META-INF/resources/webjars/pure/0.5.0/pure-min.css",
- "META-INF/resources/webjars/pure/0.5.0/grids-responsive-min.css",
- "META-INF/resources/webjars/font-awesome/4.2.0/fonts/FontAwesome.otf",
- "META-INF/resources/webjars/font-awesome/4.2.0/fonts/fontawesome-webfont.eot",
- "META-INF/resources/webjars/font-awesome/4.2.0/fonts/fontawesome-webfont.svg",
- "META-INF/resources/webjars/font-awesome/4.2.0/fonts/fontawesome-webfont.ttf",
- "META-INF/resources/webjars/font-awesome/4.2.0/fonts/fontawesome-webfont.woff",
- "css/side-menu.css",
- "example-opt.js",
-// "example-opt.js.map",
- "webpage/weather.js",
- "favicon.svg",
- "favicon.png"
- )
-
- val fontAwesomeCss =
- "META-INF/resources/webjars/font-awesome/4.2.0/css/font-awesome.min.css"
-
- val manualResources = Set(
- "images/javascript-the-good-parts-the-definitive-guide.jpg",
- "images/Hello World.png",
- "images/Hello World White.png",
- "images/Hello World Console.png",
- "images/IntelliJ Hello.png",
- "images/Dropdown.png",
- "images/Scalatags Downloads.png",
- fontAwesomeCss
- )
-
-
- val txt = Index()
- val data = upickle.write(sect.structure)
- val googleAnalytics =
- """
- |(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- | })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
- |
- | ga('create', 'UA-27464920-4', 'auto');
- | ga('send', 'pageview');
- """.stripMargin
- val site = Seq(
- raw("<!doctype html>"),
- html(
- head(
- meta(charset:="utf-8"),
- meta(name:="viewport", content:="width=device-width, initial-scale=1.0"),
- link(rel:="shortcut icon", `type`:="image/png", href:="favicon.png"),
- link(rel:="stylesheet", href:=fontAwesomeCss),
- link(rel:="stylesheet", href:="styles.css"),
- tags2.title("Hands-on Scala.js"),
- script(src:="scripts.js"),
- script(raw(googleAnalytics))
- ),
- body(
- onload:=s"Controller().main($data)",
- div(id:="layout")(
- a(href:="#menu", id:="menuLink", cls:="menu-link")(
- span
- ),
- div(id:="menu")
-
- ),
- div(id:="main",
- div(id:="main-box")(
- txt
- )
- )
- )
- )
- ).render
-}
diff --git a/book/src/main/scala/book/BookData.scala b/book/src/main/scala/book/BookData.scala
index ff1f23a..8484f10 100644
--- a/book/src/main/scala/book/BookData.scala
+++ b/book/src/main/scala/book/BookData.scala
@@ -50,11 +50,22 @@ object BookData {
def half = div(cls:="pure-u-1 pure-u-md-1-2")
- val hl = new Highlighter(
- Seq(
+ val hl = new scalatex.site.Highlighter {
+ override val pathMappings = Seq(
s"$cloneRoot/scala-js" -> "https://github.com/scala-js/scala-js",
s"$cloneRoot/workbench-example-app" -> "https://github.com/lihaoyi/workbench-example-app",
"" -> "https://github.com/lihaoyi/hands-on-scala-js"
)
- )
+ override val suffixMappings = Map(
+ "scala" -> "scala",
+ "sbt" -> "scala",
+ "js" -> "javascript"
+ )
+ def scala(s: String) = this.highlight(s, "scala")
+ def bash(s: String) = this.highlight(s, "bash")
+ def html(s: String) = this.highlight(s, "html")
+ def xml(s: String) = this.highlight(s, "xml")
+ def diff(s: String) = this.highlight(s, "diff")
+ def javascript(s: String) = this.highlight(s, "javascript")
+ }
}
diff --git a/book/src/main/scala/book/Main.scala b/book/src/main/scala/book/Main.scala
index 4b862d0..90b0738 100644
--- a/book/src/main/scala/book/Main.scala
+++ b/book/src/main/scala/book/Main.scala
@@ -3,40 +3,80 @@ import acyclic.file
import java.io.InputStream
import java.nio.file.{Paths, Files}
+import scalatags.Text.{attrs, tags2, all}
+import scalatags.Text.all._
+import scalatex.site.Section.Tree
+import scalatex.site.Site
object Main {
- def write(txt: String, dest: String) = {
- Paths.get(dest).toFile.getParentFile.mkdirs()
- Files.deleteIfExists(Paths.get(dest))
- Files.write(Paths.get(dest), txt.getBytes)
- }
- def copy(src: InputStream, dest: String) = {
- Paths.get(dest).toFile.getParentFile.mkdirs()
- Files.deleteIfExists(Paths.get(dest))
- Files.copy(src, Paths.get(dest))
- }
-
def main(args: Array[String]): Unit = {
- println("Writing Book")
- val outputRoot = System.getProperty("output.root") + "/"
- write(Book.site, s"$outputRoot/index.html")
-
- val jsFiles = Book.autoResources.filter(_.endsWith(".js")).toSet
- val cssFiles = Book.autoResources.filter(_.endsWith(".css")).toSet
- val miscFiles = Book.autoResources -- cssFiles -- jsFiles
+ val googleAnalytics =
+ """
+ |(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ | })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ |
+ | ga('create', 'UA-27464920-4', 'auto');
+ | ga('send', 'pageview');
+ """.stripMargin
+
+ def data = upickle.write(sect.structure)
+
+ val s = new Site {
+ def content = Map("index.html" -> Index())
+
+ override def autoResources = super.autoResources | Set(
+ "META-INF/resources/webjars/pure/0.5.0/grids-responsive-min.css",
+ "css/side-menu.css",
+ "example-opt.js",
+ "webpage/weather.js",
+ "favicon.svg",
+ "favicon.png"
+ )
+ override def manualResources = super.manualResources | Set(
+ "images/javascript-the-good-parts-the-definitive-guide.jpg",
+ "images/Hello World.png",
+ "images/Hello World White.png",
+ "images/Hello World Console.png",
+ "images/IntelliJ Hello.png",
+ "images/Dropdown.png",
+ "images/Scalatags Downloads.png"
+ )
+ override def headFrags = super.headFrags ++ Seq(
+ meta(charset:="utf-8"),
+ meta(name:="viewport", attrs.content:="width=device-width, initial-scale=1.0"),
+ link(rel:="shortcut icon", `type`:="image/png", href:="favicon.png"),
+ tags2.title("Hands-on Scala.js"),
+ script(raw(googleAnalytics))
+ )
+ override def bodyFrag(frag: Frag) = body(
+
+ div(id:="layout")(
+ a(href:="#menu", id:="menuLink", cls:="menu-link")(
+ span
+ ),
+ div(id:="menu")
+
+ ),
+ div(
+ id:="main",
+ div(
+ id:="main-box",
+ cls:="scalatex-content",
+ maxWidth:="840px",
+ lineHeight:="1.6em",
+ frag
+ )
+ ),
+ onload:=s"Controller().main($data)"
+ )
- for(res <- Book.manualResources ++ miscFiles) {
- copy(getClass.getResourceAsStream("/" + res), outputRoot + res)
}
- for((resources, dest) <- Seq(jsFiles -> "scripts.js", cssFiles -> "styles.css")) {
- val blobs = for(res <- resources.iterator) yield {
- io.Source.fromInputStream(getClass.getResourceAsStream("/"+res)).mkString
- }
+ s.renderTo(System.getProperty("output.root") + "/")
- write(blobs.mkString("\n"), outputRoot + dest)
- }
val allNames = {
def rec(n: Tree[String]): Seq[String] = {
@@ -62,5 +102,4 @@ object Main {
// lnk.usedLinks
}
-
}
diff --git a/book/src/main/scala/book/Utils.scala b/book/src/main/scala/book/Utils.scala
index 2c861d0..c14a6ba 100644
--- a/book/src/main/scala/book/Utils.scala
+++ b/book/src/main/scala/book/Utils.scala
@@ -13,69 +13,21 @@ case class pureTable(header: Frag*){
)
}
}
-object sect{
-
+object sect extends scalatex.site.Section{
var indent = 0
- val headers = Seq[((String, String, Frag) => scalatags.Text.Tag, Option[Frag => Frag])](
- ((h, s, l) => div(cls:="header")(
- h1(h, l),
- h2(s)
- ), Some(f => div(cls:="content", f))),
- ((h, s, l) => div(cls:="header")(
- h1(id:=munge(h), h, l),
- br
- ), None),
- (h1(_, _, _), None),
- (h2(_, _, _), None),
- (h3(_, _, _), None),
- (h4(_, _, _), None),
- (h5(_, _, _), None),
- (h6(_, _, _), None)
+ override val headers: Seq[Header] = Seq(
+ Header(
+ (l, h, s) => div(cls:="header")(h1(h, l), br, h2(s)),
+ f => div(cls:="content", f)
+ ),
+ Header(
+ (l, h, s) => div(cls:="header")(h1(id:=munge(h), h, l), br)),
+ h1, h2, h3, h4, h5, h6
)
-
- var structure = Tree[String]("root", mutable.Buffer.empty)
-
- val usedRefs = mutable.Set.empty[String]
-
- def ref(s: String, txt: String = "") = {
- usedRefs += s
- a(if (txt == "") s else txt, href:=s"#${munge(s)}")
- }
-
- def munge(name: String) = {
- name.replace(" ", "")
- }
}
-case class sect(name: String, subname: String = ""){
- sect.indent += 1
- val newNode = Tree[String](name, mutable.Buffer.empty)
- val (headerWrap, contentWrap) = sect.headers(sect.indent-1)
- sect.structure.children.append(newNode)
- val prev = sect.structure
- sect.structure = newNode
- def apply(args: Frag*) = {
- val wrappedContents = contentWrap.getOrElse((x: Frag) => x)(args)
- val headingAnchor = a(
- cls:="header-link",
- href:=s"#${sect.munge(name)}",
- " ",
- i(cls:="fa fa-link")
- )
- val res = Seq[Frag](
- headerWrap(name, subname, headingAnchor)(
- cls:="content-subhead",
- id:=sect.munge(name)
- ),
- wrappedContents
- )
- sect.indent -= 1
- sect.structure = prev
- res
- }
-}
-case class Tree[T](value: T, children: mutable.Buffer[Tree[T]])
+
object lnk{
val usedLinks = mutable.Set.empty[String]
def apply(name: String, url: String) = {
@@ -122,87 +74,3 @@ object lnk{
val scalaPickling = lnk("scala-pickling", "https://github.com/scala/pickling")
}
}
-
-class Highlighter(mappings: Seq[(String, String)]){
- def highlight(snippet: Seq[String], lang: String) = {
- val string = snippet.mkString
- val lines = string.split("\n", -1)
- if (lines.length == 1){
- code(cls:=lang + " highlight-me", lines(0), padding:=0, display:="inline")
- }else{
- val minIndent = lines.map(_.takeWhile(_ == ' ').length)
- .filter(_ > 0)
- .min
- val stripped = lines.map(_.drop(minIndent))
- .dropWhile(_ == "")
- .mkString("\n")
-
- pre(code(cls:=lang + " highlight-me hljs", stripped))
- }
- }
-
- def javascript(code: String*) = highlight(code, "javascript")
- def scala(code: String*) = highlight(code, "scala")
- def bash(code: String*) = highlight(code, "bash")
- def diff(code: String*) = highlight(code, "diff")
- def html(code: String*) = highlight(code, "xml")
-
- def ref(filepath: String, start: String = "", end: String = "\n") = {
-
- val lang = filepath.split('.').last match {
- case "js" => "javascript"
- case "scala" => "scala"
- case "sbt" => "scala"
- case "sh" => "bash"
- case "html" => "xml"
- case x =>
- println("??? " + x)
- ???
- }
-
- val lines = io.Source.fromFile(filepath).getLines().toVector
-
- def indent(line: String) = line.takeWhile(_.isWhitespace).length
-
- val startLine = lines.indexWhere(_.contains(start))
- if (startLine == -1){
- throw new Exception("Can't find marker: " + start)
- }
- val whitespace = indent(lines(startLine))
- val endLine = lines.indexWhere(
- line => line.contains(end) || (indent(line) < whitespace && line.trim != ""),
- startLine + 1
- )
- val sliced =
- if (endLine == -1) lines.drop(startLine)
- else lines.slice(startLine, endLine)
-
- val blob = sliced.map(_.drop(whitespace)).mkString("\n")
-
- val (prefix, url) =
- mappings.iterator
- .find{case (prefix, path) => filepath.startsWith(prefix)}
- .get
-
- val hash =
- if (endLine == -1) ""
- else s"#L$startLine-L$endLine"
-
- val linkUrl =
- s"$url/tree/master/${filepath.drop(prefix.length)}$hash"
- pre(
- code(cls:=lang + " highlight-me hljs", blob),
- a(
- cls:="header-link",
- i(cls:="fa fa-link "),
- position.absolute,
- right:="0.5em",
- bottom:="0.5em",
- display.block,
- fontSize:="24px",
- href:=linkUrl,
- target:="_blank"
- )
- )
- }
-} \ No newline at end of file
diff --git a/book/src/main/scalatex/book/Index.scalatex b/book/src/main/scalatex/book/Index.scalatex
index 7a7e2b8..bf33d19 100644
--- a/book/src/main/scalatex/book/Index.scalatex
+++ b/book/src/main/scalatex/book/Index.scalatex
@@ -1,11 +1,11 @@
@import BookData._
-@val firstHalfDescription = """
-is a set of tutorials that walks you through getting started with Scala.js. You'll build a range of small projects, from Making a Canvas App to Interactive Web Pages to Integrating Client-Server, and in the process will get a good overview of both Scala.js's use cases as well as the development experience
-"""
-@val secondHalfDescription = """
+@val firstHalfDescription = Seq[Frag]("""
+is a set of tutorials that walks you through getting started with Scala.js. You'll build a range of small projects, from """, sect.ref("Making a Canvas App"), " to ", sect.ref("Interactive Web Pages"), " to ", sect.ref("Integrating Client-Server"), """, and in the process will get a good overview of both Scala.js's use cases as well as the development experience
+""")
+@val secondHalfDescription = Seq("""
is a set of detailed expositions on various parts of the Scala.js platform. Nothing in here is necessary for you to make your first demos, but as you dig deeper into the platform, you will likely need or want to care about these things so you can properly understand what's going on "under the hood"
-"""
+""")
@sect("Hands-on Scala.js", "Writing client-side web applications in Scala")
@split
@more
@@ -80,4 +80,4 @@ is a set of detailed expositions on various parts of the Scala.js platform. Noth
@indepth.DesignSpace()
@sect{Java APIs}
- @indepth.JavaAPIs() \ No newline at end of file
+ @indepth.JavaAPIs()
diff --git a/book/src/main/scalatex/book/Intro.scalatex b/book/src/main/scalatex/book/Intro.scalatex
index 5438cfb..a504aa6 100644
--- a/book/src/main/scalatex/book/Intro.scalatex
+++ b/book/src/main/scalatex/book/Intro.scalatex
@@ -5,7 +5,7 @@
@split
@half
@hl.scala
- object Example extends js.JSApp{
+ object Main extends js.JSApp{
def main() = {
var x = 0
while(x < 10) x += 3
@@ -16,12 +16,13 @@
@half
@hl.javascript
- ScalaJS.c.LExample$.prototype.main__V = (function() {
+ ScalaJS.c.LMain$.prototype.main__V = (function() {
var x = 0;
while ((x < 10)) {
x = ((x + 3) | 0)
};
- ScalaJS.m.s_Predef().println__O__V(x)
+ ScalaJS.m.s_Predef()
+ .println__O__V(x)
// 12
});
@@ -67,7 +68,7 @@
@p
To work in Javascript, you need the discipline to limit yourself to the sane subset of the language, avoiding all the pitfalls along the way:
- @img(src:="images/javascript-the-good-parts-the-definitive-guide.jpg")
+ @img(src:="images/javascript-the-good-parts-the-definitive-guide.jpg", margin.auto, display.block)
@p
Even if you manage to do so, what constitutes a pitfall and what constitutes a clever-language-feature changes yearly, making it difficult to maintain cohesiveness over time. This is compounded by the fact that refactoring is difficult, and so removing "unwanted" patterns from a large code-base a difficult (often multi-year) process.
diff --git a/build.sbt b/build.sbt
index 43d679c..dde5431 100644
--- a/build.sbt
+++ b/build.sbt
@@ -4,7 +4,7 @@ import org.eclipse.jgit.api.Git
import org.eclipse.jgit.merge.MergeStrategy
import org.eclipse.jgit.transport.{UsernamePasswordCredentialsProvider, RefSpec}
-import scala.scalajs.sbtplugin.ScalaJSPlugin._
+import scalajs.sbtplugin.ScalaJSPlugin._
import ScalaJSKeys._
val cloneRepos = taskKey[Unit]("Clone stuff from github")
@@ -20,13 +20,11 @@ val sharedSettings = Seq(
lazy val book = Project(
id = "book",
base = file("book")
-).settings(sharedSettings ++ inConfig(Compile)(scalatex.SbtPlugin.settings):_*).settings(
+).settings(sharedSettings ++ scalatex.SbtPlugin.projectSettings:_*).settings(
libraryDependencies ++= Seq(
- "org.webjars" % "highlightjs" % "8.2-1",
- "org.webjars" % "pure" % "0.5.0",
- "org.webjars" % "font-awesome" % "4.2.0",
"com.scalatags" %% "scalatags" % "0.4.2",
- "com.lihaoyi" %%% "upickle" % "0.2.5"
+ "com.lihaoyi" %%% "upickle" % "0.2.5",
+ "com.lihaoyi" %% "scalatex-site" % "0.1.0"
),
(resources in Compile) += {
(fullOptJS in (demos, Compile)).value
diff --git a/examples/crossBuilds/clientserver/build.sbt b/examples/crossBuilds/clientserver/build.sbt
index 3bba3af..048df8a 100644
--- a/examples/crossBuilds/clientserver/build.sbt
+++ b/examples/crossBuilds/clientserver/build.sbt
@@ -1,6 +1,6 @@
import NativePackagerKeys._
import utest.jsrunner.JsCrossBuild
-import scala.scalajs.sbtplugin.ScalaJSPlugin._
+import scalajs.sbtplugin.ScalaJSPlugin._
import ScalaJSKeys._
val sharedSettings = Seq(
unmanagedSourceDirectories in Compile +=
diff --git a/examples/crossBuilds/clientserver/client/src/main/scala/simple/Client.scala b/examples/crossBuilds/clientserver/client/src/main/scala/simple/Client.scala
index adefe01..9b3eda1 100644
--- a/examples/crossBuilds/clientserver/client/src/main/scala/simple/Client.scala
+++ b/examples/crossBuilds/clientserver/client/src/main/scala/simple/Client.scala
@@ -1,10 +1,10 @@
package simple
import scalatags.JsDom.all._
-import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow
+import scalajs.concurrent.JSExecutionContext.Implicits.runNow
import org.scalajs.dom
import dom.extensions.Ajax
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
@JSExport
object Client extends{
diff --git a/examples/crossBuilds/clientserver2/build.sbt b/examples/crossBuilds/clientserver2/build.sbt
index c64a6fd..4c5045f 100644
--- a/examples/crossBuilds/clientserver2/build.sbt
+++ b/examples/crossBuilds/clientserver2/build.sbt
@@ -1,5 +1,5 @@
import utest.jsrunner.JsCrossBuild
-import scala.scalajs.sbtplugin.ScalaJSPlugin._
+import scalajs.sbtplugin.ScalaJSPlugin._
import ScalaJSKeys._
val sharedSettings = Seq(
unmanagedSourceDirectories in Compile +=
diff --git a/examples/crossBuilds/clientserver2/client/src/main/scala/simple/Client.scala b/examples/crossBuilds/clientserver2/client/src/main/scala/simple/Client.scala
index 026e52d..5aefb70 100644
--- a/examples/crossBuilds/clientserver2/client/src/main/scala/simple/Client.scala
+++ b/examples/crossBuilds/clientserver2/client/src/main/scala/simple/Client.scala
@@ -1,7 +1,7 @@
package simple
import scalatags.JsDom.all._
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
import scalajs.concurrent.JSExecutionContext.Implicits.runNow
import autowire._
diff --git a/examples/crossBuilds/clientserver2/server/src/main/scala/simple/Server.scala b/examples/crossBuilds/clientserver2/server/src/main/scala/simple/Server.scala
index df5f877..8967c17 100644
--- a/examples/crossBuilds/clientserver2/server/src/main/scala/simple/Server.scala
+++ b/examples/crossBuilds/clientserver2/server/src/main/scala/simple/Server.scala
@@ -30,7 +30,10 @@ object Server extends SimpleRoutingApp with Api{
extract(_.request.entity.asString) { e =>
complete {
Router.route[Api](Server)(
- autowire.Core.Request(s, upickle.read[Map[String, String]](e))
+ autowire.Core.Request(
+ s,
+ upickle.read[Map[String, String]](e)
+ )
)
}
}
diff --git a/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala b/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
index 35ebe1d..d726ec1 100644
--- a/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
+++ b/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
@@ -1,6 +1,6 @@
//js/src/main/scala/simple/Platform.scala
package simple
-import scala.scalajs.js
+import scalajs.js
object Platform extends js.JSApp{
def format(ts: Long) = {
diff --git a/examples/crossBuilds/simple2/js/src/main/scala/simple/Platform.scala b/examples/crossBuilds/simple2/js/src/main/scala/simple/Platform.scala
index 42cc7dc..d4a9554 100644
--- a/examples/crossBuilds/simple2/js/src/main/scala/simple/Platform.scala
+++ b/examples/crossBuilds/simple2/js/src/main/scala/simple/Platform.scala
@@ -1,6 +1,6 @@
//js/src/main/scala/simple/Platform.scala
package simple
-import scala.scalajs.js
+import scalajs.js
object Platform{
def format(ts: Long) = {
diff --git a/examples/demos/build.sbt b/examples/demos/build.sbt
index aa801b0..0db3dec 100644
--- a/examples/demos/build.sbt
+++ b/examples/demos/build.sbt
@@ -1,4 +1,4 @@
-import scala.scalajs.sbtplugin.ScalaJSPlugin.ScalaJSKeys._
+import scalajs.sbtplugin.ScalaJSPlugin.ScalaJSKeys._
(emitSourceMaps in fullOptJS) := false
diff --git a/examples/demos/src/main/scala/Splash.scala b/examples/demos/src/main/scala/Splash.scala
index c68bdca..05cbbc2 100644
--- a/examples/demos/src/main/scala/Splash.scala
+++ b/examples/demos/src/main/scala/Splash.scala
@@ -2,7 +2,7 @@ import java.lang.Math._
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
@JSExport
object Splash extends{
@@ -15,7 +15,7 @@ object Splash extends{
}
clear()
- val renderer =
+ val brush =
canvas.getContext("2d")
.asInstanceOf[dom.CanvasRenderingContext2D]
@@ -26,18 +26,17 @@ object Splash extends{
type Graph = (String, Double => Double)
val graphs = Seq[Graph](
("red", sin),
- ("green", x => 1 - abs(x % 4 - 2)),
- ("blue", x => pow(sin(x/12), 2) * sin(x))
+ ("green", x => abs(x % 4 - 2) - 1),
+ ("blue", x => sin(x/12) * sin(x))
).zipWithIndex
dom.setInterval(() => {
x = (x + 1) % w; if (x == 0) clear()
for (((color, f), i) <- graphs) {
val offset = h / 3 * (i + 0.5)
val y = f(x / w * 75) * h / 30
- renderer.fillStyle = color
- renderer.fillRect(x, y + offset, 3, 3)
+ brush.fillStyle = color
+ brush.fillRect(x, y + offset, 3, 3)
}
}, 20)
-
}
} \ No newline at end of file
diff --git a/examples/demos/src/main/scala/advanced/Async.scala b/examples/demos/src/main/scala/advanced/Async.scala
index c4d7366..a76b78b 100644
--- a/examples/demos/src/main/scala/advanced/Async.scala
+++ b/examples/demos/src/main/scala/advanced/Async.scala
@@ -3,7 +3,7 @@ package advanced
import org.scalajs.dom
import concurrent._
import async.Async._
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
import scalajs.concurrent.JSExecutionContext.Implicits.queue
@JSExport
diff --git a/examples/demos/src/main/scala/advanced/BasicRx.scala b/examples/demos/src/main/scala/advanced/BasicRx.scala
index 56b41b0..1c9a0c8 100644
--- a/examples/demos/src/main/scala/advanced/BasicRx.scala
+++ b/examples/demos/src/main/scala/advanced/BasicRx.scala
@@ -1,8 +1,8 @@
package advanced
import org.scalajs.dom
-import scala.scalajs.js
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js
+import scalajs.js.annotation.JSExport
import rx._
import scalatags.JsDom.all._
diff --git a/examples/demos/src/main/scala/advanced/Futures.scala b/examples/demos/src/main/scala/advanced/Futures.scala
index 0d7107d..d1142b9 100644
--- a/examples/demos/src/main/scala/advanced/Futures.scala
+++ b/examples/demos/src/main/scala/advanced/Futures.scala
@@ -5,10 +5,10 @@ import org.scalajs.dom.XMLHttpRequest
import org.scalajs.dom.extensions.{Ajax, KeyCode}
import scala.collection.mutable
import scala.concurrent.Future
-import scala.scalajs.js
+import scalajs.js
import scalatags.JsDom.all._
-import scala.scalajs.js.annotation.JSExport
-import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow
+import scalajs.js.annotation.JSExport
+import scalajs.concurrent.JSExecutionContext.Implicits.runNow
@JSExport
object Futures {
def main(container: dom.HTMLDivElement,
diff --git a/examples/demos/src/main/scala/canvasapp/Clock.scala b/examples/demos/src/main/scala/canvasapp/Clock.scala
index af9d8aa..793b84c 100644
--- a/examples/demos/src/main/scala/canvasapp/Clock.scala
+++ b/examples/demos/src/main/scala/canvasapp/Clock.scala
@@ -3,8 +3,8 @@ package canvasapp
import org.scalajs.dom
-import scala.scalajs.js
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js
+import scalajs.js.annotation.JSExport
@JSExport
object Clock extends{
@JSExport
diff --git a/examples/demos/src/main/scala/canvasapp/FlappyLine.scala b/examples/demos/src/main/scala/canvasapp/FlappyLine.scala
index fdf6e60..af797f8 100644
--- a/examples/demos/src/main/scala/canvasapp/FlappyLine.scala
+++ b/examples/demos/src/main/scala/canvasapp/FlappyLine.scala
@@ -3,7 +3,7 @@ package canvasapp
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
import scala.util.Random
@JSExport
diff --git a/examples/demos/src/main/scala/canvasapp/ScratchPad.scala b/examples/demos/src/main/scala/canvasapp/ScratchPad.scala
index cc3d7e0..65e873c 100644
--- a/examples/demos/src/main/scala/canvasapp/ScratchPad.scala
+++ b/examples/demos/src/main/scala/canvasapp/ScratchPad.scala
@@ -3,7 +3,7 @@ package canvasapp
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
@JSExport
object ScratchPad extends{
@@ -22,19 +22,21 @@ object ScratchPad extends{
/*code*/
renderer.fillStyle = "black"
var down = false
- canvas.onmousedown = (e: dom.MouseEvent)=>{
- down = true
- }
- canvas.onmouseup = (e: dom.MouseEvent)=>{
- down = false
- }
- canvas.onmousemove = (e: dom.MouseEvent)=>{
- val rect = canvas.getBoundingClientRect()
- if (down) renderer.fillRect(
- e.clientX - rect.left,
- e.clientY - rect.top,
- 10, 10
- )
+ canvas.onmousedown =
+ (e: dom.MouseEvent) => down = true
+
+ canvas.onmouseup =
+ (e: dom.MouseEvent) => down = false
+
+ canvas.onmousemove = {
+ (e: dom.MouseEvent) =>
+ val rect =
+ canvas.getBoundingClientRect()
+ if (down) renderer.fillRect(
+ e.clientX - rect.left,
+ e.clientY - rect.top,
+ 10, 10
+ )
}
}
} \ No newline at end of file
diff --git a/examples/demos/src/main/scala/scrollmenu/Controller.scala b/examples/demos/src/main/scala/scrollmenu/Controller.scala
index fe35be8..b56da31 100644
--- a/examples/demos/src/main/scala/scrollmenu/Controller.scala
+++ b/examples/demos/src/main/scala/scrollmenu/Controller.scala
@@ -3,8 +3,8 @@ package scrollmenu
import org.scalajs.dom
import org.scalajs.dom.extensions._
-import scala.scalajs.js
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
diff --git a/examples/demos/src/main/scala/scrollmenu/ScrollSpy.scala b/examples/demos/src/main/scala/scrollmenu/ScrollSpy.scala
index 736f9b3..f0b9dd4 100644
--- a/examples/demos/src/main/scala/scrollmenu/ScrollSpy.scala
+++ b/examples/demos/src/main/scala/scrollmenu/ScrollSpy.scala
@@ -2,7 +2,7 @@ package scrollmenu
import org.scalajs.dom
import org.scalajs.dom.extensions._
-import scala.scalajs.js
+import scalajs.js
import scalatags.JsDom.all._
case class Tree[T](value: T, children: Vector[Tree[T]])
diff --git a/examples/demos/src/main/scala/webpage/HelloWorld0.scala b/examples/demos/src/main/scala/webpage/HelloWorld0.scala
index df458ac..4ec7d30 100644
--- a/examples/demos/src/main/scala/webpage/HelloWorld0.scala
+++ b/examples/demos/src/main/scala/webpage/HelloWorld0.scala
@@ -1,17 +1,17 @@
package webpage
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
@JSExport
object HelloWorld0 extends{
@JSExport
- def main(target: dom.HTMLDivElement) = {
- val (animalA, animalB) = ("fox", "dog")
+ def main(target: dom.HTMLDivElement) ={
+ val (f, d) = ("fox", "dog")
target.innerHTML = s"""
<div>
<h1>Hello World!</h1>
<p>
- The quick brown <b>$animalA</b>
- jumped over the lazy <i>$animalB</b>
+ The quick brown <b>$f</b>
+ jumps over the lazy <i>$d</b>
</p>
</div>
"""
diff --git a/examples/demos/src/main/scala/webpage/HelloWorld1.scala b/examples/demos/src/main/scala/webpage/HelloWorld1.scala
index 1dc77b3..f897c98 100644
--- a/examples/demos/src/main/scala/webpage/HelloWorld1.scala
+++ b/examples/demos/src/main/scala/webpage/HelloWorld1.scala
@@ -1,6 +1,6 @@
package webpage
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
object HelloWorld1 extends{
@@ -10,8 +10,11 @@ object HelloWorld1 extends{
target.appendChild(
div(
h1("Hello World!"),
- p("The quick brown ", b(animalA),
- " jumped over the lazy ", i(animalB), ".")
+ p(
+ "The quick brown ", b(animalA),
+ " jumps over the lazy ",
+ i(animalB), "."
+ )
).render
)
}
diff --git a/examples/demos/src/main/scala/webpage/Inputs.scala b/examples/demos/src/main/scala/webpage/Inputs.scala
index 9339e84..0354d6d 100644
--- a/examples/demos/src/main/scala/webpage/Inputs.scala
+++ b/examples/demos/src/main/scala/webpage/Inputs.scala
@@ -1,7 +1,7 @@
package webpage
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
diff --git a/examples/demos/src/main/scala/webpage/Search0.scala b/examples/demos/src/main/scala/webpage/Search0.scala
index 300b506..d44dc34 100644
--- a/examples/demos/src/main/scala/webpage/Search0.scala
+++ b/examples/demos/src/main/scala/webpage/Search0.scala
@@ -1,7 +1,7 @@
package webpage
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
diff --git a/examples/demos/src/main/scala/webpage/Search1.scala b/examples/demos/src/main/scala/webpage/Search1.scala
index 1936898..9a37ca9 100644
--- a/examples/demos/src/main/scala/webpage/Search1.scala
+++ b/examples/demos/src/main/scala/webpage/Search1.scala
@@ -1,7 +1,7 @@
package webpage
import org.scalajs.dom
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
diff --git a/examples/demos/src/main/scala/webpage/Weather0.scala b/examples/demos/src/main/scala/webpage/Weather0.scala
index 4a2c6f0..2bf4666 100644
--- a/examples/demos/src/main/scala/webpage/Weather0.scala
+++ b/examples/demos/src/main/scala/webpage/Weather0.scala
@@ -2,8 +2,8 @@ package webpage
import org.scalajs.dom
import org.scalajs.dom.{Node, Element}
-import scala.scalajs.js
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
diff --git a/examples/demos/src/main/scala/webpage/Weather1.scala b/examples/demos/src/main/scala/webpage/Weather1.scala
index c509cb5..1d61678 100644
--- a/examples/demos/src/main/scala/webpage/Weather1.scala
+++ b/examples/demos/src/main/scala/webpage/Weather1.scala
@@ -2,8 +2,8 @@ package webpage
import org.scalajs.dom
import org.scalajs.dom.{Node, Element}
-import scala.scalajs.js
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
diff --git a/examples/demos/src/main/scala/webpage/Weather2.scala b/examples/demos/src/main/scala/webpage/Weather2.scala
index aa04059..bf908e3 100644
--- a/examples/demos/src/main/scala/webpage/Weather2.scala
+++ b/examples/demos/src/main/scala/webpage/Weather2.scala
@@ -2,8 +2,8 @@ package webpage
import org.scalajs.dom
import org.scalajs.dom.{Node, Element}
-import scala.scalajs.js
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
diff --git a/examples/demos/src/main/scala/webpage/Weather3.scala b/examples/demos/src/main/scala/webpage/Weather3.scala
index 4dadf94..3a7a2ac 100644
--- a/examples/demos/src/main/scala/webpage/Weather3.scala
+++ b/examples/demos/src/main/scala/webpage/Weather3.scala
@@ -2,8 +2,8 @@ package webpage
import org.scalajs.dom
import org.scalajs.dom.{Node, Element}
-import scala.scalajs.js
-import scala.scalajs.js.annotation.JSExport
+import scalajs.js
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
diff --git a/examples/demos/src/main/scala/webpage/WeatherSearch.scala b/examples/demos/src/main/scala/webpage/WeatherSearch.scala
index 0c8acc9..de8d1e2 100644
--- a/examples/demos/src/main/scala/webpage/WeatherSearch.scala
+++ b/examples/demos/src/main/scala/webpage/WeatherSearch.scala
@@ -2,9 +2,9 @@ package webpage
import org.scalajs.dom
import dom.extensions._
-import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow
-import scala.scalajs.js
-import scala.scalajs.js.annotation.JSExport
+import scalajs.concurrent.JSExecutionContext.Implicits.runNow
+import scalajs.js
+import scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
diff --git a/scalatex/api/src/main/scala/scalatex/package.scala b/scalatex/api/src/main/scala/scalatex/package.scala
deleted file mode 100644
index 1f13e63..0000000
--- a/scalatex/api/src/main/scala/scalatex/package.scala
+++ /dev/null
@@ -1,98 +0,0 @@
-import scala.reflect.internal.util.{BatchSourceFile, SourceFile, OffsetPosition}
-import scala.reflect.io.{PlainFile, AbstractFile}
-import scala.reflect.macros.{TypecheckException, Context}
-import scalatags.Text.all._
-import scalatex.stages.{Parser, Compiler}
-import scala.language.experimental.macros
-import acyclic.file
-
-package object scalatex {
- /**
- * Wraps the given string as a twist fragment.
- */
- def tw(expr: String): Frag = macro Internals.applyMacro
- def twf(filename: String): Frag = macro Internals.applyMacroFile
- object Internals {
-
- def twRuntimeErrors(expr: String): Frag = macro applyMacroRuntimeErrors
- def twDebug(expr: String): Frag = macro applyMacroDebug
-
- def applyMacro(c: Context)(expr: c.Expr[String]): c.Expr[Frag] = applyMacroFull(c)(expr, false, false)
- def applyMacroDebug(c: Context)(expr: c.Expr[String]): c.Expr[Frag] = applyMacroFull(c)(expr, false, true)
-
- def applyMacroRuntimeErrors(c: Context)(expr: c.Expr[String]): c.Expr[Frag] = applyMacroFull(c)(expr, true, false)
-
- def applyMacroFile(c: Context)(filename: c.Expr[String]): c.Expr[Frag] = {
- import c.universe._
- val fileName = filename.tree
- .asInstanceOf[Literal]
- .value
- .value
- .asInstanceOf[String]
- val txt = io.Source.fromFile(fileName).mkString
- val sourceFile = new BatchSourceFile(
- new PlainFile(fileName),
- txt.toCharArray
- )
-
- compileThing(c)(txt, sourceFile, 0, false, false)
- }
-
- case class DebugFailure(msg: String, pos: String) extends Exception(msg)
-
- private[this] def applyMacroFull(c: Context)
- (expr: c.Expr[String],
- runtimeErrors: Boolean,
- debug: Boolean)
- : c.Expr[Frag] = {
- import c.universe._
- val scalatexFragment = expr.tree
- .asInstanceOf[Literal]
- .value
- .value
- .asInstanceOf[String]
- val stringStart =
- expr.tree
- .pos
- .lineContent
- .drop(expr.tree.pos.column)
- .take(2)
- compileThing(c)(
- scalatexFragment,
- expr.tree.pos.source,
- expr.tree.pos.point + (if (stringStart == "\"\"") 1 else -1),
- runtimeErrors,
- debug
- )
- }
- }
-
- def compileThing(c: Context)
- (scalatexSource: String,
- source: SourceFile,
- point: Int,
- runtimeErrors: Boolean,
- debug: Boolean) = {
- import c.universe._
- def compile(s: String): c.Tree = {
- val realPos = new OffsetPosition(source, point).asInstanceOf[c.universe.Position]
-
- Compiler(c)(realPos, Parser.tupled(stages.Trim(s)))
- }
-
-
- import c.Position
- try {
- val compiled = compile(scalatexSource)
- if (debug) println(compiled)
- c.Expr[Frag](c.typeCheck(compiled))
- } catch {
- case e@TypecheckException(pos: Position, msg) =>
- if (!runtimeErrors) c.abort(pos, msg)
- else {
- val posMsg = pos.lineContent + "\n" + (" " * pos.column) + "^"
- c.Expr( q"""throw scalatex.Internals.DebugFailure($msg, $posMsg)""")
- }
- }
- }
-}
diff --git a/scalatex/api/src/main/scala/scalatex/stages/Compiler.scala b/scalatex/api/src/main/scala/scalatex/stages/Compiler.scala
deleted file mode 100644
index 3df8da7..0000000
--- a/scalatex/api/src/main/scala/scalatex/stages/Compiler.scala
+++ /dev/null
@@ -1,103 +0,0 @@
-package scalatex
-package stages
-
-import acyclic.file
-
-import scala.reflect.macros.whitebox.Context
-import scala.reflect.internal.util.{Position, OffsetPosition}
-
-/**
- * Walks the parsed AST, converting it into a structured Scala c.Tree
- */
-object Compiler{
-
- def apply(c: Context)(fragPos: c.Position, template: Ast.Block): c.Tree = {
-
- import c.universe._
- def fragType = tq"scalatags.Text.all.Frag"
-
- def incPosRec(trees: c.Tree, offset: Int): trees.type = {
-
- trees.foreach(incPos(_, offset))
- trees
- }
- def incPos(tree: c.Tree, offset: Int): tree.type = {
-
- val current = if (tree.pos == NoPosition) 0 else tree.pos.point
- c.internal.setPos(tree,
- new OffsetPosition(
- fragPos.source,
- offset + current + fragPos.point
- ).asInstanceOf[c.universe.Position]
- )
- tree
- }
-
- def compileChain(code: String, parts: Seq[Ast.Chain.Sub], offset: Int): c.Tree = {
-
- val out = parts.foldLeft(incPosRec(c.parse(code), offset + 1)){
- case (curr, Ast.Chain.Prop(str, offset2)) =>
- incPos(q"$curr.${TermName(str)}", offset2 + 1)
- case (curr, Ast.Chain.Args(str, offset2)) =>
- val Apply(fun, args) = c.parse(s"omg$str")
- incPos(Apply(curr, args.map(incPosRec(_, offset2 - 2))), offset2)
- case (curr, Ast.Chain.TypeArgs(str, offset2)) =>
- val TypeApply(fun, args) = c.parse(s"omg$str")
- incPos(TypeApply(curr, args.map(incPosRec(_, offset2 - 2))), offset2)
- case (curr, Ast.Block(parts, offset1)) =>
- incPos(q"$curr(..${compileBlock(parts, offset1)})", offset1)
- case (curr, Ast.Header(header, block, offset1)) =>
- incPos(q"$curr(${compileHeader(header, block, offset1)})", offset1)
- }
-
- out
- }
- def compileBlock(parts: Seq[Ast.Block.Sub], offset: Int): Seq[c.Tree] = {
- val res = parts.map{
- case Ast.Block.Text(str, offset1) =>
- incPos(q"$str", offset1)
- case Ast.Chain(code, parts, offset1) =>
- compileChain(code, parts, offset1)
- case Ast.Header(header, block, offset1) =>
- compileHeader(header, block, offset1)
- case Ast.Block.IfElse(condString, Ast.Block(parts2, offset2), elseBlock, offset1) =>
- val If(cond, _, _) = c.parse(condString + "{}")
- val elseCompiled = elseBlock match{
- case Some(Ast.Block(parts3, offset3)) => compileBlockWrapped(parts3, offset3)
- case None => EmptyTree
- }
-
- val res = If(incPosRec(cond, offset1 + 2), compileBlockWrapped(parts2, offset2), elseCompiled)
-
- incPos(res, offset1)
- res
- case Ast.Block.For(generators, Ast.Block(parts2, offset2), offset1) =>
- val fresh = c.fresh()
-
- val tree = incPosRec(c.parse(s"$generators yield $fresh"), offset1 + 2)
-
- def rec(t: Tree): Tree = t match {
- case a @ Apply(fun, List(f @ Function(vparams, body))) =>
- val f2 = Function(vparams, rec(body))
- val a2 = Apply(fun, List(f2))
- a2
- case Ident(x: TermName) if x.decoded == fresh =>
- compileBlockWrapped(parts2, offset2)
- }
-
- rec(tree)
- }
- res
- }
- def compileBlockWrapped(parts: Seq[Ast.Block.Sub], offset: Int): c.Tree = {
- incPos(q"Seq[$fragType](..${compileBlock(parts, offset)})", offset)
- }
- def compileHeader(header: String, block: Ast.Block, offset: Int): c.Tree = {
- val Block(stmts, expr) = c.parse(s"{$header\n ()}")
- Block(stmts, compileBlockWrapped(block.parts, block.offset))
- }
-
- val res = compileBlockWrapped(template.parts, template.offset)
- res
- }
-} \ No newline at end of file
diff --git a/scalatex/api/src/main/scala/scalatex/stages/Omg/scala.scala b/scalatex/api/src/main/scala/scalatex/stages/Omg/scala.scala
deleted file mode 100644
index 81fa1f9..0000000
--- a/scalatex/api/src/main/scala/scalatex/stages/Omg/scala.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-package scalatex.stages.Omg
-
-/**
- * Created by haoyi on 12/3/14.
- */
-class scala {
-
-}
diff --git a/scalatex/api/src/main/scala/scalatex/stages/Parser.scala b/scalatex/api/src/main/scala/scalatex/stages/Parser.scala
deleted file mode 100644
index 0b87d97..0000000
--- a/scalatex/api/src/main/scala/scalatex/stages/Parser.scala
+++ /dev/null
@@ -1,170 +0,0 @@
-package scalatex
-package stages
-import acyclic.file
-import org.parboiled2._
-import scalaParser.ScalaSyntax
-
-/**
- * Parses the input text into a roughly-structured AST. This AST
- * is much simpler than the real Scala AST, but serves us well
- * enough until we stuff the code-strings into the real Scala
- * parser later
- */
-object Parser extends ((String, Int) => Ast.Block){
- def apply(input: String, offset: Int = 0): Ast.Block = {
- new Parser(input, offset).Body.run().get
- }
-}
-class Parser(input: ParserInput, indent: Int = 0, offset: Int = 0) extends scalaParser.ScalaSyntax(input) {
- def offsetCursor = offset + cursor
- val txt = input.sliceString(0, input.length)
- val indentTable = txt.split('\n').map{ s =>
- if (s.trim == "") -1
- else s.takeWhile(_ == ' ').length
- }
- val nextIndentTable = (0 until indentTable.length).map { i =>
- val index = indentTable.indexWhere(_ != -1, i + 1)
- if (index == -1) 100000
- else indentTable(index)
- }
- def cursorNextIndent() = {
- nextIndentTable(txt.take(cursor).count(_ == '\n'))
- }
-
- def TextNot(chars: String) = rule {
- push(offsetCursor) ~ capture(oneOrMore(noneOf(chars + "\n") | "@@")) ~> {
- (i, x) => Ast.Block.Text(x.replace("@@", "@"), i)
- }
- }
- def Text = TextNot("@")
- def Code = rule {
- "@" ~ capture(Identifiers.Id | BlockExpr2 | ('(' ~ optional(Exprs) ~ ')'))
- }
- def Header = rule {
- "@" ~ capture(Def | Import)
- }
-
- def HeaderBlock: Rule1[Ast.Header] = rule{
- Header ~ zeroOrMore(capture(WL) ~ Header ~> (_ + _)) ~ runSubParser{new Parser(_, indent, cursor).Body0} ~> {
- (start: String, heads: Seq[String], body: Ast.Block) => Ast.Header(start + heads.mkString, body)
- }
- }
-
- def BlankLine = rule{ '\n' ~ zeroOrMore(' ') ~ &('\n') }
- def IndentSpaces = rule{ indent.times(' ') ~ zeroOrMore(' ') }
- def Indent = rule{ '\n' ~ IndentSpaces }
- def LoneScalaChain: Rule2[Ast.Block.Text, Ast.Chain] = rule {
- (push(offsetCursor) ~ capture(Indent) ~> ((i, x) => Ast.Block.Text(x, i))) ~
- ScalaChain ~
- IndentBlock ~> {
- (chain: Ast.Chain, body: Ast.Block) => chain.copy(parts = chain.parts :+ body)
- }
- }
- def IndentBlock = rule{
- &("\n") ~
- test(cursorNextIndent() > indent) ~
- runSubParser(new Parser(_, cursorNextIndent(), cursor).Body)
- }
- def IfHead = rule{ "@" ~ capture("if" ~ "(" ~ Expr ~ ")") }
- def IfElse1 = rule{
- push(offsetCursor) ~ IfHead ~ BraceBlock ~ optional("else" ~ (BraceBlock | IndentBlock))
- }
- def IfElse2 = rule{
- Indent ~ push(offsetCursor) ~ IfHead ~ IndentBlock ~ optional(Indent ~ "@else" ~ (BraceBlock | IndentBlock))
- }
- def IfElse = rule{
- (IfElse1 | IfElse2) ~> ((a, b, c, d) => Ast.Block.IfElse(b, c, d, a))
- }
-
- def ForHead = rule{
- push(offsetCursor) ~ "@" ~ capture("for" ~ '(' ~ Enumerators ~ ')')
- }
- def ForLoop = rule{
- ForHead ~
- BraceBlock ~> ((a, b, c) => Ast.Block.For(b, c, a))
- }
- def LoneForLoop = rule{
- (push(offsetCursor) ~ capture(Indent) ~> ((i, t) => Ast.Block.Text(t, i))) ~
- ForHead ~
- IndentBlock ~>
- ((a, b, c) => Ast.Block.For(b, c, a))
- }
-
- def ScalaChain = rule {
- push(offsetCursor) ~ Code ~ zeroOrMore(Extension) ~> { (a, b, c) => Ast.Chain(b, c, a)}
- }
- def Extension: Rule1[Ast.Chain.Sub] = rule {
- (push(offsetCursor) ~ '.' ~ capture(Identifiers.Id) ~> ((x, y) => Ast.Chain.Prop(y, x))) |
- (push(offsetCursor) ~ capture(TypeArgs2) ~> ((x, y) => Ast.Chain.TypeArgs(y, x))) |
- (push(offsetCursor) ~ capture(ArgumentExprs2) ~> ((x, y) => Ast.Chain.Args(y, x))) |
- BraceBlock
- }
- def Ws = WL
- // clones of the version in ScalaSyntax, but without tailing whitespace or newlines
- def TypeArgs2 = rule { '[' ~ Ws ~ Types ~ ']' }
- def ArgumentExprs2 = rule {
- '(' ~ Ws ~
- (optional(Exprs ~ ',' ~ Ws) ~ PostfixExpr ~ ':' ~ Ws ~ '_' ~ Ws ~ '*' ~ Ws | optional(Exprs) ) ~
- ')'
- }
- def BlockExpr2: Rule0 = rule { '{' ~ Ws ~ (CaseClauses | Block) ~ Ws ~ '}' }
- def BraceBlock: Rule1[Ast.Block] = rule{ '{' ~ BodyNoBrace ~ '}' }
-
- def BodyItem(exclusions: String): Rule1[Seq[Ast.Block.Sub]] = rule{
- ForLoop ~> (Seq(_)) |
- LoneForLoop ~> (Seq(_, _)) |
- IfElse ~> (Seq(_)) |
- LoneScalaChain ~> (Seq(_, _)) |
- HeaderBlock ~> (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{ 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) =>
- Ast.Block(x.flatten, i)
- }
- }
-}
-
-trait Ast{
- def offset: Int
-}
-object Ast{
-
- /**
- * @param parts The various bits of text and other things which make up this block
- * @param offset
- */
- case class Block(parts: Seq[Block.Sub],
- offset: Int = 0)
- extends Chain.Sub with Block.Sub
- object Block{
- trait Sub extends Ast
- case class Text(txt: String, offset: Int = 0) extends Block.Sub
- case class For(generators: String, block: Block, offset: Int = 0) extends Block.Sub
- case class IfElse(condition: String, block: Block, elseBlock: Option[Block], offset: Int = 0) extends Block.Sub
- }
- case class Header(front: String, block: Block, offset: Int = 0) extends Block.Sub with Chain.Sub
-
- /**
- * @param lhs The first expression in this method-chain
- * @param parts A list of follow-on items chained to the first
- * @param offset
- */
- case class Chain(lhs: String, parts: Seq[Chain.Sub], offset: Int = 0) extends Block.Sub
- object Chain{
- trait Sub extends Ast
- case class Prop(str: String, offset: Int = 0) extends Sub
- case class TypeArgs(str: String, offset: Int = 0) extends Sub
- case class Args(str: String, offset: Int = 0) extends Sub
- }
-}
diff --git a/scalatex/api/src/main/scala/scalatex/stages/Trim.scala b/scalatex/api/src/main/scala/scalatex/stages/Trim.scala
deleted file mode 100644
index 8993734..0000000
--- a/scalatex/api/src/main/scala/scalatex/stages/Trim.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-package scalatex.stages
-import acyclic.file
-
-/**
- * Preprocesses the input string to normalize things related to whitespace
- *
- * Find the "first" non-whitespace-line of the text and remove the front
- * of every line to align that first line with the left margin.
- *
- * Remove all trailing whitespace from each line.
- */
-object Trim extends (String => (String, Int)){
- def apply(str: String) = {
- val lines = str.split("\n", -1)
- val offset = lines.iterator
- .filter(_.length > 0)
- .next()
- .takeWhile(_ == ' ')
- .length
- val res = lines.iterator
- .map(_.replaceFirst("\\s+$", ""))
- .mkString("\n")
- (res, offset)
- }
- def old(str: String) = {
- val (res, offset) = this.apply(str)
- res.split("\n", -1).map(_.drop(offset)).mkString("\n")
- }
-}
diff --git a/scalatex/api/src/test/scala/scalatex/BasicTests.scala b/scalatex/api/src/test/scala/scalatex/BasicTests.scala
deleted file mode 100644
index 4bc362c..0000000
--- a/scalatex/api/src/test/scala/scalatex/BasicTests.scala
+++ /dev/null
@@ -1,468 +0,0 @@
-package scalatex
-import utest._
-import scala.collection.mutable.ArrayBuffer
-import scalatex.stages._
-import scalatags.Text.all._
-
-
-/**
-* Created by haoyi on 7/14/14.
-*/
-object BasicTests extends TestSuite{
- import TestUtil._
-
- val tests = TestSuite{
-
- 'helloWorld{
- object omg {
- def wtf(s: Frag*): Frag = Seq[Frag]("|", s, "|")
- }
- def str = "hear me moo"
- check(
- tw("""
- @omg.wtf
- i @b{am} cow @str
- """),
- "|i<b>am</b>cowhearmemoo|"
- )
- }
- 'interpolation{
- 'chained-check(
- tw("omg @scala.math.pow(0.5, 3) wtf"),
- "omg 0.125 wtf"
- )
- 'parens-check(
- tw("omg @(1 + 2 + 3 + 4) wtf"),
- "omg 10 wtf"
- )
- 'block-check(
- tw("""
- @{"lol" * 3}
- @{
- val omg = "omg"
- omg * 2
- }
- """),
- """
- lollollol
- omgomg
- """
- )
- }
- 'definitions{
- 'imports{
- object Whee{
- def func(x: Int) = x * 2
- }
- check(
- tw("""
- @import math._
- @import Whee.func
- @abs(-10)
- @p
- @max(1, 2)
- @func(2)
- """),
- """
- 10
- <p>
- 2
- 4
- </p>
- """
- )
- }
- 'valDefVar{
- check(
- tw("""
- Hello
- @val x = 1
- World @x
- @def y = "omg"
- mooo
- @y
- """),
- """
- Hello
- World 1
- mooo
- omg
- """
- )
- }
- 'classObjectTrait{
- check(
- tw("""
- @trait Trait{
- def tt = 2
- }
- Hello
- @case object moo extends Trait{
- val omg = "wtf"
- }
-
- @moo.toString
- @moo.omg
- @case class Foo(i: Int, s: String, b: Boolean)
- TT is @moo.tt
- @Foo(10, "10", true).toString
- """),
- """
- Hello
- moo
- wtf
- TT is 2
- Foo(10, 10, true)
- """
- )
- }
- }
- 'parenArgumentLists{
- 'attributes{
- check(
- tw("""
- @div(id:="my-id"){ omg }
- @div(id:="my-id")
- omg
- """),
- """
- <divid="my-id">omg</div>
- <divid="my-id">omg</div>
- """
- )
- }
-// 'multiline{
-//
-// check(
-// tw("""
-// @div(
-// h1("Hello World"),
-// p("I am a ", b{"cow"})
-// )
-// """),
-// """
-// <div>
-// <h1>Hello World</h1>
-// <p>I am a <b>cow</b></p>
-// </div>
-// """
-// )
-// }
- }
- 'grouping{
- 'negative{
- // The indentation for "normal" text is ignored; we only
- // create blocks from the indentation following a scala
- // @xxx expression
- check(
- tw("""
- I am cow hear me moo
- I weigh twice as much as you
- And I look good on the barbecue
- Yoghurt curds cream cheese and butter
- Comes from liquids from my udder
- I am cow I am cow hear me moooooo
- """),
- """
- I am cow hear me moo
- I weigh twice as much as you
- And I look good on the barbecue
- Yoghurt curds cream cheese and butter
- Comes from liquids from my udder
- I am cow I am cow hear me moooooo
- """
- )
- }
- 'indentation{
- 'simple{
- val world = "World2"
-
- check(
- tw("""
- @h1
- Hello World
- @h2
- hello @world
- @h3
- Cow
- """),
- """
- <h1>HelloWorld</h1>
- <h2>helloWorld2</h2>
- <h3>Cow</h3>
- """
- )
- }
- 'linearNested{
- check(
- tw("""
- @h1 @span @a Hello World
- @h2 @span @a hello
- @b world
- @h3 @i
- @div Cow
- """),
- """
- <h1></h1><span></span><a></a>HelloWorld
- <h2></h2><span></span><a></a>hello<b></b>world
- <h3></h3><i></i><div></div>Cow
- """
- )
- }
- 'crasher{
- tw("""
-@html
- @head
- @meta
- @div
- @a
- @span
- """)
- }
- }
- 'curlies{
- 'simple{
- val world = "World2"
-
- check(
- tw("""@div{Hello World}"""),
- """<div>HelloWorld</div>"""
- )
- }
- 'multiline{
- check(
- tw("""
- @div{
- Hello
- }
- """),
- """
- <div>Hello</div>
- """
- )
- }
- }
- 'mixed{
- check(
- tw("""
- @div{
- Hello
- @div
- @h1
- WORLD @b{!!!}
- lol
- @p{
- @h2{Header 2}
- }
- }
- """),
- """
- <div>
- Hello
- <div>
- <h1>WORLD<b>!!!</b>lol</h1>
- <p><h2>Header2</h2></p>
- </div>
- </div>
- """
- )
- }
-//
-// 'args{
-// val things = Seq(1, 2, 3)
-// check(
-// tw("""
-// @ul
-// @things.map { x =>
-// @li
-// @x
-// }
-// """),
-// tw("""
-// @ul
-// @things.map x =>
-// @li
-// @x
-//
-// """),
-// """
-// <ul>
-// <li>1</li>
-// <li>2</li>
-// <li>3</li>
-// </ul>
-// """
-// )
-// }
- }
-//
- 'loops {
-//
- * - check(
- tw("""
- @for(x <- 0 until 3)
- lol
- """),
- tw("""
- @for(x <- 0 until 3){
- lol
- }
- """),
- "lollollol"
- )
-
-
- * - check(
- tw("""
- @p
- @for(x <- 0 until 2)
- @for(y <- 0 until 2)
- lol@x@y
- """),
- tw( """
- @p
- @for(x <- 0 until 2){
- @for(y <- 0 until 2)
- lol@x@y
- }
- """),
- tw("""
- @p
- @for(x <- 0 until 2)
- @for(y <- 0 until 2){
- lol@x@y
- }
- """),
- "<p>lol00lol01lol10lol11</p>"
- )
- check(
- tw("""
- @p
- @for(x <- 0 until 2)
- @for(y <- 0 until 2)
- lol@x@y
- """),
- "<p>lol00lol01lol10lol11</p>"
- )
-
- * - check(
- tw(
- """
- @for(x <- 0 until 2; y <- 0 until 2)
- @div{@x@y}
-
- """),
- """<div>00</div><div>01</div><div>10</div><div>11</div>"""
- )
- }
-
- 'ifElse{
- 'basicExamples{
- * - check(
- tw("""
- @if(false)
- Hello
- @else
- lols
- @p
- """),
- "lols<p></p>"
- )
-
- * - check(
- tw("""
- @div
- @if(true)
- Hello
- @else
- lols
- """),
- "<div>Hello</div>"
- )
-
- * - check(
- tw("""
- @div
- @if(true)
- Hello
- @else
- lols
- """),
- "<div>Hello</div>"
- )
- * - check(
- tw("""
- @if(false)
- Hello
- @else
- lols
- """),
- "lols"
- )
- * - check(
- tw("""
- @if(false)
- Hello
- @else
- lols
- @img
- """),
- "lols<img/>"
- )
- * - check(
- tw("""
- @p
- @if(true)
- Hello
- @else
- lols
- """),
- tw("""
- @p
- @if(true){
- Hello
- }else{
- lols
- }
- """),
- "<p>Hello</p>"
- )
- }
-// 'funkyExpressions{
-// * - check(
-// tw("""
-// @p
-// @if(true == false == (true.==(false)))
-// @if(true == false == (true.==(false)))
-// Hello1
-// @else
-// lols1
-// @else
-// @if(true == false == (true.==(false)))
-// Hello2
-// @else
-// lols2
-// """),
-// "<p>Hello1</p>"
-// )
-// * - check(
-// tw("""
-// @p
-// @if(true == false != (true.==(false)))
-// @if(true == false != (true.==(false)))
-// Hello1
-// @else
-// lols1
-// @else
-// @if(true == false != (true.==(false)))
-// Hello2
-// @else
-// lols2
-// """),
-// "<p>lols2</p>"
-// )
-// }
- }
- }
-
-}
diff --git a/scalatex/api/src/test/scala/scalatex/ErrorTests.scala b/scalatex/api/src/test/scala/scalatex/ErrorTests.scala
deleted file mode 100644
index d8cd4f5..0000000
--- a/scalatex/api/src/test/scala/scalatex/ErrorTests.scala
+++ /dev/null
@@ -1,373 +0,0 @@
-package scalatex
-
-import utest._
-import scalatex.stages._
-import scalatags.Text.all._
-import scalatex.Internals.{DebugFailure, twRuntimeErrors}
-
-/**
-* Created by haoyi on 7/14/14.
-*/
-object ErrorTests extends TestSuite{
- def check(x: => Unit, expectedMsg: String, expectedError: String) = {
- val DebugFailure(msg, pos) = intercept[DebugFailure](x)
- def format(str: String) = {
- val whitespace = " \t\n".toSet
- "\n" + str.dropWhile(_ == '\n')
- .reverse
- .dropWhile(whitespace.contains)
- .reverse
- }
- // Format these guys nicely to normalize them and make them
- // display nicely in the assert error message if it blows up
- val formattedPos = format(pos)
- val formattedExpectedPos = format(expectedError)
-
- assert(msg.contains(expectedMsg))
- assert(formattedPos == formattedExpectedPos)
-
- }
- val tests = TestSuite{
-
-
- 'simple - check(
- twRuntimeErrors("omg @notInScope lol"),
- """not found: value notInScope""",
- """
- twRuntimeErrors("omg @notInScope lol"),
- ^
- """
- )
-
- 'chained{
- 'properties {
- * - check(
- twRuntimeErrors("omg @math.lol lol"),
- """object lol is not a member of package math""",
- """
- twRuntimeErrors("omg @math.lol lol"),
- ^
- """
- )
-
- * - check(
- twRuntimeErrors("omg @math.E.lol lol"),
- """value lol is not a member of Double""",
- """
- twRuntimeErrors("omg @math.E.lol lol"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("omg @_root_.scala.math.lol lol"),
- """object lol is not a member of package math""",
- """
- twRuntimeErrors("omg @_root_.scala.math.lol lol"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("omg @_root_.scala.gg.lol lol"),
- """object gg is not a member of package scala""",
- """
- twRuntimeErrors("omg @_root_.scala.gg.lol lol"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("omg @_root_.ggnore.math.lol lol"),
- """object ggnore is not a member of package <root>""",
- """
- twRuntimeErrors("omg @_root_.ggnore.math.lol lol"),
- ^
- """
- )
- }
- 'calls{
- * - check(
- twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"),
- """object QQ is not a member of package scala""",
- """
- twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"),
- "value tdo is not a member of Int",
- """
- twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"),
- "value z is not a member of Int",
- """
- twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"),
- "value z is not a member of Int",
- """
- twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"),
- "value cow is not a member of Int",
- """
- twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@scala.smath.abs.cow.sum.z"),
- "object smath is not a member of package scala",
- """
- twRuntimeErrors("@scala.smath.abs.cow.sum.z"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@scala.math.cos('omg)"),
- "type mismatch",
- """
- twRuntimeErrors("@scala.math.cos('omg)"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@scala.math.cos[omg]('omg)"),
- "not found: type omg",
- """
- twRuntimeErrors("@scala.math.cos[omg]('omg)"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("""
- I am cow hear me moo
- @scala.math.abs(-10).tdo(10).sum.z
- I weigh twice as much as you
- """),
- "value tdo is not a member of Int",
- """
- @scala.math.abs(-10).tdo(10).sum.z
- ^
- """
- )
- }
- 'curlies{
- * - check(
- twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"),
- "missing arguments for method foldLeft",
- """
- twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"),
- ^
- """
- )
-
- * - check(
- twRuntimeErrors("@Nil.foldLeft{XY}"),
- "missing arguments for method foldLeft",
- """
- twRuntimeErrors("@Nil.foldLeft{XY}"),
- ^
- """
- )
-
-// * - check(
-// twRuntimeErrors("@Seq(1).map{(y: String) => omg}"),
-// "type mismatch",
-// """
-// twRuntimeErrors("@Seq(1).map{(y: String) => omg}"),
-// ^
-// """
-// )
-// * - check(
-// twRuntimeErrors("@Nil.map{ omg}"),
-// "too many arguments for method map",
-// """
-// twRuntimeErrors("@Nil.map{ omg}"),
-// ^
-// """
-// )
- }
- 'callContents{
- * - check(
- twRuntimeErrors("@scala.math.abs((1, 2).wtf)"),
- "value wtf is not a member of (Int, Int)",
- """
- twRuntimeErrors("@scala.math.abs((1, 2).wtf)"),
- ^
- """
- )
-
- * - check(
- twRuntimeErrors("@scala.math.abs((1, 2).swap._1.toString().map(_.toString.wtf))"),
- "value wtf is not a member of String",
- """
- twRuntimeErrors("@scala.math.abs((1, 2).swap._1.toString().map(_.toString.wtf))"),
- ^
- """
- )
- }
- }
- 'ifElse{
- 'oneLine {
- * - check(
- twRuntimeErrors("@if(math > 10){ 1 }else{ 2 }"),
- "object > is not a member of package math",
- """
- twRuntimeErrors("@if(math > 10){ 1 }else{ 2 }"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@if(true){ (@math.pow(10)) * 10 }else{ 2 }"),
- "Unspecified value parameter y",
- """
- twRuntimeErrors("@if(true){ (@math.pow(10)) * 10 }else{ 2 }"),
- ^
- """
- )
- * - check(
- twRuntimeErrors("@if(true){ * 10 }else{ @math.sin(3, 4, 5) }"),
- "too many arguments for method sin: (x: Double)Double",
- """
- twRuntimeErrors("@if(true){ * 10 }else{ @math.sin(3, 4, 5) }"),
- ^
- """
- )
- }
- 'multiLine{
- * - check(
- twRuntimeErrors("""
- Ho Ho Ho
-
- @if(math != 10)
- I am a cow
- @else
- You are a cow
- GG
- """),
- "object != is not a member of package math",
- """
- @if(math != 10)
- ^
- """
- )
- * - check(
- twRuntimeErrors("""
- Ho Ho Ho
-
- @if(4 != 10)
- I am a cow @math.lols
- @else
- You are a cow
- GG
- """),
- "object lols is not a member of package math",
- """
- I am a cow @math.lols
- ^
- """
- )
- * - check(
- twRuntimeErrors("""
- Ho Ho Ho
-
- @if(12 != 10)
- I am a cow
- @else
- @math.E.toString.gog(1)
- GG
- """),
- "value gog is not a member of String",
- """
- @math.E.toString.gog(1)
- ^
- """
- )
- }
- }
- 'forLoop{
- 'oneLine{
- 'header - check(
- twRuntimeErrors("omg @for(x <- (0 + 1 + 2) omglolol (10 + 11 + 2)){ hello }"),
- """value omglolol is not a member of Int""",
- """
- twRuntimeErrors("omg @for(x <- (0 + 1 + 2) omglolol (10 + 11 + 2)){ hello }"),
- ^
- """
- )
-
- 'body - check(
- twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"),
- """too many arguments for method +""",
- """
- twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"),
- ^
- """
- )
- }
- 'multiLine{
- 'body - check(
- twRuntimeErrors("""
- omg
- @for(x <- 0 until 10)
- I am cow hear me moo
- I weigh twice as much as @x.kkk
- """),
- """value kkk is not a member of Int""",
- """
- I weigh twice as much as @x.kkk
- ^
- """
- )
- }
- }
- 'multiLine{
- 'missingVar - check(
- twRuntimeErrors("""
- omg @notInScope lol
- """),
- """not found: value notInScope""",
- """
- omg @notInScope lol
- ^
- """
- )
-// 'wrongType - check(
-// twRuntimeErrors("""
-// omg @{() => ()} lol
-// """),
-// """type mismatch""",
-// """
-// omg @{() => ()} lol
-// ^
-// """
-// )
-
- 'bigExpression - check(
- twRuntimeErrors("""
- @{
- val x = 1 + 2
- val y = new Object()
- val z = y * x
- x
- }
- """),
- "value * is not a member of Object",
- """
- val z = y * x
- ^
- """
- )
- }
- }
-}
diff --git a/scalatex/api/src/test/scala/scalatex/ParserTests.scala b/scalatex/api/src/test/scala/scalatex/ParserTests.scala
deleted file mode 100644
index 9a4ee63..0000000
--- a/scalatex/api/src/test/scala/scalatex/ParserTests.scala
+++ /dev/null
@@ -1,424 +0,0 @@
-package scalatex
-
-
-import org.parboiled2._
-import scalaParser.ScalaSyntax
-
-import scalatex.stages.{Trim, Parser, Ast}
-import scalatex.stages.Ast.Block.{IfElse, For, Text}
-import Ast.Chain.Args
-
-object ParserTests extends utest.TestSuite{
- import Ast._
- import utest._
- def check[T](input: String, parse: Parser => scala.util.Try[T], expected: T) = {
- val parsed = parse(new Parser(input)).get
- assert(parsed == expected)
- }
- def tests = TestSuite{
- 'Trim{
- def wrap(s: String) = "|" + s + "|"
- * - {
- val trimmed = wrap(stages.Trim.old("""
- i am cow
- hear me moo
- i weigh twice as much as you
- """))
- val expected = wrap("""
- |i am cow
- | hear me moo
- | i weigh twice as much as you
- |""".stripMargin)
- assert(trimmed == expected)
-
- }
- * - {
- val trimmed = wrap(stages.Trim.old(
- """
- @{"lol" * 3}
- @{
- val omg = "omg"
- omg * 2
- }
- """
- ))
- val expected = wrap(
- """
- |@{"lol" * 3}
- |@{
- | val omg = "omg"
- | omg * 2
- |}
- |""".stripMargin
- )
- assert(trimmed == expected)
- }
- 'dropTrailingWhitespace - {
-
- val trimmed = wrap(stages.Trim.old(
- Seq(
- " i am a cow ",
- " hear me moo ",
- " i weigh twice as much as you"
- ).mkString("\n")
- ))
- val expected = wrap(
- Seq(
- "i am a cow",
- " hear me moo",
- " i weigh twice as much as you"
- ).mkString("\n")
- )
- assert(trimmed == expected)
- }
- }
- 'Text {
- * - check("i am a cow", _.Text.run(), Block.Text("i am a cow"))
- * - check("i am a @cow", _.Text.run(), Block.Text("i am a "))
- * - check("i am a @@cow", _.Text.run(), Block.Text("i am a @cow"))
- * - check("i am a @@@cow", _.Text.run(), Block.Text("i am a @"))
- * - check("i am a @@@@cow", _.Text.run(), Block.Text("i am a @@cow"))
-
- }
- 'Code{
- 'identifier - check("@gggg ", _.Code.run(), "gggg")
- 'parens - check("@(1 + 1)lolsss\n", _.Code.run(), "(1 + 1)")
- 'curlies - check("@{{1} + (1)} ", _.Code.run(), "{{1} + (1)}")
- 'blocks - check("@{val x = 1; 1} ", _.Code.run(), "{val x = 1; 1}")
- 'weirdBackticks - check("@{`{}}{()@`}\n", _.Code.run(), "{`{}}{()@`}")
- }
- 'MiscCode{
- 'imports{
- * - check("@import math.abs", _.Header.run(), "import math.abs")
- * - check("@import math.{abs, sin}", _.Header.run(), "import math.{abs, sin}")
- }
- 'headerblocks{
- check(
- """@import math.abs
- |@import math.sin
- |
- |hello world
- |""".stripMargin,
- _.HeaderBlock.run(),
- Ast.Header(
- "import math.abs\nimport math.sin",
- Ast.Block(
- Seq(Text("\n", 33), Text("\n", 34), Text("hello world", 35), Text("\n", 46)),
- 33
- )
- )
- )
- }
- 'caseclass{
- check(
- """@case class Foo(i: Int, s: String)
- """.stripMargin,
- _.Header.run(),
- "case class Foo(i: Int, s: String)"
- )
- }
-
- }
- 'Block{
- * - check("{i am a cow}", _.BraceBlock.run(), Block(Seq(Block.Text("i am a cow", 1)), 1))
- * - check("{i @am a @cow}", _.BraceBlock.run(),
- Block(Seq(
- Block.Text("i ", 1),
- Chain("am",Seq(), 3),
- Block.Text(" a ", 6),
- Chain("cow",Seq(), 9)
- ), 1)
- )
- }
- 'Chain{
- * - check("@omg.bbq[omg].fff[fff](123) ", _.ScalaChain.run(),
- Chain("omg",Seq(
- Chain.Prop("bbq", 4),
- Chain.TypeArgs("[omg]", 8),
- Chain.Prop("fff", 13),
- Chain.TypeArgs("[fff]", 17),
- Chain.Args("(123)", 22)
- ))
- )
- * - check("@omg{bbq}.cow(moo){a @b}\n", _.ScalaChain.run(),
- Chain("omg",Seq(
- Block(Seq(Text("bbq", 5)), 5),
- Chain.Prop("cow", 9),
- Chain.Args("(moo)", 13),
- Block(Seq(Text("a ", 19), Chain("b", Nil, 21)), 19)
- ))
- )
- }
- 'ControlFlow{
- 'for {
- 'for - check(
- "@for(x <- 0 until 3){lol}",
- _.ForLoop.run(),
- For("for(x <- 0 until 3)", Block(Seq(Text("lol", 21)), 21))
- )
- 'forBlock - check(
- """
- |@for(x <- 0 until 3)
- | lol""".stripMargin,
- _.Body.run(),
- Block(Seq(
- Text("\n"),
- For(
- "for(x <- 0 until 3)",
- Block(Seq(Text("\n ", 21), Text("lol", 24)), 21),
- 1
- )
- ))
- )
- 'forBlockBraces - check(
- """
- |@for(x <- 0 until 3){
- | lol
- |}""".stripMargin,
- _.Body.run(),
- Block(Seq(
- Text("\n"),
- For(
- "for(x <- 0 until 3)",
- Block(Seq(Text("\n ", 22), Text("lol", 25), Text("\n", 28)), 22),
- 1
- )
- ))
- )
- }
- 'ifElse {
- 'if - check(
- "@if(true){lol}",
- _.IfElse.run(),
- IfElse("if(true)", Block(Seq(Text("lol", 10)), 10), None)
- )
- 'ifElse - check(
- "@if(true){lol}else{ omg }",
- _.IfElse.run(),
- IfElse("if(true)", Block(Seq(Text("lol", 10)), 10), Some(Block(Seq(Text(" omg ", 19)), 19)))
- )
- 'ifBlock - check(
- """
- |@if(true)
- | omg""".stripMargin,
- _.IfElse.run(),
- IfElse("if(true)", Block(Seq(Text("\n ", 10), Text("omg", 13)), 10), None, 1)
- )
- 'ifBlockElseBlock - check(
- """
- |@if(true)
- | omg
- |@else
- | wtf""".stripMargin,
- _.IfElse.run(),
- IfElse(
- "if(true)",
- Block(Seq(Text("\n ", 10), Text("omg", 13)), 10),
- Some(Block(Seq(Text("\n ", 22), Text("wtf", 25)), 22)),
- 1
- )
- )
- 'ifBlockElseBraceBlock - check(
- """@if(true){
- | omg
- |}else{
- | wtf
- |}""".stripMargin,
- _.IfElse.run(),
- IfElse(
- "if(true)",
- Block(Seq(Text("\n ", 10), Text("omg", 13), Text("\n", 16)), 10),
- Some(Block(Seq(Text("\n ", 23), Text("wtf", 26), Text("\n", 29)), 23)),
- 0
- )
- )
- 'ifBlockElseBraceBlockNested - {
- val res = Parser(Trim.old(
- """
- @p
- @if(true){
- Hello
- }else{
- lols
- }
- """))
- val expected =
- Block(Vector(
- Text("\n"),
- Chain("p",Vector(Block(Vector(
- Text("\n ", 3),
- IfElse("if(true)",
- Block(Vector(
- Text("\n ", 16), Text("Hello", 21), Text("\n ", 26)
- ), 16),
- Some(Block(Vector(
- Text("\n ", 35), Text("lols", 40), Text("\n ", 44)
- ), 35)),
- 6
- )), 3)), 1),
- Text("\n", 48)
- ))
- assert(res == expected)
- }
- 'ifElseBlock - check(
- """@if(true){
- | omg
- |}else
- | wtf""".stripMargin,
- _.IfElse.run(),
- IfElse(
- "if(true)",
- Block(Seq(Text("\n ", 10), Text("omg", 13), Text("\n", 16)), 10),
- Some(Block(Seq(Text("\n ", 22), Text("wtf", 25)), 22))
- )
- )
- }
-
- }
- 'Body{
- 'indents - check(
- """
- |@omg
- | @wtf
- | @bbq
- | @lol""".stripMargin,
- _.Body.run(),
- Block(Seq(
- Text("\n"),
- Chain("omg",Seq(Block(Seq(
- Text("\n ", 5),
- Chain("wtf",Seq(Block(Seq(
- Text("\n ", 7),
- Chain("bbq",Seq(Block(Seq(
- Text("\n ", 9),
- Chain("lol",Seq(), 16)
- ), 9)), 12)
- ), 7)), 8)
- ), 5)), 1)
- ))
- )
- 'dedents - check(
- """
- |@omg
- | @wtf
- |@bbq""".stripMargin,
- _.Body.run(),
- Block(Seq(
- Text("\n"),
- Chain("omg",Seq(Block(
- Seq(
- Text("\n ", 5),
- Chain("wtf",Seq(), 8)
- ),
- 5
- )), 1),
- Text("\n", 12),
- Chain("bbq", Seq(), 13)
- ))
- )
- 'braces - check(
- """
- |@omg{
- | @wtf
- |}
- |@bbq""".stripMargin,
- _.Body.run(),
- Block(Seq(
- Text("\n"),
- Chain("omg",Seq(Block(
- Seq(
- Text("\n ", 6),
- Chain("wtf",Seq(), 9),
- Text("\n", 13)
- ),
- 6
- )), 1),
- Text("\n", 15),
- Chain("bbq", Seq(), 16)
- ))
- )
- 'dedentText - check(
- """
- |@omg("lol", 1, 2)
- | @wtf
- |bbq""".stripMargin,
- _.Body.run(),
- Block(Seq(
- Text("\n"),
- Chain("omg",Seq(
- Args("""("lol", 1, 2)""", 5),
- Block(Seq(
- Text("\n ", 18),
- Chain("wtf",Seq(), 21)
- ), 18)
- ), 1),
- Text("\n", 25),
- Text("bbq", 26)
- ))
- )
- * - check(
- """
- |@omg("lol",
- |1,
- | 2
- | )
- | wtf
- |bbq""".stripMargin,
- _.Body.run(),
- Block(Seq(
- Text("\n", 0),
- Chain("omg",Seq(
- Args("(\"lol\",\n1,\n 2\n )", 5),
- Block(Seq(
- Text("\n ", 30), Text("wtf", 33)
- ), 30)
- ), 1),
- Text("\n", 36),
- Text("bbq", 37)
- ), 0)
- )
- 'codeBlock - check(
- """@{
- | val omg = "omg"
- | omg * 2
- |}""".stripMargin,
- _.Code.run(),
- """{
- | val omg = "omg"
- | omg * 2
- |}""".stripMargin
- )
- 'codeBlocks - check(
- """
- |@{"lol" * 3}
- |@{
- | val omg = "omg"
- | omg * 2
- |}""".stripMargin,
- _.Body.run(),
- Block(Seq(
- Text("\n"),
- Chain("{\"lol\" * 3}", Seq(), 1),
- Text("\n", 13),
- Chain("""{
- | val omg = "omg"
- | omg * 2
- |}""".stripMargin,
- Seq(),
- 14
- )
- ))
- )
- }
-// 'Test{
-// check(
-// "@{() => ()}",
-// _.Code.run(),
-// ""
-// )
-// }
- }
-}
-
-
-
diff --git a/scalatex/api/src/test/scala/scalatex/TestUtil.scala b/scalatex/api/src/test/scala/scalatex/TestUtil.scala
deleted file mode 100644
index 5a72677..0000000
--- a/scalatex/api/src/test/scala/scalatex/TestUtil.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-package scalatex
-
-import utest._
-
-
-object TestUtil {
- implicit def stringify(f: scalatags.Text.all.Frag) = f.render
- def check(rendered: String*) = {
- val collapsed = rendered.map(collapse)
- val first = collapsed(0)
- assert(collapsed.forall(_ == first))
- }
- def collapse(s: String): String = {
- s.replaceAll("[ \n]", "")
- }
-}
diff --git a/scalatex/build.sbt b/scalatex/build.sbt
deleted file mode 100644
index 4769bad..0000000
--- a/scalatex/build.sbt
+++ /dev/null
@@ -1,44 +0,0 @@
-val sharedSettings = Seq(
- version := "0.1.0",
- organization := "com.lihaoyi",
- crossScalaVersions:= Seq("2.10.4", "2.11.2"),
- scalaVersion := "2.11.4",
- libraryDependencies += "com.lihaoyi" %% "acyclic" % "0.1.2" % "provided",
- addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
- autoCompilerPlugins := true
-)
-
-lazy val scalaParser = project.settings(sharedSettings:_*)
- .settings(
- name := "scala-parser-lite",
- libraryDependencies ++= Seq(
- "com.lihaoyi" %% "utest" % "0.2.4",
- "org.parboiled" %% "parboiled" % "2.0.1"
- ),
- testFrameworks += new TestFramework("utest.runner.JvmFramework")
- )
-lazy val api = project.settings(sharedSettings:_*)
- .dependsOn(scalaParser)
- .settings(
- name := "scalatex-api",
- libraryDependencies ++= Seq(
- "com.lihaoyi" %% "utest" % "0.2.4",
- "com.scalatags" %% "scalatags" % "0.4.2",
- "org.scala-lang" % "scala-reflect" % scalaVersion.value,
- "org.parboiled" %% "parboiled" % "2.0.1"
- ),
- testFrameworks += new TestFramework("utest.runner.JvmFramework")
- )
-
-lazy val scalatexSbtPlugin = project.settings(sharedSettings:_*)
- .settings(
- name := "scalatex-sbt-plugin",
- scalaVersion := "2.10.4",
- sbtPlugin := true
-)
-lazy val compilerPlugin = project.settings(sharedSettings:_*)
- .dependsOn(api)
- .settings(
- name := "scalatex-compiler-plugin",
- libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value
-) \ No newline at end of file
diff --git a/scalatex/compilerPlugin/src/main/resources/scalac-plugin.xml b/scalatex/compilerPlugin/src/main/resources/scalac-plugin.xml
deleted file mode 100755
index a446f13..0000000
--- a/scalatex/compilerPlugin/src/main/resources/scalac-plugin.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<plugin>
- <name>demo-plugin</name>
- <classname>scalatex.CompilerPlugin</classname>
-</plugin> \ No newline at end of file
diff --git a/scalatex/compilerPlugin/src/main/scala/scalatex/CompilerPlugin.scala b/scalatex/compilerPlugin/src/main/scala/scalatex/CompilerPlugin.scala
deleted file mode 100755
index e122de5..0000000
--- a/scalatex/compilerPlugin/src/main/scala/scalatex/CompilerPlugin.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-package scalatex
-
-import java.nio.file.Paths
-
-import scala.reflect.internal.util.BatchSourceFile
-import scala.reflect.io.VirtualFile
-import scala.tools.nsc.{ Global, Phase }
-import scala.tools.nsc.plugins.{ Plugin, PluginComponent }
-
-class CompilerPlugin(val global: Global) extends Plugin {
- import global._
-
- override def init(options: List[String], error: String => Unit): Boolean = true
-
- val name = "scalatex"
- val description = "Compiles scalatex files into Scala compilation units"
- val components = List[PluginComponent](DemoComponent)
- private object DemoComponent extends PluginComponent {
-
- val global = CompilerPlugin.this.global
- import global._
-
- override val runsAfter = List("parser")
- override val runsBefore = List("namer")
-
- val phaseName = "Demo"
-
- override def newPhase(prev: Phase) = new GlobalPhase(prev) {
- val splitOptions = options.map(o => o.splitAt(o.indexOf(":")+1))
- val scalatexRoots = splitOptions.collect{case ("root:", p) => p}
- override def run() = {
- def recursiveListFiles(f: java.io.File): Iterator[java.io.File] = {
- val (dirs, files) =
- Option(f.listFiles())
- .toSeq
- .flatten
- .partition(_.isDirectory)
- files.iterator ++ dirs.iterator.flatMap(recursiveListFiles)
- }
- for {
- scalatexRoot <- scalatexRoots
- file <- recursiveListFiles(new java.io.File(scalatexRoot))
- } {
- val name = file.getCanonicalPath
- val fakeJfile = new java.io.File(name)
- val txt = io.Source.fromFile(name).mkString
- val virtualFile = new VirtualFile(name) {
- override def file = fakeJfile
- }
- val sourceFile = new BatchSourceFile(virtualFile, txt)
- val unit = new CompilationUnit(sourceFile)
- val objectName = name.slice(name.lastIndexOf('/')+1, name.lastIndexOf('.'))
- val pkgName =
- Paths.get(scalatexRoot)
- .relativize(fakeJfile.getParentFile.toPath)
- .toString
- .split("/")
- .map(s => s"package $s")
- .mkString("\n")
-
- val shim = s"""
- $pkgName
- import scalatags.Text.all._
-
- object $objectName{
- def apply() = scalatex.twf("${name}")
- }
- """
- unit.body = global.newUnitParser(shim).parse()
- global.currentRun.compileLate(unit)
- }
- }
-
- def name: String = phaseName
-
- def apply(unit: global.CompilationUnit): Unit = {}
- }
- }
-}
diff --git a/scalatex/project/build.properties b/scalatex/project/build.properties
deleted file mode 100644
index 748703f..0000000
--- a/scalatex/project/build.properties
+++ /dev/null
@@ -1 +0,0 @@
-sbt.version=0.13.7
diff --git a/scalatex/project/build.sbt b/scalatex/project/build.sbt
deleted file mode 100644
index f1db6ad..0000000
--- a/scalatex/project/build.sbt
+++ /dev/null
@@ -1 +0,0 @@
-addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.4")
diff --git a/scalatex/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala b/scalatex/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala
deleted file mode 100644
index de9f039..0000000
--- a/scalatex/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala
+++ /dev/null
@@ -1,416 +0,0 @@
-package scalaParser
-import acyclic.file
-import language.implicitConversions
-import syntax._
-import org.parboiled2._
-
-/**
- * Parser for Scala syntax.
- *
- * The `G` parameter that gets passed in to each rule stands for
- * "Greedy", and determines whether or not that rule is to consume
- * newlines after the last terminal in that rule. We need to pass it
- * everywhere so it can go all the way to the last terminal deep
- * inside the parse tree, which can then decide whether or not to
- * consume whitespace.
- *
- * The vast majority of terminals will consume newlines; only rules
- * which occur in {} blocks won't have their terminals consume newlines,
- * and only the *last* terminal in the rule will be affected.
- * That's why the parser does terminals-consume-newlines-by-default,
- * and leaves it up to the dev to thread the `G` variable where-ever
- * we want the opposite behavior.
- */
-class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identifiers with Literals {
- // Aliases for common things. These things are used in almost every parser
- // in the file, so it makes sense to keep them short.
- type B = Boolean
- val t = true
- type R0 = Rule0
- /**
- * Parses all whitespace, excluding newlines. This is only
- * really useful in e.g. {} blocks, where we want to avoid
- * capturing newlines so semicolon-inference would work
- */
- def WS = rule { zeroOrMore(Basic.WhitespaceChar | Literals.Comment) }
-
- /**
- * Parses whitespace, including newlines.
- * This is the default for most things
- */
- def WL = rule{ zeroOrMore(Basic.WhitespaceChar | Literals.Comment | Basic.Newline) }
-
-
-
- /**
- * By default, all strings and characters greedily
- * capture all whitespace immediately after the token.
- */
- implicit private[this] def wspStr(s: String): R0 = rule { WL ~ str(s) }
- implicit private[this] def wspChar(s: Char): R0 = rule { WL ~ ch(s) }
-
- /**
- * Most keywords don't just require the correct characters to match,
- * they have to ensure that subsequent characters *don't* match in
- * order for it to be a keyword. This enforces that rule for key-words
- * (W) and key-operators (O) which have different non-match criteria.
- */
- object K {
- def W(s: String) = rule {
- WL ~ Key.W(s)
- }
-
- def O(s: String) = rule {
- WL ~ Key.O(s)
- }
- }
-
-
- def pos = cursor -> cursorChar
-
- /**
- * helper printing function
- */
- def pr(s: String) = rule { run(println(s"LOGGING $cursor: $s")) }
-
- def Id = rule { WL ~ Identifiers.Id }
- def VarId = rule { WL ~ Identifiers.VarId }
- def Literal = rule { WL ~ Literals.Literal }
- def Semi = rule { WS ~ Basic.Semi }
- def Semis = rule { oneOrMore(Semi) }
- def Newline = rule { WL ~ Basic.Newline }
-
- def QualId = rule { WL ~ oneOrMore(Id).separatedBy('.') }
- def Ids = rule { oneOrMore(Id) separatedBy ',' }
-
- def Path: R0 = rule {
- zeroOrMore(Id ~ '.') ~ K.W("this") ~ zeroOrMore(Id).separatedBy('.') |
- StableId
- }
- def StableId: R0 = rule {
- zeroOrMore(Id ~ '.') ~ (K.W("this") | K.W("super") ~ optional(ClassQualifier)) ~ '.' ~ oneOrMore(Id).separatedBy('.') |
- Id ~ zeroOrMore(WL ~ '.' ~ WL ~ Id)
- }
-
- def ClassQualifier = rule { '[' ~ Id ~ ']' }
-
- def Type: R0 = rule {
- FunctionArgTypes ~ K.O("=>") ~ Type | InfixType ~ optional(WL ~ ExistentialClause)
- }
- def FunctionArgTypes = rule {
- InfixType | '(' ~ optional(oneOrMore(ParamType) separatedBy ',') ~ ')'
- }
-
- def ExistentialClause = rule { "forSome" ~ '{' ~ oneOrMore(ExistentialDcl).separatedBy(Semi) }
- def ExistentialDcl = rule { K.W("type") ~ TypeDcl | K.W("val") ~ ValDcl }
-
- def InfixType = rule {
- CompoundType ~ zeroOrMore(WL ~ Id ~ optional(Newline) ~ CompoundType)
- }
- def CompoundType = rule {
- oneOrMore(AnnotType).separatedBy(WL ~ K.W("with")) ~ optional(Refinement)
- }
- def AnnotType = rule {
- SimpleType ~ zeroOrMore(WL ~ Annotation)
- }
- def SimpleType: R0 = rule {
- BasicType ~
- optional(WL ~ '#' ~ Id) ~
- optional(WL ~ TypeArgs)
- }
- def BasicType: R0 = rule {
- '(' ~ Types ~ ')' |
- Path ~ '.' ~ K.W("type") |
- StableId
- }
- def TypeArgs = rule { '[' ~ Types ~ "]" }
- def Types = rule { oneOrMore(Type).separatedBy(',') }
- def Refinement = rule {
- optional(Newline) ~ '{' ~ oneOrMore(RefineStat).separatedBy(Semi) ~ "}"
- }
- def RefineStat = rule { "type" ~ TypeDef | Dcl | MATCH }
- def TypePat = rule { CompoundType }
- def Ascription = rule {
- ":" ~ ("_" ~ "*" | InfixType | oneOrMore(Annotation))
- }
-
- def ParamType = rule { K.O("=>") ~ Type | Type ~ "*" | Type }
-
- def Expr: R0 = rule {
- (Bindings | optional(K.W("implicit")) ~ Id | "_") ~ K.O("=>") ~ Expr |
- Expr1
- }
- def Expr1: R0 = rule {
- IfCFlow |
- WhileCFlow |
- TryCFlow |
- DoWhileCFlow |
- ForCFlow |
- K.W("throw") ~ Expr |
- K.W("return") ~ optional(Expr) |
- SimpleExpr ~ K.O("=") ~ Expr |
- PostfixExpr ~ optional("match" ~ '{' ~ CaseClauses ~ "}" | Ascription)
-
- }
- def IfCFlow = rule { "if" ~ '(' ~ Expr ~ ')' ~ zeroOrMore(Newline) ~ Expr ~ optional(optional(Semi) ~ K.W("else") ~ Expr) }
- def WhileCFlow = rule { "while" ~ '(' ~ Expr ~ ')' ~ zeroOrMore(Newline) ~ Expr }
- def TryCFlow = rule {
- K.W("try") ~ Expr ~
- optional(WL ~ K.W("catch") ~ Expr) ~
- optional(WL ~ K.W("finally") ~ Expr)
- }
-
- def DoWhileCFlow = rule { K.W("do") ~ Expr ~ optional(Semi) ~ "while" ~ '(' ~ Expr ~ ")" }
- def ForCFlow = rule {
- "for" ~
- ('(' ~ Enumerators ~ ')' | '{' ~ Enumerators ~ '}') ~
- zeroOrMore(Newline) ~
- optional(K.W("yield")) ~
- Expr }
- def NotNewline: R0 = rule{ &( WS ~ noneOf("\n") )}
- def PostfixExpr: R0 = rule { InfixExpr ~ optional(NotNewline ~ Id ~ optional(Newline)) }
- def InfixExpr: R0 = rule {
- PrefixExpr ~
- zeroOrMore(
- NotNewline ~
- Id ~
- optional(Newline) ~
- PrefixExpr
- )
- }
- def PrefixExpr = rule { optional(WL ~ anyOf("-+~!")) ~ SimpleExpr }
-
- def SimpleExpr: R0 = rule {
- SimpleExpr1 ~
- zeroOrMore(WL ~ ('.' ~ Id | TypeArgs | ArgumentExprs)) ~
- optional(WL ~ "_")
- }
-
- def SimpleExpr1 = rule{
- K.W("new") ~ (ClassTemplate | TemplateBody) |
- BlockExpr |
- Literal |
- Path |
- K.W("_") |
- '(' ~ optional(Exprs) ~ ")"
- }
-
-
-
- def Exprs: R0 = rule { oneOrMore(Expr).separatedBy(',') }
- def ArgumentExprs: R0 = rule {
- '(' ~ optional(Exprs ~ optional(K.O(":") ~ K.W("_") ~ '*')) ~ ")" |
- optional(Newline) ~ BlockExpr
- }
-
- def BlockExpr: R0 = rule { '{' ~ (CaseClauses | Block) ~ "}" }
- def BlockEnd: R0 = rule{ optional(Semis) ~ &("}" | "case") }
- def Block: R0 = rule {
- optional(Semis) ~
- (
- BlockStats ~ optional(Semis ~ ResultExpr) ~ BlockEnd |
- ResultExpr ~ BlockEnd |
- MATCH ~ BlockEnd
- )
- }
- def BlockStats: R0 = rule{
- oneOrMore(BlockStat).separatedBy(Semis)
- }
- def BlockStat: R0 = rule {
- Import |
- zeroOrMore(Annotation) ~ (optional(K.W("implicit") | K.W("lazy")) ~ Def | zeroOrMore(LocalModifier) ~ TmplDef) |
- Expr1
- }
- def ResultExpr: R0 = rule {
- (Bindings | optional(K.W("implicit")) ~ Id | "_") ~ K.W("=>") ~ Block | Expr1
- }
- def Enumerators: R0 = rule { Generator ~ zeroOrMore(Semi ~ Enumerator) ~ WL }
- def Enumerator: R0 = rule { Generator | Guard | Pattern1 ~ K.O("=") ~ Expr }
- def Generator: R0 = rule { Pattern1 ~ K.O("<-") ~ Expr ~ optional(WL ~ Guard) }
- def CaseClauses: R0 = rule { oneOrMore(CaseClause) }
- def CaseClause: R0 = rule { K.W("case") ~ Pattern ~ optional(Guard) ~ K.O("=>") ~ Block }
- def Guard: R0 = rule { K.W("if") ~ PostfixExpr }
- def Pattern: R0 = rule {
- oneOrMore(Pattern1).separatedBy('|')
- }
- def Pattern1: R0 = rule {
- K.W("_") ~ K.O(":") ~ TypePat | VarId ~ K.O(":") ~ TypePat | Pattern2
- }
- def Pattern2: R0 = rule {
- VarId ~ "@" ~ Pattern3 | Pattern3 | VarId
- }
- def Pattern3: R0 = rule {
- SimplePattern ~ zeroOrMore(Id ~ SimplePattern)
- }
- def SimplePattern: R0 = rule {
- K.W("_") |
- Literal |
- '(' ~ optional(Patterns) ~ ')' |
- (
- StableId ~
- optional(
- '(' ~
- (optional(Patterns ~ ',') ~ optional(VarId ~ '@') ~ K.W("_") ~ '*' | optional(Patterns)) ~
- ')'
- )
- ) |
- VarId
- }
- def Patterns: R0 = rule { K.W("_") ~ '*' | oneOrMore(Pattern).separatedBy(',') }
-
- def TypeParamClause: R0 = rule { '[' ~ oneOrMore(VariantTypeParam).separatedBy(',') ~ ']' }
- def FunTypeParamClause: R0 = rule { '[' ~ oneOrMore(TypeParam).separatedBy(',') ~ ']' }
- def VariantTypeParam: R0 = rule { zeroOrMore(Annotation) ~ optional(anyOf("+-")) ~ TypeParam }
- def TypeParam: R0 = rule {
- (Id | K.W("_")) ~
- optional(TypeParamClause) ~
- optional(K.O(">:") ~ Type) ~
- optional(K.O("<:") ~ Type) ~
- zeroOrMore(K.O("<%") ~ Type) ~
- zeroOrMore(K.O(":") ~ Type)
- }
- def ParamClauses: R0 = rule { zeroOrMore(ParamClause) ~ optional(optional(Newline) ~ '(' ~ K.W("implicit") ~ Params ~ ')') }
- def ParamClause: R0 = rule { optional(Newline) ~ '(' ~ optional(Params) ~ ')' }
- def Params: R0 = rule { zeroOrMore(Param).separatedBy(',') }
- def Param: R0 = rule { zeroOrMore(Annotation) ~ Id ~ optional(K.O(":") ~ ParamType) ~ optional(K.O("=") ~ Expr) }
- def ClassParamClauses: R0 = rule { zeroOrMore(ClassParamClause) ~ optional(optional(Newline) ~ '(' ~ K.W("implicit") ~ ClassParam ~ ")") }
- def ClassParamClause: R0 = rule { optional(Newline) ~ '(' ~ optional(ClassParams) ~ ")" }
- def ClassParams: R0 = rule { oneOrMore(ClassParam).separatedBy(',') }
- def ClassParam: R0 = rule { zeroOrMore(Annotation) ~ optional(zeroOrMore(Modifier) ~ (K.W("val") | K.W("var"))) ~ Id ~ K.O(":") ~ ParamType ~ optional(K.O("=") ~ Expr) }
-
- def Bindings: R0 = rule { '(' ~ zeroOrMore(Binding).separatedBy(',') ~ ')' }
- def Binding: R0 = rule { (Id | K.W("_")) ~ optional(K.O(":") ~ Type) }
-
- def Modifier: R0 = rule { LocalModifier | AccessModifier | K.W("override") }
- def LocalModifier: R0 = rule { K.W("abstract") | K.W("final") | K.W("sealed") | K.W("implicit") | K.W("lazy") }
- def AccessModifier: R0 = rule { (K.W("private") | K.W("protected")) ~ optional(AccessQualifier) }
- def AccessQualifier: R0 = rule { '[' ~ (K.W("this") | Id) ~ ']' }
-
- def Annotation: R0 = rule { '@' ~ SimpleType ~ zeroOrMore(WL ~ ArgumentExprs) }
- def ConstrAnnotation: R0 = rule { '@' ~ SimpleType ~ ArgumentExprs }
-
- def TemplateBody: R0 = rule {
- '{' ~
- optional(SelfType) ~
- zeroOrMore(TemplateStat).separatedBy(Semis) ~
- '}'
- }
- def TemplateStat: R0 = rule {
- Import |
- zeroOrMore(Annotation ~ optional(Newline)) ~ zeroOrMore(Modifier) ~ (Def | Dcl) |
- Expr
- }
-
- def SelfType: R0 = rule { K.W("this") ~ K.O(":") ~ Type ~ K.O("=>") | Id ~ optional(K.O(":") ~ Type) ~ K.O("=>") }
-
- def Import: R0 = rule { K.W("import") ~ oneOrMore(ImportExpr).separatedBy(',') }
-
- def ImportExpr: R0 = rule {
- StableId ~ optional('.' ~ ("_" | ImportSelectors))
- }
- def ImportSelectors: R0 = rule { '{' ~ zeroOrMore(ImportSelector ~ ',') ~ (ImportSelector | K.W("_")) ~ "}" }
- def ImportSelector: R0 = rule { Id ~ optional(K.O("=>") ~ (Id | K.W("_"))) }
-
- def Dcl: R0 = rule {
- K.W("val") ~ ValDcl |
- K.W("var") ~ VarDcl |
- K.W("def") ~ FunDcl |
- K.W("type") ~ zeroOrMore(Newline) ~ TypeDcl
- }
- def ValDcl: R0 = rule { Ids ~ K.O(":") ~ Type }
- def VarDcl: R0 = rule { Ids ~ K.O(":") ~ Type }
- def FunDcl: R0 = rule { FunSig ~ optional(WL ~ K.O(":") ~ Type) }
- def FunSig: R0 = rule { Id ~ optional(FunTypeParamClause) ~ ParamClauses }
- def TypeDcl: R0 = rule {
- Id ~
- optional(WL ~ TypeParamClause) ~
- optional(WL ~ K.O(">:") ~ Type) ~
- optional(WL ~ K.O("<:") ~ Type)
- }
-
- def PatVarDef: R0 = rule { K.W("val") ~ PatDef | K.W("var") ~ VarDef }
- def Def: R0 = rule { K.W("def") ~ FunDef | K.W("type") ~ zeroOrMore(Newline) ~ TypeDef | PatVarDef | TmplDef }
- def PatDef: R0 = rule { oneOrMore(Pattern2).separatedBy(',') ~ optional(K.O(":") ~ Type) ~ K.O("=") ~ Expr }
- def VarDef: R0 = rule { Ids ~ K.O(":") ~ Type ~ K.O("=") ~ K.W("_") | PatDef }
- def FunDef: R0 = rule {
- K.W("this") ~ ParamClause ~ ParamClauses ~ (K.O("=") ~ ConstrExpr | optional(Newline) ~ ConstrBlock) |
- FunSig ~
- (
- optional(K.O(":") ~ Type) ~ K.O("=") ~ optional(K.W("macro")) ~ Expr |
- optional(Newline) ~ '{' ~ Block ~ "}"
- )
- }
- def TypeDef: R0 = rule { Id ~ optional(TypeParamClause) ~ K.O("=") ~ Type }
-
- def TmplDef: R0 = rule {
- K.W("trait") ~ TraitDef |
- optional(K.W("case")) ~ (K.W("class") ~ ClassDef |
- K.W("object") ~ ObjectDef)
- }
- def ClassDef: R0 = rule {
- Id ~
- optional(TypeParamClause) ~
- zeroOrMore(ConstrAnnotation) ~
- optional(AccessModifier) ~
- ClassParamClauses ~
- ClassTemplateOpt
- }
- def TraitDef: R0 = rule { Id ~ optional(TypeParamClause) ~ TraitTemplateOpt }
- def ObjectDef: R0 = rule { Id ~ ClassTemplateOpt }
- def ClassTemplateOpt: R0 = rule {
- WL ~ K.W("extends") ~ ClassTemplate |
- optional(WL ~ optional(K.W("extends")) ~ TemplateBody)
- }
- def TraitTemplateOpt: R0 = rule { K.W("extends") ~ TraitTemplate | optional(optional(K.W("extends")) ~ TemplateBody) }
- def ClassTemplate: R0 = rule {
- optional(EarlyDefs) ~
- ClassParents ~
- optional(WL ~ TemplateBody)
- }
-
- def TraitTemplate: R0 = rule {
- optional(EarlyDefs) ~ TraitParents ~ optional(TemplateBody)
- }
- def ClassParents: R0 = rule {
- Constr ~ zeroOrMore(WL ~ K.W("with") ~ AnnotType)
- }
- def TraitParents: R0 = rule {
- AnnotType ~ zeroOrMore(WL ~ K.W("with") ~ AnnotType)
- }
- def Constr: R0 = rule {
- AnnotType ~ zeroOrMore(WL ~ ArgumentExprs)
- }
- def EarlyDefs: R0 = rule {
- '{' ~ optional(oneOrMore(EarlyDef).separatedBy(Semis)) ~ '}' ~ K.W("with")
- }
- def EarlyDef: R0 = rule {
- zeroOrMore(Annotation ~ optional(Newline)) ~ zeroOrMore(Modifier) ~ PatVarDef
- }
- def ConstrExpr: R0 = rule { ConstrBlock | SelfInvocation }
- def ConstrBlock: R0 = rule { '{' ~ SelfInvocation ~ zeroOrMore(Semis ~ BlockStat) ~ '}' }
- def SelfInvocation: R0 = rule { K.W("this") ~ oneOrMore(ArgumentExprs) }
-
- def TopStatSeq: R0 = rule { oneOrMore(TopStat).separatedBy(Semis) }
- def TopStat: R0 = rule {
- Packaging |
- PackageObject |
- Import |
- zeroOrMore(Annotation ~ optional(Newline)) ~ zeroOrMore(Modifier) ~ TmplDef
- }
- def Packaging: R0 = rule { K.W("package") ~ QualId ~ '{' ~ TopStatSeq ~ '}' }
- def PackageObject: R0 = rule { K.W("package") ~ K.W("object") ~ ObjectDef }
- def TopPackageSeq: R0 = rule{
- oneOrMore(K.W("package") ~ QualId).separatedBy(Semis)
- }
- def CompilationUnit: Rule1[String] = rule {
- capture(
- pr("CompulationUnit 0") ~
- optional(Semis) ~
- pr("CompulationUnit 1") ~
- (TopPackageSeq ~ optional(Semis ~ TopStatSeq) | TopStatSeq) ~
- optional(Semis) ~
- WL
-
- )
- }
-}
diff --git a/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Basic.scala b/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Basic.scala
deleted file mode 100644
index 8d3232a..0000000
--- a/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Basic.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-package scalaParser
-package syntax
-import acyclic.file
-import org.parboiled2._
-
-trait Basic { self: Parser =>
- object Basic{
- def UnicodeExcape = rule { "\\u" ~ 4.times(HexDigit) }
-
-
- //Numbers and digits
- def HexDigit = rule { Digit | "a" - "f" | "A" - "Z" }
- def Digit = rule { "0" | NonZeroDigit }
- def NonZeroDigit = rule { "1" - "9" }
- def HexNumeral = rule { "0x" ~ oneOrMore(HexDigit) }
- def DecimalNumeral = rule(oneOrMore(Digit))
- def ExponentPart = rule { anyOf("Ee") ~ optional(anyOf("+-")) ~ oneOrMore(Digit) }
- def FloatType = rule { anyOf("FfDd") }
-
- def Parentheses = rule { "(" | ")" | "[" | "]" | "{" | "}" }
- def DelimiterChar = rule { "'" | "\"" | "." | ";" | "," }
-
- def WhitespaceChar = rule { "\u0020" | "\u0009" }
- def Newline = rule { "\r\n" | "\n" }
- def Semi = rule { ';' | oneOrMore(Newline) }
- def OperatorChar = rule {
- anyOf("""!#$%&*+-/:<=>?@\^|~""") |
- CharPredicate.from(_.getType match {
- case Character.OTHER_SYMBOL | Character.MATH_SYMBOL => true; case _ => false
- })
- }
- def Letter = rule { Upper | Lower | CharPredicate.from(c => c.isLetter | c.isDigit) }
- def Lower = rule { "a" - "z" | "$" | "_" | CharPredicate.from(_.isLower) }
- def Upper = rule { "A" - "Z" | CharPredicate.from(_.isUpper) }
- }
- /**
- * Most keywords don't just require the correct characters to match,
- * they have to ensure that subsequent characters *don't* match in
- * order for it to be a keyword. This enforces that rule for key-words
- * (W) and key-operators (O) which have different non-match criteria.
- */
- object Key {
- def W(s: String) = rule {
- str(s) ~ !(Basic.Letter | Basic.Digit)
- }
-
- def O(s: String) = rule {
- str(s) ~ !Basic.OperatorChar
- }
- }
-}
diff --git a/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala b/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala
deleted file mode 100644
index 4bc972f..0000000
--- a/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala
+++ /dev/null
@@ -1,35 +0,0 @@
-package scalaParser
-package syntax
-import acyclic.file
-import org.parboiled2._
-
-trait Identifiers { self: Parser with Basic =>
- object Identifiers{
- import Basic._
- def Operator = rule(oneOrMore(OperatorChar))
-
- def VarId = rule {
- !(Keywords ~ (WhitespaceChar | Newline | "//" | "/*")) ~ Lower ~ IdRest
- }
- def PlainId = rule { Upper ~ IdRest | VarId | !(Keywords ~ (WhitespaceChar | Newline | "//" | "/*")) ~ Operator }
- def Id = rule { PlainId | ("`" ~ oneOrMore(noneOf("`")) ~ "`") }
- def IdRest = rule {
- zeroOrMore(zeroOrMore("_") ~ oneOrMore(!"_" ~ Letter | Digit)) ~
- optional(oneOrMore("_") ~ optional(Operator))
- }
-
-
- def AlphabetKeywords = rule {
- "abstract" | "case" | "catch" | "class" | "def" | "do" | "else" | "extends" | "false" | "finally" | "final" | "finally" | "forSome" | "for" | "if" |
- "implicit" | "import" | "lazy" | "match" | "new" | "null" | "object" | "override" | "package" | "private" | "protected" | "return" |
- "sealed" | "super" | "this" | "throw" | "trait" | "try" | "true" | "type" | "val" | "var" | "while" | "with" | "yield" | "_"
- }
- def SymbolicKeywords = rule{
- ":" | ";" | "=>" | "=" | "<-" | "<:" | "<%" | ">:" | "#" | "@" | "\u21d2" | "\u2190"
- }
- def Keywords = rule {
- AlphabetKeywords ~ !Letter | SymbolicKeywords ~ !OperatorChar
-
- }
- }
-}
diff --git a/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Literals.scala b/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Literals.scala
deleted file mode 100644
index 9fd9d5b..0000000
--- a/scalatex/scalaParser/src/main/scala/scalaParser/syntax/Literals.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-package scalaParser
-package syntax
-import acyclic.file
-import org.parboiled2._
-
-trait Literals { self: Parser with Basic with Identifiers =>
- object Literals{
- import Basic._
- def FloatingPointLiteral = rule {
-
- "." ~ oneOrMore(Digit) ~ optional(ExponentPart) ~ optional(FloatType) |
- oneOrMore(Digit) ~ (
- "." ~ oneOrMore(Digit) ~ optional(ExponentPart) ~ optional(FloatType) |
- ExponentPart ~ optional(FloatType) |
- optional(ExponentPart) ~ FloatType
- )
- }
-
- def IntegerLiteral = rule { (DecimalNumeral | HexNumeral) ~ optional(anyOf("Ll")) }
-
- def BooleanLiteral = rule { Key.W("true") | Key.W("false") }
-
- def MultilineComment: Rule0 = rule { "/*" ~ zeroOrMore(MultilineComment | !"*/" ~ ANY) ~ "*/" }
- def Comment: Rule0 = rule {
- MultilineComment |
- "//" ~ zeroOrMore(!Basic.Newline ~ ANY) ~ &(Basic.Newline | EOI)
- }
-
- def Literal = rule {
- (optional("-") ~ (FloatingPointLiteral | IntegerLiteral)) |
- BooleanLiteral |
- CharacterLiteral |
- StringLiteral |
- SymbolLiteral |
- (Key.W("null") ~ !(Basic.Letter | Basic.Digit))
- }
-
-
- def EscapedChars = rule { '\\' ~ anyOf("rnt\\\"") }
-
- // Note that symbols can take on the same values as keywords!
- def SymbolLiteral = rule { ''' ~ (Identifiers.PlainId | Identifiers.Keywords) }
-
- def CharacterLiteral = rule { ''' ~ (UnicodeExcape | EscapedChars | !'\\' ~ CharPredicate.from(isPrintableChar)) ~ ''' }
-
- def MultiLineChars = rule { zeroOrMore(optional('"') ~ optional('"') ~ noneOf("\"")) }
- def StringLiteral = rule {
- (optional(Identifiers.Id) ~ "\"\"\"" ~ MultiLineChars ~ ("\"\"\"" ~ zeroOrMore('"'))) |
- (optional(Identifiers.Id) ~ '"' ~ zeroOrMore("\\\"" | noneOf("\n\"")) ~ '"')
- }
-
- def isPrintableChar(c: Char): Boolean = {
- val block = Character.UnicodeBlock.of(c)
- !Character.isISOControl(c) && !Character.isSurrogate(c) && block != null && block != Character.UnicodeBlock.SPECIALS
- }
- }
-}
-
diff --git a/scalatex/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala b/scalatex/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala
deleted file mode 100644
index fe5fc2c..0000000
--- a/scalatex/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala
+++ /dev/null
@@ -1,448 +0,0 @@
-package scalaParser
-
-import org.parboiled2.ParseError
-import utest._
-import utest.framework.Test
-import utest.util.Tree
-
-import scala.util.{Failure, Success}
-
-object SyntaxTest extends TestSuite{
- def check[T](input: String) = {
- println("Checking...")
- new ScalaSyntax(input).CompilationUnit.run() match{
- case Failure(f: ParseError) =>
- println(f.position)
- println(f.formatExpectedAsString)
- println(f.formatTraces)
- throw new Exception(f.position + "\t" + f.formatTraces)
- case Success(parsed) =>
- assert(parsed == input)
- }
- }
- println("running")
- def tests = TestSuite{
- 'unit {
- * - check(
- "package torimatomeru"
-
- )
- * - check(
- """package torimatomeru
- |
- |package lols
- """.stripMargin
- )
- * - check(
- """package torimatomeru
- |import a
- |import b
- """.stripMargin
- )
- * - check(
- """
- |package torimatomeru
- |
- |import org.parboiled2.ParseError
- |import utest._
- |import utest.framework.Test
- |import utest.util.Tree
- |
- |import scala.util.{Failure, Success}
- |
- |object SyntaxTest extends TestSuite
- """.stripMargin
- )
- * - check(
- """
- |object SyntaxTest extends TestSuite{
- | def check[T](input: String) = {
- |
- | }
- |}
- """.stripMargin
- )
- * - check(
- """
- |object SyntaxTest{
- | a()
- | throw 1
- |}
- """.stripMargin
- )
- * - check(
- """
- |object SyntaxTest extends TestSuite{
- | {
- | println
- | throw 1
- | }
- |}
- """.stripMargin
- )
- * - check(
- """package scalatex
- |
- |
- |import org.parboiled2._
- |import torimatomeru.ScalaSyntax
- |
- |import scalatex.stages.{Trim, Parser, Ast}
- |import scalatex.stages.Ast.Block.{IfElse, For, Text}
- |import Ast.Chain.Args
- |
- |object ParserTests extends utest.TestSuite{
- | import Ast._
- | import utest._
- | def check[T](input: String, parse: Parser => scala.util.Try[T], expected: T) = {
- | val parsed = parse(new Parser(input)).get
- | assert(parsed == expected)
- | }
- | def tests = TestSuite{}
- |}
- """.stripMargin
- )
- * - check(
- """
- |object Moo{
- | a
- | .b
- |
- | c
- |}
- """.stripMargin
- )
- * - check(
- """
- |object Moo{
- | filename
- | .asInstanceOf[Literal]
- |10
- |}
- """.stripMargin
- )
- * - check(
- """
- |object Cow{
- | ().mkString
- |
- | 1
- |}
- """.stripMargin
- )
- * - check(
- """
- |object O{
- | private[this] val applyMacroFull = 1
- |}
- """.stripMargin
- )
- * - check(
- """
- |object O{
- | private[this] def applyMacroFull(c: Context)
- | (expr: c.Expr[String],
- | runtimeErrors: Boolean,
- | debug: Boolean)
- | : c.Expr[Frag] = {
- | }
- |}
- """.stripMargin
- )
- * - check(
- """
- |object O{
- | class DebugFailure extends Exception
- |
- | 1
- |}
- """.stripMargin
- )
- * - check(
- """
- |package torimatomeru
- |
- |package syntax
- |
- |import org.parboiled2._
- |
- """.stripMargin
- )
- * - check(
- """
- |object Foo{
- | 0 match {
- | case A | B => 0
- | }
- |}
- """.stripMargin
- )
- * - check(
- """
- |object Compiler{
- |
- | def apply = {
- | def rec = t match {
- | case 0 => 0
- | }
- |
- | rec(tree)
- | }
- |}
- |
- """.stripMargin
- )
- * - check(
- """
- |object O {
- | A(A(A(A(A(A(A(A())))))))
- |}
- |
- """.stripMargin
- )
- * - check(
- """
- |object O{
- | A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A())))))))))))))))
- |}
- """.stripMargin
- )
- * - check(
- """
- |object L{
- | a.b = c
- | a().b = c
- |}
- """.stripMargin
- )
- * - check(
- """
- |object L{
- | a b c
- | d = 1
- |}
- """.stripMargin
- )
-
- * - check(
- """/* __ *\
- |** ________ ___ / / ___ __ ____ Scala.js CLI **
- |** / __/ __// _ | / / / _ | __ / // __/ (c) 2013-2014, LAMP/EPFL **
- |** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
- |** /____/\___/_/ |_/____/_/ | |__/ /____/ **
- |** |/____/ **
- |\* */
- |
- |package scala.scalajs.cli
- |
- """.stripMargin
- )
- * - check(
- """
- |object O{
- | for {
- | a <- b
- | c <- d
- | } {
- | 1
- | }
- |}
- """.stripMargin
- )
- * - check(
- """
- |object O{
- | val jarFile =
- | try { 1 }
- | catch { case _: F => G }
- |}
- """.stripMargin
- )
- * - check(
- """
- |object F{
- | func{ case _: F => fail }
- |}
- """.stripMargin
- )
- * - check(
- """
- |object Foo{
- | val a = d // g
- | val b = e // h
- | val c = f
- |}
- """.stripMargin
- )
- * - check(
- """
- |object L{
- | x match{
- | case y.Y(z) => z
- | }
- |}
- """.stripMargin
- )
- * - check(
- """object K{
- | val a: B {
- | val c: D
- | }
- |
- | 1
- |}
- """.stripMargin
- )
- * - check(
- """
- |object LOLS{
- | def run() {}
- |
- | def apply() {}
- |}
- """.stripMargin
- )
- * - check(
- """
- |object O{
- | a =:= b.c
- |}
- """.stripMargin
- )
- * - check(
- """
- |object K{
- | a(
- | 1: _*
- | )
- |}
- """.stripMargin
- )
- * - check(
- """
- |object P{
- | tree match {
- | case stats :+ expr => 1
- | }
- |}
- """.stripMargin
- )
- * - check(
- """
- |object K{
- | val trueA = 1
- |}
- """.stripMargin
- )
- * - check(
- """
- |object K{
- | val nullo :: cow = 1
- |}
- """.stripMargin
- )
- * - check(
- """
- |object K{
- | val omg_+ = 1
- |}
- """.stripMargin
- )
- * - check(
- """
- |object K{
- | val + = 1
- | var * = 2
- |}
- """.stripMargin
- )
- * - check(
- """
- |object O{
- | c match {
- | case b_ => 1
- | }
- |}
- """.stripMargin
- )
- * - check(
- """
- |trait Basic {
- | b match {
- | case C => true; case _ => false
- | }
- |}
- """.stripMargin
- )
- * - check(
- """trait Basic {
- | !a.b
- |}
- """.stripMargin
- )
- * - check(
- """
- |class Parser {
- | {() => }
- |}
- |
- """.stripMargin
- )
- * - check(
- """
- |
- |
- |
- |package omg
- |;
- |
- |;
- |
- |;
- |class Parser
- |;
- |
- |;
- |
- |;
- """.stripMargin
- )
- }
- def checkFile(path: String) = check(io.Source.fromFile(path).mkString)
- 'file{
-
- * - checkFile("test.txt")
- * - checkFile("scalaParser/src/main/scala/scalaParser/syntax/Basic.scala")
- * - checkFile("scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala")
- * - checkFile("scalaParser/src/main/scala/scalaParser/syntax/Literals.scala")
- * - checkFile("scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala")
-
- * - checkFile("scalaParser/src/test/scala/scalaParser/SyntaxTest.scala")
-
-
- * - checkFile("scalatexApi/src/main/scala/scalatex/stages/Compiler.scala")
- * - checkFile("scalatexApi/src/main/scala/scalatex/stages/Parser.scala")
- * - checkFile("scalatexApi/src/main/scala/scalatex/stages/Trim.scala")
- * - checkFile("scalatexApi/src/main/scala/scalatex/package.scala")
-
- * - checkFile("scalatexApi/src/test/scala/scalatex/ParserTests.scala")
- * - checkFile("scalatexApi/src/test/scala/scalatex/BasicTests.scala")
- * - checkFile("scalatexApi/src/test/scala/scalatex/ErrorTests.scala")
- * - checkFile("scalatexApi/src/test/scala/scalatex/TestUtil.scala")
-
- * - checkFile("scalatexPlugin/src/main/scala/scalatex/ScalaTexPlugin.scala")
- }
-
-// 'omg{
-// val root = new java.io.File("../scala-js/")
-// def listFiles(s: java.io.File): Iterator[String] = {
-// val (dirs, files) = s.listFiles().toIterator.partition(_.isDirectory)
-// files.map(_.getPath) ++ dirs.flatMap(listFiles)
-// }
-// for(f <- listFiles(root).filter(_.endsWith(".scala"))){
-// println("CHECKING " + f)
-// checkFile(f)
-// }
-// }
- }
-} \ No newline at end of file
diff --git a/scalatex/scalatexSbtPlugin/src/main/scala/SbtPlugin.scala b/scalatex/scalatexSbtPlugin/src/main/scala/SbtPlugin.scala
deleted file mode 100644
index f09dc17..0000000
--- a/scalatex/scalatexSbtPlugin/src/main/scala/SbtPlugin.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-package scalatex
-
-import sbt.Keys._
-import sbt._
-object SbtPlugin extends sbt.Plugin{
- val scalatexDirectory = taskKey[sbt.File]("Clone stuff from github")
- override val settings = Seq(
- scalatexDirectory := sourceDirectory.value / "scalatex",
- scalacOptions += {
- "-P:scalatex:root:" + scalatexDirectory.value.getCanonicalPath
- },
- watchSources += scalatexDirectory.value,
- addCompilerPlugin("com.lihaoyi" %% "scalatex-compiler-plugin" % "0.1.0"),
- libraryDependencies += "com.lihaoyi" %% "scalatex-api" % "0.1.0"
- )
-}