procedure main()
    s := "Mon Dec 8"
    s ? write(Mdate() | "not a valid date")
end
# Define a matching function that returns
# a string that matches a day month dayofmonth
procedure Mdate()
# Define some initial values
static dates
static days
initial {
       days := ["Mon","Tue","Wed","Thr","Fri","Sat","Sun"]
       dates := ["Jan","Feb","Mar","Apr","May","Jun",
                 "Jul","Aug","Sep","Oct","Nov","Dec"]
}
every suspend   (retval <-  tab(match(!days)) ||     # Match a day
                            =" " ||                  # Followed by a blank
                            tab(match(!dates)) ||    # Followed by the month
                            =" " ||                  # Followed by a blank
                            matchdigits(2)           # Followed by at least 2 digits 
                ) &
                (=" " | pos(0) ) &                   # Either a blank or the end of the string
                retval                               # And finally return the string
end
# Matching function that returns a string of n digits
procedure matchdigits(n)
    suspend (v := tab(many(&digits)) & *v <= n) & v
end

