Skip to content

Commit

Permalink
#675 Provide lists of keywords, punctuation, readability (#688)
Browse files Browse the repository at this point in the history
Also added a simple test case to stabilize the
keywords by count.
  • Loading branch information
reid-spencer authored Oct 29, 2024
1 parent 4fdf31a commit 1f99f00
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ object Keywords {
def append[u: P]: P[Unit] = keyword(Keyword.append)

def application[u: P]: P[Unit] = keyword(Keyword.application)
def attachment[u:P]: P[Unit] = keyword(Keyword.attachment)

def attachment[u: P]: P[Unit] = keyword(Keyword.attachment)

def author[u: P]: P[Unit] = keyword(Keyword.author)

Expand Down Expand Up @@ -110,7 +110,8 @@ object Keywords {
def direct[u: P]: P[Unit] = keyword(Keyword.direct)

def described[u: P]: P[Unit] = keywords(
StringIn(Keyword.described, Keyword.explained, Keyword.description, Keyword.explanation))
StringIn(Keyword.described, Keyword.explained, Keyword.description, Keyword.explanation)
)

def details[u: P]: P[Unit] = keyword(Keyword.details)

Expand Down Expand Up @@ -182,7 +183,7 @@ object Keywords {

def items[u: P]: P[Unit] = keyword(Keyword.items)

def label[u:P]: P[Unit] = keyword(Keyword.label)
def label[u: P]: P[Unit] = keyword(Keyword.label)

def link[u: P]: P[Unit] = keyword(Keyword.link)

Expand All @@ -199,8 +200,8 @@ object Keywords {
def morph[u: P]: P[Unit] = keyword(Keyword.morph)

def name[u: P]: P[Unit] = keyword(Keyword.name)
def nebula[u:P]: P[Unit] = keyword(Keyword.nebula)

def nebula[u: P]: P[Unit] = keyword(Keyword.nebula)

def on[u: P]: P[Unit] = keyword(Keyword.on)

Expand Down Expand Up @@ -473,4 +474,147 @@ object Keyword {
final val when = "when"
final val where = "where"
final val with_ = "with"

def allKeywords: Seq[String] = Seq(
acquires,
adaptor,
all,
any,
append,
application,
attachment,
author,
become,
benefit,
brief,
briefly,
body,
call,
case_,
capability,
command,
commands,
condition,
connector,
constant,
container,
contains,
context,
create,
described,
description,
details,
direct,
presents,
do_,
domain,
else_,
email,
end_,
entity,
epic,
error,
event,
example,
execute,
explanation,
explained,
field,
fields,
file,
flow,
focus,
for_,
foreach,
form,
from,
fully,
function,
graph,
group,
handler,
if_,
import_,
include,
index,
init,
inlet,
inlets,
input,
invariant,
items,
label,
link,
many,
mapping,
merge,
message,
module,
morph,
name,
nebula,
on,
one,
organization,
option,
optional,
options,
other,
outlet,
outlets,
output,
parallel,
pipe,
plant,
projector,
query,
range,
reference,
relationship,
remove,
replica,
reply,
repository,
requires,
required,
record,
result,
results,
return_,
returns,
reverted,
router,
saga,
schema,
selects,
send,
sequence,
set,
show,
shown,
sink,
source,
split,
state,
step,
stop,
story,
streamlet,
table,
take,
tell,
term,
then_,
title,
type_,
url,
updates,
user,
value,
void,
when,
where,
with_
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,24 @@ object Punctuation {
final val squareClose = "]"
final val undefinedMark = "???"
final val verticalBar = "|"

def allPunctuation: Seq[String] = Seq(
asterisk,
atSign,
comma,
colon,
curlyOpen,
curlyClose,
dot,
equalsSign,
plus,
question,
quote,
roundOpen,
roundClose,
squareOpen,
squareClose,
undefinedMark,
verticalBar
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ import com.ossuminc.riddl.language.parsing.Keywords.keyword
trait Readability {

def and[u: P]: P[Unit] = keyword("and")

def are[u: P]: P[Unit] = keyword("are")

def as[u: P]: P[Unit] = keyword("as")

def at[u: P]: P[Unit] = keyword("at")

def by[u: P]: P[Unit] = keyword("by")

def byAs[u: P]: P[Unit] = Keywords.keywords(StringIn("by", "as"))

def `for`[u: P]: P[Unit] = keyword("for")

def from[u: P]: P[Unit] = keyword("from")

def in[u: P]: P[Unit] = keyword("in")

def is[u: P]: P[Unit] = {
Expand All @@ -32,10 +39,37 @@ trait Readability {
}

def of[u: P]: P[Unit] = keyword("of")

def so[u: P]: P[Unit] = keyword("so")

def that[u: P]: P[Unit] = keyword("that")

def to[u: P]: P[Unit] = keyword("to")

def wants[u: P]: P[Unit] = keyword("wants")

def `with`[u: P]: P[Unit] = keyword("with")
}

object Readability {
def allReadability: Seq[String] = Seq(
"and",
"are",
"as",
"at",
"by",
"for",
"from",
"in",
"is",
"are",
":",
"=",
"of",
"so",
"that",
"to",
"wants",
"with"
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2019 Ossum, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

package com.ossuminc.riddl.language.parsing

import com.ossuminc.riddl.utils.AbstractTestingBasis

class KeywordsTest extends AbstractTestingBasis {

"Keyword" should {
"produce all keywords" in {
Keyword.allKeywords.size must be(139)
}
}

"Punctuation" should {
"produce all punctuation marks" in {
Punctuation.allPunctuation.size must be (17)
}
}

"Readability" should {
"produce all readability words" in {
Readability.allReadability.size must be(18)
}
}
}

0 comments on commit 1f99f00

Please sign in to comment.