diff --git a/build.sbt b/build.sbt index 230f2d1..044526a 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ // CPB.cs4500 build settings name := "cs4500" -version := "0.1" +version := "0.8" organization := "com.cpb" diff --git a/src/main/scala/com/cpb/cs4500/parsing/ADTParser.scala b/src/main/scala/com/cpb/cs4500/parsing/ADTParser.scala index 3217ef6..9702698 100644 --- a/src/main/scala/com/cpb/cs4500/parsing/ADTParser.scala +++ b/src/main/scala/com/cpb/cs4500/parsing/ADTParser.scala @@ -123,8 +123,9 @@ package com.cpb.cs4500.parsing { // Modified version of Scala's JavaTokenParser.stringLiteral // Removed requirement of enclosing in double quotes, and ability to // read white space. now reads strings containing unicode characters - def schIdent : Parser[String] = ( - """[a-zA-Z=*+/<>!\?\\u[a-fA-F0-9]{4}][a-zA-Z0-9=*+/<>!\?\\u[a-fA-F0-9]{4}]*""".r ^^ + // don't begin with - or : to avoid ambiguities + 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 } ) diff --git a/src/test/scala/com/cpb/cs4500/parsing/TestParse.scala b/src/test/scala/com/cpb/cs4500/parsing/TestParse.scala index 475f9b3..9c1695a 100644 --- a/src/test/scala/com/cpb/cs4500/parsing/TestParse.scala +++ b/src/test/scala/com/cpb/cs4500/parsing/TestParse.scala @@ -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") { for (testFile <- testFileList) { expect(true) {