Ignore:
Timestamp:
Dec 1, 2010, 2:56:27 PM (8 years ago)
Author:
ksherdy
Message:

Update template.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/JSON/json_compilable.py

    r746 r755  
    158158        Lex.Null = (temp89 | Lex.l);
    159159
    160         # --- Start Generate String Mask ---
    161         # parse_escape() --- manual inline
     160        # Start parse_escape --- manual inline
    162161        # Odd = simd_const_2(1)
    163162        # Even = simd_const_2(2)
     
    175174        UnescapedDQuotes = (Lex.DQuote &~ Escape)
    176175       
    177         # parallel_prefix_mask() --- manual insert and bitblock logic in JSON template.c --- assume existence of ParityMask
    178        
     176        # End parse_escape --- manual inline
     177       
     178        # parallel_prefix_mask() --- we currently manually insert this method into the JSON template.c
     179       
     180        # Start Generate String Mask ---
    179181        StringMask = ParityMask & bitutil.Advance(ParityMask)
    180         # --- End Generate String Mask ---
    181 
     182        # End Generate String Mask ---
     183
     184        # Start atom_starts --- manual inline   
    182185        StringSpans = StringMask | UnescapedDQuotes
     186       
     187        AtomSpans = (Lex.True | Lex.False | Lex.Null | Lex.Number | StringSpans)
     188        AtomStarts = AtomSpans &~ bitutil.Advance(AtomSpans)
     189               
     190        StringStarts = AtomStarts & (Lex.DQuote)       
     191        NumberStarts = AtomStarts & (Lex.Minus|Lex.Digit0_9)
     192        TrueStarts = AtomStarts & (Lex.t)
     193        FalseStarts = AtomStarts & (Lex.f)
     194        NullStarts = AtomStarts & (Lex.n)       
     195        # End atom_starts --- manual inline
     196       
     197        # Start validate_string --- manual inline
     198        # (1) Validate escape characters
     199        StringEscapeChars = EscapeChars & StringMask
     200        StringErrors = (StringEscapeChars &~ Lex.Escape)
     201       
     202        u = StringEscapeChars & Lex.u
     203       
     204        uScope1 = bitutil.Advance(u)
     205        uScope2 = bitutil.Advance(uScope1)
     206        uScope3 = bitutil.Advance(uScope2)
     207        uScope4 = bitutil.Advance(uScope3)
     208       
     209        StringErrors |= uScope1 &~ Lex.HexDigit
     210        StringErrors |= uScope2 &~ Lex.HexDigit
     211        StringErrors |= uScope3 &~ Lex.HexDigit
     212        StringErrors |= uScope4 &~ Lex.HexDigit
     213       
     214        # (2) Validation of unescaped characters
     215        # (2.1) StringMask construction ensures all '"' are escaped.
     216        # (2.2) '\' are either correctly escaped or the character following an odd length run is escaped.
     217
     218        StringNotEscapedChars = (~(EscapeChars | Lex.RSolidus)) & StringMask # TODO - Verify logic.
     219        StringErrors |= (StringNotEscapedChars & Ctrl.x00_x1F)
     220       
     221        # (3) Validate all strings are terminated with an unescaped "
     222        StringCursor = bitutil.Advance(StringStarts)
     223        StringEnds = bitutil.ScanThru(StringCursor, StringMask)
     224        StringErrors |= StringEnds &~ UnescapedDQuotes
     225        StringSpans = (StringEnds - StringStarts) | StringEnds 
     226
     227        # End validate_string --- manual inline
     228       
     229        # Consolidate errors
     230        error_mask = StringErrors
    183231
    184232        return (u8,Lex,Ctrl,EOF_mask)
Note: See TracChangeset for help on using the changeset viewer.