Changeset 420


Ignore:
Timestamp:
Jun 30, 2010, 3:07:29 PM (9 years ago)
Author:
lindanl
Message:

Name prevalidation: separate streams for name_start and name char checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2.py

    r417 r420  
    554554
    555555
    556 #
    557 # Fully validate ASCII-based names and identify non-ASCII
    558 # positions within names.
    559 
    560 def prevalidate_names(lex, name_stream, nmtoken_stream):
    561         """Fully validate ASCII-based names and identify non-ASCII positions within names.
    562 
     556def prevalidate_names(u8, lex, name_stream, nmtoken_stream):
     557        """  Fully validate ASCII-based names and identify non-ASCII positions within names.
    563558        >>> demo_prevalidate_names("<good -bad='hyphen'/><_OK/><:funny:butOK/><1problem a='b' d423='x'>")
    564         input data: <good -bad='hyphen'/><_OK/><:funny:butOK/><1problem a='b' d423='x'>
    565         names     : _1111_1111____________111___111111111111___11111111_1_____1111_____
    566         name_check: ______1____________________________________1_______________________
     559        input data      : <good -bad='hyphen'/><_OK/><:funny:butOK/><1problem a='b' d423='x'>
     560        names           : _1111_1111____________111___111111111111___11111111_1_____1111_____
     561        name_start_check: ______1____________________________________1_______________________
     562        name_check      : ___________________________________________________________________
    567563"""
    568         name_check = name_stream &~ bitutil.Advance(name_stream) & ~lex.ASCII_name_start
    569         name_check |= (name_stream | nmtoken_stream) & ~lex.ASCII_name_char
    570         return name_check
     564        name_start = name_stream &~ bitutil.Advance(name_stream)
     565        name_start_check = name_start & ~lex.ASCII_name_start
     566        name_check = (name_stream &~ name_start | nmtoken_stream) & ~lex.ASCII_name_char & ~u8.suffix
     567        return (name_start_check, name_check)
    571568
    572569def demo_prevalidate_names(u8data):
     
    578575        callouts = parse_tags(lex, markup1.CtCDPI_mask, EOF_mask)
    579576        name_stream = callouts.ElemNames | callouts.AttNames
    580         name_check = prevalidate_names(lex, name_stream, 0)
     577        (name_start_check, name_check) = prevalidate_names(u8, lex, name_stream, 0)
    581578        bitutil.print_aligned_u8_byte_streams([('input data', u8data),
    582579                              ('names', bitutil.bitstream2string(name_stream, lgth)),
     580                              ('name_start_check', bitutil.bitstream2string(name_start_check, lgth)),
    583581                              ('name_check', bitutil.bitstream2string(name_check, lgth))])
    584582
Note: See TracChangeset for help on using the changeset viewer.