summaryrefslogtreecommitdiff
path: root/tests/general/recogn.icn
diff options
context:
space:
mode:
Diffstat (limited to 'tests/general/recogn.icn')
-rw-r--r--tests/general/recogn.icn28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/general/recogn.icn b/tests/general/recogn.icn
new file mode 100644
index 0000000..c55efd0
--- /dev/null
+++ b/tests/general/recogn.icn
@@ -0,0 +1,28 @@
+#
+# C F L R E C O G N I T I O N
+#
+
+# This program takes strings from standard input and determines
+# whether or not they are sentences in the language defined by <s>.
+
+procedure main()
+ local line
+ while line := read() do
+ if recogn(s,line) then write("accepted") else write("rejected")
+end
+
+procedure recogn(goal,text)
+ return text ? (goal() & pos(0))
+end
+
+# <s> ::= a <s> | <t> b | c
+
+procedure s()
+ suspend (="a" || s()) | (t() || ="b") | ="c"
+end
+
+# <t> ::= d <s> d | e | f
+
+procedure t()
+ suspend (="d" || s() || ="d") | ="e" | ="f"
+end