File:  [CSRG BSD Unix] / 43BSD / contrib / icon / samples / recogn.icn
Revision 1.1: download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
CVS tags: MAIN, HEAD
Initial revision

#
#          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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.