parsing fixed length field with yacc/bison

How to specify the token length in a yacc file?
sample input format
<field1,data type ans,fixed length 6> followed by <field2,data type ans,fixed length 3>

Example i/p and o/p
Sample Input: "ab* d2 9o"
O/p : "Field1 [ab* d2] Field2 [ 9o] "

yacc/bison grammar:
record : AlphaNumericSpecialOfLength6 AlphaNAumericSpecialOfLength3
/** not like
record : FIELD1 FIELD2 { ....};
FIELD1 : ANS ANS ANS ANS ANS ANS;
FIELD2 : ANS ANS ANS { ...} ; ***/
{ printf("Field1 [%s] Field2 [%s] \n", $1 , $2); }

How to define grammar for this in yacc/bison?

Generally, you don't specify token lengths.... yacc sees tokens, not strings. F/Lex sees strings and outputs tokens. So if you want tokens of specified length, do (in flex):

[a-zA-Z0-9_][a-zA-Z0-9_][a-zA-Z0-9_]    AlphaNumericSpecialOfLength3

(Pardon, but I forgot actual flex syntax)