[antlr-interest] Parsing a Fixed length file

Manikandan Subramanian vsmani.chrome at gmail.com
Wed Aug 27 12:09:12 PDT 2008


Hi,

I am new to ANTLR. I would like to parse fixed length records. I have gone
through many documentation but I didnt get any idea how to do.

Basically, I want to define my token to a fixed length [something like
defining with starting positon and ending postion].

my input document format will be like,

 HEADER                              Loc at 1                  Optional
 RecType*              Rec type              C         1      10 String
      X                        7         2 Left

 BODY(Msg 1)                       Loc at 1                 Mandatory
 Record1*              Rec one descrip    C         1       2 String
   X                        7         2 Left
 rec02*                  Rec 2 desc           M         1        2 String
        X                       9         2 Left
 PO*                     PO#                     C          1      22 String
          X                     11        22 Left
 A05*                    Order Date            C          8       8
Date/Time     YYYYMMDD    33        10 Left
 B06*                    Contract#              C          0     30 String
         X                     43        30 Left
 Delivery_date*      Date Requested     C          8       8 Date/Time
YYYYMMDD     73         8 Left

 BODY(Msg 2)                       Loc at 1                 Mandatory
 Record12              Rec two descrip    C         1       2 String
   X                       7         2 Left
 rec02*                  Rec 2 desc           M         1        2 String
        X                       9         2 Left
 PO*                     PO#                     C          1      22 String
          X                     11        22 Left
 A05*                    Order Date            C          8       8
Date/Time     YYYYMMDD    33        10 Left
 B06*                    Contract#              C          0     30 String
         X                     43        30 Left
 Delivery_date*      Date Requested     C          8       8 Date/Time
YYYYMMDD     73         8 Left


Thanks in Advance,
Mani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080827/97bc8199/attachment.html 


More information about the antlr-interest mailing list