Redcode grammar:
----------------

statement_list :: statement statement_list | e ;
statement :: normal_stmt<1> |
             equ_stmt       |
             forrof_stmt    |
             comment_stmt   |
             substitution_stmt<2> ;

num       :: [0-9] ;
number    :: num number | num ;
alpha     :: [a-zA-Z] | "_" ;
alphanum  :: alpha | num ;
alphanums :: alphanum alphanums | e ;

label  :: alpha alphanums ;
label1 :: label label1 | label ;
labels :: label1 "\n" labels | label1 ;
stringization :: stringization"&"label | label ;

this_string :: (^\n)* ;
comment     :: ";" this_string "\n" | e ;

equ_stmt    :: labels equ_strings ;
equ_string  :: "equ" this_string comment "\n" ;
equ_strings :: equ_string "\n" equ_strings | equ_string ;

forrof_stmt :: labels index "for" expression<3> comment "\n"
               statement_list
               "rof" this_string "\n" ;
index       :: label

comment_stmt  :: info_comment | debug_comment | ignore ;
ignore        :: ";" this_string "\n" ;
info_comment  :: ";redcode" this_string "\n" |
                 ";" "name" this_string "\n" |
                 ";" "author" this_string "\n" |
                 ";" "date" this_string "\n" |
                 ";" "version" this_string "\n" |
                 ";" "assert" expression<4> "\n" ;
debug_comment :: ";" debug "\n" | ";" trace "\n" | ";" break "\n" ;
debug         :: "debug" | "debug" "off" | "debug" "static" ;
trace         :: "trace" | "trace" "off" ;
break         :: "break" ;

Note:
1. Normal statements are statements in the following form:
   opcode [address mode] operand [, [address mode] operand] [comment]
   More details about the grammar are given in the '88 or '94 proposal.

2. Substitution statements are labels that have been declared by EQU.
   If a label is declared this way: "IMP_instr equ imp mov imp, imp + 
   1", the label name IMP_instr can be thought of as a statement.  
   Therefore, whenf IMP_instr is used after its declaration, it will 
   be replaced by "imp mov imp, imp + 1". It has effect of declaring 
   a label 'imp' and inserting the statement 'mov imp, imp + 1'.

3. Valid expression for "FOR" statement is very close to C expression in
   which operator '()' has the highest precedence, followed by 'unary +,
   unary -', '*, / and %', 'binary + and binary -', '<, <=, >, >=',
   '==, !=', '&&', '||', and the lowest '='.
   Beside numbers, it can also has labels as its terms. All of its labels
   have to be declared before "FOR" statement is invoked.

4. Valid expression for "ASSERT" statement is the same as that for "FOR".