Skip to content

Commit

Permalink
Fix build (#190)
Browse files Browse the repository at this point in the history
* Fix xml preprocessor related tests (`<?xml-stylesheet`)

* Attempt to fix native target tests

* Fixed entity handling.

* Fixing symbolic keyword definition

It was not considering the comments after them. Added test too.
  • Loading branch information
aborg0 authored and lihaoyi committed Jul 20, 2018
1 parent 3a1b33e commit 3bc8788
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ matrix:
- env:
- CI_SCRIPT: '"fastparseNative/test; fastparseByteNative/test; scalaparseNative/test; pythonparseNative/test; cssparseNative/test "'
before_install:
- curl https://raw.githubusercontent.com/scala-native/scala-native/master/bin/travis_setup.sh | bash -x
- curl https://raw.githubusercontent.com/scala-native/scala-native/master/scripts/travis_setup.sh | bash -x
scala: 2.11.11
jdk: oraclejdk8

Expand Down
4 changes: 2 additions & 2 deletions scalaparse/shared/src/main/scala/scalaparse/Xml.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ trait Xml extends Core {
val ComText = P( (!"--" ~ Char).rep ~ ("-" ~ &("--")).? )

val PI = P( "<?" ~ PITarget ~ PIProcText.? ~ "?>" )
val PITarget = P( !(("X" | "x") ~ ("M" | "m") ~ ("L" | "l")) ~ Name )
val PITarget = P( !(("X" | "x") ~ ("M" | "m") ~ ("L" | "l") ~ ("?>" | Basic.WSChars | Basic.Newline)) ~ Name )
val PIProcText = P( WL ~ (!"?>" ~ Char).rep )

val Reference = P( EntityRef | CharRef )
val EntityRef = P( "&" ~ Name ~/ ";" )
val CharRef = P( "&#" ~ Num ~/ ";" | "&#x" ~ HexNum ~/ ";" )
val CharRef = P( ("&#x" ~ HexNum ~/ ";") | ("&#" ~ Num ~/ ";") )
val Num = P( CharIn('0' to '9').rep )
val HexNum = P( CharIn('0' to '9', 'a' to 'f', 'A' to 'F').rep )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object Identifiers{
)

val SymbolicKeywords = P{
StringIn(symbolKeywords:_*) ~ !OpChar
StringIn(symbolKeywords:_*) ~ (!OpChar | &("//" | "/*"))
}

val keywords = alphaKeywords ++ symbolKeywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1504,5 +1504,60 @@ object SuccessTests extends TestSuite{
| } yield a
|}""".stripMargin
)
* - check(
"""
|object foo {
| val bar = "baz"
| val xml =
| <?xml-stylesheet href="style.xslt" type="text/xsl"?>
| <root>
| <?foo {bar}?>
| </root>
|}""".stripMargin
)
* - check(
"""
|object foo {
| val xml =
| <?xaml-stylesheet href="style.xslt" type="text/xsl"?>
| <root>
| </root>
|}""".stripMargin
)
* - check(
"""
|object foo {
| val bar = "baz"
| val xml =
| <root>
| &amp; &quot; &#x27; &#123; &lt; &gt;
| </root>
|}""".stripMargin
)
* - check(
"""
|class Ping {
|
| val pong = new Pong(this)
|
| def name = "ping"
|
| def loop: Unit =/*?*/ { poke() }
|
| def poke: Unit =/*?*/ { pong./*!*/poke() }
|
| override def toString = name
| }
|
|class Pong(ping: Ping) {
|
| val name/*?*/ = "pong"
|
| def poke(): Unit = { ping./*!*/poke() }
|
| override def toString = name
| }
|""".stripMargin
)
}
}

0 comments on commit 3bc8788

Please sign in to comment.