Skip to content

Commit

Permalink
Merge b5a82ad into e1315a8
Browse files Browse the repository at this point in the history
  • Loading branch information
reid-spencer authored Nov 18, 2023
2 parents e1315a8 + b5a82ad commit 62ae6db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ private[parsing] trait ApplicationParser {
}
}

private def groupDefinitions[u: P]: P[Seq[GroupDefinition]] =
P(
undefined(Seq.empty[GroupDefinition]) |
(group | containedGroup | appOutput | appInput).rep(0)
)
private def groupDefinitions[u: P]: P[Seq[GroupDefinition]] = {
P(group | containedGroup | appOutput | appInput).rep(1)
}

private def group[u: P]: P[Group] = {
P(
location ~ groupAliases ~ identifier ~/ is ~ open ~
groupDefinitions ~
(undefined(Seq.empty[GroupDefinition]) | groupDefinitions) ~
close ~ briefly ~ description
).map { case (loc, alias, id, elements, brief, description) =>
Group(loc, alias, id, elements, brief, description)
Expand All @@ -62,7 +60,9 @@ private[parsing] trait ApplicationParser {

private def outputDefinitions[u: P]: P[Seq[OutputDefinition]] = {
P(
is ~ open ~ appOutput.rep(1) ~ close
is ~ open ~
(undefined(Seq.empty[OutputDefinition]) | appOutput.rep(1)) ~
close
).?.map {
case Some(definitions) => definitions
case None => Seq.empty[OutputDefinition]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@ import org.scalatest.matchers.must.Matchers
class ApplicationParsingTest extends ParsingTest with Matchers {

"Application Components" must {
"empty definitions should fail" in {
"nested empty definitions should fail" in {
val input =
"""
|domain foo {
|application foo2 {
| group {}
| group g1 is { ??? }
| group g2 is {
| group g3 is { ??? }
| input i1 acquires String is { ??? }
| output o1 displays String is { ??? }
| }
|}
|}""".stripMargin
parseDefinition[Domain](input) match {
case Left(messages: Messages) =>
val errors = messages.justErrors
errors.size mustBe 1
val msg = errors.head
msg.message contains "Expected one of"
msg.message contains "???"
msg.loc.line mustBe 4

fail(messages.format)
case Right((dom: Domain, _)) =>
fail("should have required ??? syntax")
succeed
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class RunRiddlcOnArbitraryTest extends RunCommandSpecBase {
val config = "design/src/main/riddl/ksoapp.conf"
validateLocalProject(cwd, config)
}
// FIXME: Fix Improving.app syntax and renable
// FIXME: Fix Improving.app syntax and re-enable
// "validate Improving.app" in {
// val cwd = "/Users/reid/Code/improving.app/riddl"
// val config = "src/main/riddl/ImprovingApp.conf"
Expand Down

0 comments on commit 62ae6db

Please sign in to comment.