Inspired by, and in memory of, our beloved genius,
R.I.P.
He invented and implemented dfns — his magnum opus and the subject of the challenge.
For the interested: latest full dfns documentation and videos with John.
Task
Given an ASCII source code, answer in which of the following four categories it belongs:
Dyadic dop
Monadic dop
Dfn
Other
You may return any four consistent values, but please state your mapping if it isn't obvious.
Details
You may assume that the source code always begins with an opening curly brace {
and ends with a closing curly brace }
.
Recursively nested braces can occur (e.g. {{{}}}
), but categories 1–3 can never have brace nesting depth go below 1 (so {}{}
is "Other") and all braces must be balanced (so {{}
is "Other").
Characters in the following contexts on a line are ignored:
To the right of
#
(a comment):significant#ignored
Enclosed in single quotes
'
…'
(i.e. in a string):significant'ignored'significant
(This applies to#
too:'#'significant
)To the right of an unpaired quote
'
(pairing quotes from the left):significant'ignored
In curly brace level one (i.e. excluding nested braces):
Dyadic dops contain the uninterrupted phrase
ww
Monadic dops do not contain
ww
, but do containaa
Dfns contain neither
ww
noraa
Test cases
Dyadic dops
{ww}
{
www
}
{
''ww'
}
{aa
ww}
{'#''#'ww?aa}
Monadic dops
{aa}
{aaaa}
{aa{ww}'ww'}
{w#w'
aa'
}
{aaw*w}
{w'\'aa\''}
Dfns
{}
{a a}
{aA}
{
{aa}
}
{w
w''w#
w}
{{
}}
{w\'aa\'}
Other
{}{}
{{}
{}}
{ww}}
{}
{}
{ww}{}
{#}
{'
'}
{'#\'ww?aa'}
-> other?) \$\endgroup\$''
(apostrophe in string, can also be parsed as two adjacent strings for this challenge)? \$\endgroup\$'abc''def'
is parsed as one or two strings for this challenge. \$\endgroup\$