Simply save this html file and edit out html header and footer. Then split the file 
into IQ.rexx and test.iq cutting at the cut lines. You will also need rexxtricks.library
available on AmiNet.

----begin cut----

/* IQ command SYNTAX: IQ.rexx TO FROM WORD SUBS... */
/* Copyright 1998 Timothy Rue - AREXX VIC IQ command: version 0.1 */
/* uses rexxtricks.library (available on Aminet) for ADOS style pattern
matching */

IF ~ SHOW('L',"rexxtricks.library") THEN
    IF ~ ADDLIB("rexxtricks.library",0,-30,0) THEN DO
        SAY 'rexxtricks.library not available, exiting'
        EXIT 10
        END

PARSE ARG to_port from word subs

IF to_port == ? | to_port == '-?' | to_port == '-h' | to_port == 'help' THEN DO
 SAY "IQ.rexx   [word|pattern] {}"
 EXIT 0
 END
IF ~ SHOW('p',to_port) THEN
    SAY "WARNING: Cannot find named port" to_port "->Default to STDOUT"
ELSE ADDRESS VALUE to_port

/* Sets compound variable by reading the first line of IQ file
and checks for the first word to = contents of the 'key' variable */
key = filekey
key.1 = 'word:'
key.2 = 'sub:'
key.3 = 'file:'
key.4 = 1

IF ~ OPEN(iqfile,from,'R') THEN DO
        SAY 'IQfile> 'from' not found!'
        EXIT 10
        END
    ELSE DO
        inline = READLN(iqfile)
        ln = 1
        keypattern = key || #?
        IF MATCHPATTERN(inline,keypattern) THEN DO i = 1 to 3
            key.i = WORD(inline,i+1)
            END
        ELSE i = -1
        END /* end of checking and reading filekey */

subn=WORDS(subs)
DO FOREVER
    IF i ~= -1 THEN DO
        inline = READLN(iqfile)
        ln = ln + 1
        END
    DO i = 1 to 3
        keypattern = key.i || #?
        key.i.result = 0
        IF MATCHPATTERN(inline,keypattern) THEN key.i.result = 1
        END
    linetest = key.1.result+key.2.result+key.3.result

    SELECT
        WHEN linetest == 0 & key.4 == 1 THEN
            IF ADDRESS() == to_port THEN inline
            ELSE say inline
        WHEN linetest == 0 & key.4 == 0 THEN NOP
        WHEN key.3.result & key.4 == 1 THEN say 'Sorry file option not yet used'
        WHEN key.2.result & key.4.level == 2 THEN DO
            key.4 = 0
            key.4.level = 1
            /* test arg sub match (within matching word)*/
            DO sn = 1 to subn
                subpattern = key.2 || WORD(subs,sn)
                IF MATCHPATTERN(inline,subpattern) THEN DO
                    key.4.level = 2
                    key.4 = 1
                    BREAK
                    END
                END
            /* if exiting sub w/blank sub */
            IF inline == key.2 & key.4.level == 1 THEN key.4 = 1
            END
        WHEN key.2.result & key.4.level == 1 THEN DO
            key.4 = 0
            /* if arg sub match (within matching word)*/
            DO sn = 1 to subn
                subpattern = key.2 || WORD(subs,sn)
                IF MATCHPATTERN(inline,subpattern) THEN DO
                    key.4.level = 2
                    key.4 = 1
                    BREAK
                    END
                END
            /* if exiting sub w/blank sub */
            IF inline == key.2 & key.4.level == 1 THEN key.4 = 1
            END
        WHEN key.1.result THEN DO
            key.4.level = 0
            key.4 = 0
            /* if arg word match */
            wordpattern = key.1 || word
            IF MATCHPATTERN(inline,key.1 || word) THEN DO
                key.4.level = 1
                key.4 = 1
                END
            /* if exiting word w/blank word */
            IF inline == key.1 THEN key.4 = 1
            END
        OTHERWISE say 'Error in IQ file at linenumber> 'ln
    END
    IF EOF(iqfile) THEN BREAK
END


---- test.iq ----- begin cut ----------

filekey : :: :::

no word definition

:word1

    definition of word1

:word2

    definition of word2

::sub1

    definition of sub1
    at word2

::sub2

    definition of sub2
    at word2

:::file1

::

    definition of nosub
    at word2

:::file2

    definition of nosub (after :::file2)
    at word2

::sub3

    definition of sub3
    at word2


:

definition of noword

----- end cut --------