Skip to content
This repository has been archived by the owner on Sep 12, 2021. It is now read-only.

Commit

Permalink
fixed scheme identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
adamalix committed Dec 12, 2011
1 parent dc27785 commit e316231
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
@@ -1,7 +1,7 @@
// CPB.cs4500 build settings // CPB.cs4500 build settings
name := "cs4500" name := "cs4500"


version := "0.1" version := "0.8"


organization := "com.cpb" organization := "com.cpb"


Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/com/cpb/cs4500/parsing/ADTParser.scala
Expand Up @@ -123,8 +123,9 @@ package com.cpb.cs4500.parsing {
// Modified version of Scala's JavaTokenParser.stringLiteral // Modified version of Scala's JavaTokenParser.stringLiteral
// Removed requirement of enclosing in double quotes, and ability to // Removed requirement of enclosing in double quotes, and ability to
// read white space. now reads strings containing unicode characters // read white space. now reads strings containing unicode characters
def schIdent : Parser[String] = ( // don't begin with - or : to avoid ambiguities
"""[a-zA-Z=*+/<>!\?\\u[a-fA-F0-9]{4}][a-zA-Z0-9=*+/<>!\?\\u[a-fA-F0-9]{4}]*""".r ^^ def schIdent: Parser[String] = (
"""([a-zA-Z=*+/<>!\?]|[_\p{L}][_\p{L}\p{Nd}]*)([a-zA-Z0-9=*+/<>!\?\-]|[_\p{L}][_\p{L}\p{Nd}]*)*""".r ^^
{ case schemeIdent => schemeIdent } { case schemeIdent => schemeIdent }
) )


Expand Down
44 changes: 44 additions & 0 deletions src/test/scala/com/cpb/cs4500/parsing/TestParse.scala
Expand Up @@ -309,6 +309,50 @@ package com.cpb.cs4500.parsing {
} }
} }


test("test schIdent") {
expect(true) {
val weird1 = "\u00FDasdf-asdf"
val weird2 = "?a"
val weird3 = "!b?"
val weird4 = "c--"
val weird5 = "asdf\u0173asfd"
val weird6 = "d-8"
val weird7 = "asdf8-a?\u00FD"
val weirdStrings = List(weird1, weird2, weird3, weird4, weird5, weird6, weird7)
for (weird <- weirdStrings) {
parser.parseAll(parser.schIdent, weird) match {
case parser.Success(result, _) =>
case parser.Failure(msg, _) =>
throw new RuntimeException("failed parsing: " + weird)
case parser.Error(_, _) =>
throw new RuntimeException("error parsing: " + weird)
}
}
true
}

expect(true) {
val fail1 = "-a"
val fail2 = "8b"
val fail3 = "88b"
val fail4 = "->"
val fail5 = ":"
val fail6 = "-?asdf8-a?"
val failStrings = List(fail1, fail2, fail3, fail4, fail5, fail6)
for (fail <- failStrings) {
parser.parseAll(parser.schIdent, fail) match {
case parser.Success(result, _) =>
throw new RuntimeException("Succeeded parsing: " + fail)
case parser.Failure(msg, _) =>
case parser.Error(_, _) =>
throw new RuntimeException("error parsing: " + fail)
}
}
true
}

}

test("parseTestSpecs") { test("parseTestSpecs") {
for (testFile <- testFileList) { for (testFile <- testFileList) {
expect(true) { expect(true) {
Expand Down

0 comments on commit e316231

Please sign in to comment.