diff --git a/lzw.c b/lzw.c
index 4ab29254be1deefcb6bc022b26f823eafbd9a282..34c428030c5ee163232fdacf654bf091075b5f4d 100644
--- a/lzw.c
+++ b/lzw.c
@@ -317,6 +317,8 @@ void init_LZW_parser()
 	H_VDRULE(LZW_10bitcodeword, h_bits(10, false), context);
 	H_VDRULE(LZW_11bitcodeword, h_bits(11, false), context);
 	H_VDRULE(LZW_12bitcodeword, h_bits(12, false), context);
+	H_RULE  (codeword,	h_choice(LZW_9bitcodeword, LZW_10bitcodeword,
+				    LZW_11bitcodeword, LZW_12bitcodeword, NULL));
 
 	H_VDRULE(LZW_9bitlitspec, h_bits(9, false), context);
 	H_VDRULE(LZW_10bitlitspec, h_bits(10, false), context);
@@ -325,7 +327,7 @@ void init_LZW_parser()
 
 	H_AVDRULE(LZW_clear, h_choice(LZW_9bitlitspec, LZW_10bitlitspec, LZW_11bitlitspec, LZW_12bitlitspec, NULL), context);
 	H_VDRULE(LZW_eod, h_choice(LZW_9bitlitspec, LZW_10bitlitspec, LZW_11bitlitspec, LZW_12bitlitspec, NULL), context);
-	H_AVDRULE(LZW_output, h_choice(LZW_9bitcodeword, LZW_10bitcodeword, LZW_11bitcodeword, LZW_12bitcodeword, NULL), context);
+	H_AVDRULE(LZW_output,	codeword, context);
 
 	H_ADRULE(LZW_body, h_many(h_choice(LZW_clear, LZW_output, NULL)), context);