Skip to content

Commit

Permalink
Make app and epic syntax more palatable
Browse files Browse the repository at this point in the history
You can now you various aliases for "input", "output" and "group".
These are recognized in both the Application definition and in
their use in epic case steps

Signed-off-by: reidspencer <reid.spencer@yoppworks.com>
  • Loading branch information
reid-spencer committed Oct 3, 2023
1 parent c8d0eaa commit 7047b74
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@ private[parsing] trait ApplicationParser {
with ReferenceParser
with HandlerParser
with StatementParser
with TypeParser =>
with TypeParser
with CommonParser =>

private def applicationOptions[u: P]: P[Seq[ApplicationOption]] = {
options[u, ApplicationOption](StringIn(Options.technology).!) { case (loc, Options.technology, args) =>
ApplicationTechnologyOption(loc, args)
}
}

private def groupAliases[u: P]: P[String] = {
P(
StringIn(Keywords.group, "page", "pane", "dialog", "popup", "frame", "column", "window", "section", "tab").!
)
}

private def groupDefinitions[u:P]: P[Seq[GroupDefinition]] = {
private def groupDefinitions[u: P]: P[Seq[GroupDefinition]] = {
P {
undefined(Seq.empty[GroupDefinition]) | (group | appOutput | appInput).rep(0)
}
Expand All @@ -40,27 +35,13 @@ private[parsing] trait ApplicationParser {
private def group[u: P]: P[Group] = {
P(
location ~ groupAliases ~ identifier ~/ is ~ open ~
groupDefinitions ~
close ~ briefly ~ description
groupDefinitions ~
close ~ briefly ~ description
).map { case (loc, alias, id, elements, brief, description) =>
Group(loc, alias, id, elements, brief, description)
}
}

private def outputAliases[u: P]: P[String] = {
P(
StringIn(
Keywords.output,
"document",
"list",
"table",
"graph",
"animation",
"picture"
).!
)
}

private def presentationAliases[u: P]: P[Unit] = {
StringIn(Keywords.presents, "shows", "displays", "writes", "emits")
}
Expand All @@ -83,12 +64,6 @@ private[parsing] trait ApplicationParser {
}
}

private def inputAliases[u: P]: P[String] = {
P(
StringIn(Keywords.input, "form", "textblock", "button", "picklist").!
)
}

private def inputDefinitions[uP: P]: P[Seq[InputDefinition]] = {
P(
is ~ open ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,31 @@ private[parsing] trait CommonParser extends NoWhiteSpaceParsers {
def term[u: P]: P[Term] = {
P(location ~ Keywords.term ~ identifier ~ is ~ briefly ~ description)./.map(tpl => (Term.apply _).tupled(tpl))
}

def groupAliases[u: P]: P[String] = {
P(
StringIn(Keywords.group, "page", "pane", "dialog", "popup", "frame", "column", "window", "section", "tab").!
)
}

def inputAliases[u: P]: P[String] = {
P(
StringIn(Keywords.input, "form", "text", "button", "picklist", "select").!
)
}

def outputAliases[u: P]: P[String] = {
P(
StringIn(
Keywords.output,
"document",
"list",
"table",
"graph",
"animation",
"picture"
).!
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,18 @@ private[parsing] trait ReferenceParser extends CommonParser {
}

def outputRef[u: P]: P[OutputRef] = {
P(location ~ Keywords.output ~ pathIdentifier)
.map(tpl => (OutputRef.apply _).tupled(tpl))
P(location ~ outputAliases ~ pathIdentifier)
.map { case (loc, _, pid) => OutputRef(loc, pid) }
}

def inputRef[u: P]: P[InputRef] = {
P(location ~ Keywords.input ~ pathIdentifier)
.map(tpl => (InputRef.apply _).tupled(tpl))
P(location ~ inputAliases ~ pathIdentifier)
.map { case (loc, _, pid) => InputRef(loc, pid) }
}

def groupRef[u:P]: P[GroupRef] = {
P(location ~ Keywords.group ~ pathIdentifier)
.map(tpl => (GroupRef.apply _).tupled(tpl))
def groupRef[u: P]: P[GroupRef] = {
P(location ~ groupAliases ~ pathIdentifier)
.map { case (loc, _, pid) => GroupRef(loc, pid) }
}

def authorRefs[u: P]: P[Seq[AuthorRef]] = {
Expand All @@ -183,11 +183,10 @@ private[parsing] trait ReferenceParser extends CommonParser {
)
}

def arbitraryInteractionRef[u:P]: P[Reference[Definition]] = {
P( processorRef | sagaRef | inputRef | outputRef | groupRef )
def arbitraryInteractionRef[u: P]: P[Reference[Definition]] = {
P(processorRef | sagaRef | inputRef | outputRef | groupRef)
}


def anyInteractionRef[u: P]: P[Reference[Definition]] = {
arbitraryInteractionRef | userRef
}
Expand Down
21 changes: 21 additions & 0 deletions testkit/src/test/input/issues/447.riddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
domain example is {
context TenantControl {
command CreateTenant { name: String }
event TenantCreated { name: String, result: String }
}
record Create { name: String }
user Admin is "fickle"
application App is {
page NewTenantPage {
input NameEntry acquires record example.Create
button Create acquires record example.Create
}
}
epic check_for_wrong_types_to_and_from_vitals {
case UserCreatesANewCompany {
user Admin wants to "create a new tenant" so that "the tenant can do stuff"
step from user Admin "presses" button App.NewTenantPage.Create,
step from button App.NewTenantPage.Create "sends" to context TenantControl
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,13 @@ class ReportedIssuesTest extends ValidatingTest {
succeed
}
}
"447" in {
checkOne("447.riddl") {
case Left(messages) =>
fail(messages.format)
case Right(result) =>
succeed
}
}
}
}

0 comments on commit 7047b74

Please sign in to comment.