Changeset 1316 for proto/FIX/fix.py


Ignore:
Timestamp:
Aug 18, 2011, 7:50:15 AM (8 years ago)
Author:
cameron
Message:

FIX tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/FIX/fix.py

    r1315 r1316  
    22# FIX parsing prototype
    33# Robert D. Cameron   Aug. 17, 2011
     4# (c)  All rights reserved.
    45#
    5 
    66
    77class Basis_bits():     
     
    4545
    4646def Parse_fields(fix_lex, fix_callout):
     47        # Fields must begin with a nonzero digit.
     48        allowed_leading_digit = fix_lex.Digit &~ fix_lex.Zero
    4749        # Assume for now that all SOHs are field separators, not data.
    4850        # Use negated SOH stream to shift in a 1 at start-of-file.
    4951        # shift out a 0 at end of file.
    50         marker = ~bitutil.Advance(~fix_lex.SOH)
    51         header1 = marker
    52         header2 = bitutil.ScanThru(marker, fix_lex.Digit)
    53         error1 = header1 & fix_lex.Zero
    54         error2 = header1 & header2
    55         error3 = header2 &~ fix_lex.Equals
    56         error = error1 | error2 | error3
     52        msg_starts = ~bitutil.Advance(~fix_lex.SOH)
     53        error1 = msg_starts &~ allowed_leading_digit
     54        field_ends = bitutil.ScanThru(msg_starts, fix_lex.Digit)
     55        error2 = field_ends &~ fix_lex.Equals
     56        error = error1 | error2
    5757        if error:
    5858                error_tracker.NoteError("Potential error in header field", error)
    59         fix_callout.Header_end = header2
     59        fix_callout.Header_end = field_ends
    6060
    6161def main(basis_bits, fix_lex):
Note: See TracChangeset for help on using the changeset viewer.