 Timestamp:
 Nov 7, 2012, 3:18:57 PM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

proto/PDF/pdf.py
r2596 r2620 29 29 Slash = 0 30 30 Regular = 0 31 Delimiter = 032 31 LAngle = 0 33 32 RAngle = 0 34 33 Hex = 0 35 34 WS = 0 36 Digit = 035 Digit = 0 37 36 Sign = 0 38 37 Period = 0 … … 40 39 RBracket = 0 41 40 LBracket = 0 41 Hash = 0 42 CR = 0 43 LF = 0 44 Special = 0 42 45 43 46 … … 46 49 UELParen = 0 47 50 UERParen = 0 51 escapes = 0 48 52 49 53 class Comments_Callouts() : 50 mask = 054 mask = 0 51 55 52 56 class LiteralStrings_Callouts() : 53 57 starts = 0 54 58 ends = 0 59 escapes = 0 60 carriage_returns = 0 55 61 mask = 0 56 62 error = 0 57 63 58 64 class Marker() : 59 mask =065 mask = 0 60 66 61 67 class Names_Callouts() : 62 68 starts = 0 63 69 follows = 0 70 escapes = 0 64 71 65 72 class HexStrings_Callouts() : … … 67 74 ends = 0 68 75 error = 0 76 hex = 0 69 77 70 78 class Numeric_Callouts() : … … 75 83 class Keywords_Callouts() : 76 84 starts = 0 85 ends = 0 86 87 class SpecialChars_Callouts() : 88 starts = 0 77 89 follows = 0 78 79 class Arrays_Callouts() :80 starts = 081 ends = 082 90 83 91 def Classify_bytes(basis_bits, lex): 84 temp1 = (basis_bits.bit_0  basis_bits.bit_1) 85 temp2 = (basis_bits.bit_2 &~ basis_bits.bit_3) 86 temp3 = (temp2 &~ temp1) 87 temp4 = (basis_bits.bit_4 &~ basis_bits.bit_5) 88 temp5 = (basis_bits.bit_6  basis_bits.bit_7) 89 temp6 = (temp4 &~ temp5) 90 lex.LParen = (temp3 & temp6) 91 temp7 = (basis_bits.bit_7 &~ basis_bits.bit_6) 92 temp8 = (temp4 & temp7) 93 lex.RParen = (temp3 & temp8) 94 temp9 = (basis_bits.bit_1 &~ basis_bits.bit_0) 95 temp10 = (basis_bits.bit_3 &~ basis_bits.bit_2) 96 temp11 = (temp9 & temp10) 97 temp12 = (basis_bits.bit_4 & basis_bits.bit_5) 98 temp13 = (temp12 &~ temp5) 99 lex.Backslash = (temp11 & temp13) 100 temp14 = (temp5 &~ temp7) 101 temp15 = (temp4 &~ temp14) 102 temp16 = (temp3 & temp15) 103 temp17 = (basis_bits.bit_2 & basis_bits.bit_3) 104 temp18 = (temp17 &~ temp1) 105 temp19 = (temp18 & temp13) 106 temp20 = (temp16  temp19) 107 temp21 = (basis_bits.bit_6 &~ basis_bits.bit_7) 108 temp22 = (temp12 & temp21) 109 temp23 = (temp18 & temp22) 110 temp24 = (temp20  temp23) 111 temp25 = (basis_bits.bit_6 & basis_bits.bit_7) 112 temp26 = (temp4 & temp25) 113 temp27 = (temp11 & temp26) 114 temp28 = (temp24  temp27) 115 temp29 = (temp12 & temp7) 116 temp30 = (temp11 & temp29) 117 temp31 = (temp28  temp30) 118 temp32 = (temp9 & temp17) 119 temp33 = (temp32 & temp26) 120 temp34 = (temp31  temp33) 121 temp35 = (temp32 & temp29) 122 temp36 = (temp34  temp35) 123 temp37 = (basis_bits.bit_5 &~ basis_bits.bit_4) 124 temp38 = (temp37 & temp7) 125 temp39 = (temp3 & temp38) 126 temp40 = (temp36  temp39) 127 temp41 = (temp12 & temp25) 128 temp42 = (temp3 & temp41) 129 lex.Delimiter = (temp40  temp42) 130 lex.Percent = (temp3 & temp38) 131 lex.Period = (temp3 & temp22) 132 lex.LAngle = (temp18 & temp13) 133 lex.RAngle = (temp18 & temp22) 134 lex.LBracket = (temp11 & temp26) 135 lex.RBracket = (temp11 & temp29) 136 lex.Slash = (temp3 & temp41) 137 temp43 = (basis_bits.bit_2  basis_bits.bit_3) 138 temp44 = (temp1  temp43) 139 temp45 = (temp4 & temp21) 140 temp46 = (temp29  temp45) 141 lex.EOL = (temp46 &~ temp44) 142 temp47 = (basis_bits.bit_4  basis_bits.bit_5) 143 temp48 = (temp47  temp5) 144 temp49 = (temp44  temp48) 145 temp50 = (temp13 &~ temp44) 146 temp51 = (temp49 &~ temp50) 147 temp52 = (temp29 &~ temp44) 148 temp53 = (temp51 &~ temp52) 149 temp54 = (temp45 &~ temp44) 150 temp55 = (temp53 &~ temp54) 151 temp56 = (temp8 &~ temp44) 152 temp57 = (temp55 &~ temp56) 153 temp58 = (temp3 &~ temp48) 154 temp59 = (temp57 &~ temp58) 155 lex.WS = (~temp59) 156 temp60 = (basis_bits.bit_5  basis_bits.bit_6) 157 temp61 = (basis_bits.bit_4 & temp60) 158 lex.Digit = (temp18 &~ temp61) 159 temp62 = (temp29  temp26) 160 lex.Sign = (temp3 & temp62) 161 temp63 = (temp9 &~ temp43) 162 temp64 = (temp63 &~ basis_bits.bit_4) 163 temp65 = (~temp25) 164 temp66 = ((basis_bits.bit_5 & temp65)(~(basis_bits.bit_5) & temp5)) 165 temp67 = (temp64 & temp66) 166 temp68 = (lex.Digit  temp67) 167 temp69 = (temp9 & temp2) 168 temp70 = (temp69 &~ basis_bits.bit_4) 169 temp71 = (temp70 & temp66) 170 lex.Hex = (temp68  temp71) 171 lex.Regular = ~lex.Delimiter&~lex.WS 92 temp1 = (basis_bits.bit_0  basis_bits.bit_1) 93 temp2 = (basis_bits.bit_2 &~ basis_bits.bit_3) 94 temp3 = (temp2 &~ temp1) 95 temp4 = (basis_bits.bit_4 &~ basis_bits.bit_5) 96 temp5 = (basis_bits.bit_6  basis_bits.bit_7) 97 temp6 = (temp4 &~ temp5) 98 lex.LParen = (temp3 & temp6) 99 temp7 = (basis_bits.bit_7 &~ basis_bits.bit_6) 100 temp8 = (temp4 & temp7) 101 lex.RParen = (temp3 & temp8) 102 temp9 = (basis_bits.bit_1 &~ basis_bits.bit_0) 103 temp10 = (basis_bits.bit_3 &~ basis_bits.bit_2) 104 temp11 = (temp9 & temp10) 105 temp12 = (basis_bits.bit_4 & basis_bits.bit_5) 106 temp13 = (temp12 &~ temp5) 107 lex.Backslash = (temp11 & temp13) 108 temp14 = (temp5 &~ temp7) 109 temp15 = (temp4 &~ temp14) 110 temp16 = (temp3 & temp15) 111 temp17 = (basis_bits.bit_2 & basis_bits.bit_3) 112 temp18 = (temp17 &~ temp1) 113 temp19 = (temp18 & temp13) 114 temp20 = (temp16  temp19) 115 temp21 = (basis_bits.bit_6 &~ basis_bits.bit_7) 116 temp22 = (temp12 & temp21) 117 temp23 = (temp18 & temp22) 118 temp24 = (temp20  temp23) 119 temp25 = (basis_bits.bit_6 & basis_bits.bit_7) 120 temp26 = (temp4 & temp25) 121 temp27 = (temp11 & temp26) 122 temp28 = (temp24  temp27) 123 temp29 = (temp12 & temp7) 124 temp30 = (temp11 & temp29) 125 temp31 = (temp28  temp30) 126 temp32 = (temp9 & temp17) 127 temp33 = (temp32 & temp26) 128 temp34 = (temp31  temp33) 129 temp35 = (temp32 & temp29) 130 temp36 = (temp34  temp35) 131 temp37 = (basis_bits.bit_5 &~ basis_bits.bit_4) 132 temp38 = (temp37 & temp7) 133 temp39 = (temp3 & temp38) 134 temp40 = (temp36  temp39) 135 temp41 = (temp12 & temp25) 136 temp42 = (temp3 & temp41) 137 lex.Special = (temp40  temp42) 138 lex.Percent = (temp3 & temp38) 139 lex.Period = (temp3 & temp22) 140 lex.LAngle = (temp18 & temp13) 141 lex.RAngle = (temp18 & temp22) 142 lex.LBracket = (temp11 & temp26) 143 lex.RBracket = (temp11 & temp29) 144 lex.Slash = (temp3 & temp41) 145 temp43 = (basis_bits.bit_2  basis_bits.bit_3) 146 temp44 = (temp1  temp43) 147 temp45 = (temp4 & temp21) 148 temp46 = (temp29  temp45) 149 lex.EOL = (temp46 &~ temp44) 150 temp47 = (basis_bits.bit_4  basis_bits.bit_5) 151 temp48 = (temp47  temp5) 152 temp49 = (temp44  temp48) 153 temp50 = (temp13 &~ temp44) 154 temp51 = (temp49 &~ temp50) 155 temp52 = (temp29 &~ temp44) 156 temp53 = (temp51 &~ temp52) 157 temp54 = (temp45 &~ temp44) 158 temp55 = (temp53 &~ temp54) 159 temp56 = (temp8 &~ temp44) 160 temp57 = (temp55 &~ temp56) 161 temp58 = (temp3 &~ temp48) 162 temp59 = (temp57 &~ temp58) 163 lex.WS = (~temp59) 164 temp60 = (basis_bits.bit_5  basis_bits.bit_6) 165 temp61 = (basis_bits.bit_4 & temp60) 166 lex.Digit = (temp18 &~ temp61) 167 temp62 = (temp29  temp26) 168 lex.Sign = (temp3 & temp62) 169 temp63 = (temp9 &~ temp43) 170 temp64 = (temp63 &~ basis_bits.bit_4) 171 temp65 = (~temp25) 172 temp66 = ((basis_bits.bit_5 & temp65)(~(basis_bits.bit_5) & temp5)) 173 temp67 = (temp64 & temp66) 174 temp68 = (lex.Digit  temp67) 175 temp69 = (temp9 & temp2) 176 temp70 = (temp69 &~ basis_bits.bit_4) 177 temp71 = (temp70 & temp66) 178 lex.Hex = (temp68  temp71) 179 temp72 = (temp25 &~ temp47) 180 lex.Hash = (temp3 & temp72) 181 lex.CR = (temp29 &~ temp44) 182 lex.LF = (temp45 &~ temp44) 183 lex.Regular = ~lex.Special&~lex.WS 172 184 173 185 … … 185 197 even_final = pablo.ScanThru(even_start, lex.Backslash) 186 198 escape = even_final & odd 187 199 escape_char = even & pablo.SpanUpTo(even_start, even_final) 200 188 201 odd_start = start & odd 189 202 odd_final = pablo.ScanThru(odd_start, lex.Backslash) 190 203 escape = escape  (odd_final & even) 191 204 escape_char = odd & pablo.SpanUpTo(odd_start, odd_final) 205 206 escaped_Callouts.escapes = escape_char 192 207 escaped_Callouts.UELParen = lex.LParen &~ escape 193 208 escaped_Callouts.UERParen = lex.RParen &~ escape … … 239 254 comment_starts=0 240 255 comment_ends=0 241 scan_characters = escaped_Callouts.UELParen escaped_Callouts.UERParen  lex.Percent 242 literalStrings_Callouts.starts = 0 243 literalStrings_Callouts.ends = 0 244 literalStrings_Callouts.error = 0 256 scan_characters = escaped_Callouts.UELParen  escaped_Callouts.UERParen  lex.Percent 245 257 cursor = pablo.ScanToFirst(scan_characters) 246 258 while pablo.inFile(cursor) : … … 252 264 comment_ends =comment_cursor 253 265 cursor = pablo.ScanTo(pablo.Advance(comment_cursor), scan_characters) 254 255 256 266 257 267 if string_cursor : 258 268 if (string_cursor & escaped_Callouts.UELParen) : … … 270 280 literalStrings_Callouts.ends=string_cursor 271 281 cursor = pablo.ScanTo(pablo.Advance(string_cursor), scan_characters) 272 if lt_zero():282 elif lt_zero(): 273 283 literalStrings_Callouts.error=string_cursor 274 284 cursor = pablo.ScanTo(pablo.Advance(string_cursor), scan_characters) 275 if ~(is_zero()  lt_zero()):285 else: 276 286 cursor = pablo.ScanTo(pablo.Advance(string_cursor), escaped_Callouts.UELParen  escaped_Callouts.UERParen) 277 #literalStrings_Callouts.ends = string_cursor & is_zero() 278 #literalStrings_Callouts.error = string_cursor & lt_zero() 279 #cursor = pablo.ScanTo(pablo.Advance(string_cursor), scan_characters ^ (lex.Percent & (is_zero()  lt_zero()))) 280 281 282 283 #if (depth>0): 284 #error 287 288 285 289 comments_Callouts.mask = pablo.SpanUpTo(comment_starts, comment_ends) 286 literalStrings_Callouts.mask = pablo.SpanUpTo(literalStrings_Callouts.starts,literalStrings_Callouts.ends) 290 literalStrings_Callouts.mask = pablo.InclusiveSpan(literalStrings_Callouts.starts,literalStrings_Callouts.ends) 291 literalStrings_Callouts.escapes = escaped_Callouts.escapes & literalStrings_Callouts.mask 292 literalStrings_Callouts.carriage_returns = lex.CR & literalStrings_Callouts.mask &~ literalStrings_Callouts.escapes 287 293 marker.mask = comments_Callouts.mask  literalStrings_Callouts.mask 288 294 289 290 295 def Parse_Names(lex, marker, names_Callouts) : 291 names_Callouts.starts = pablo.Advance(lex.Slash&~marker.mask) 292 names_Callouts.follows = pablo.ScanThru(names_Callouts.starts, lex.Regular) 293 marker.mask =names_Callouts.starts 296 names_Callouts.starts =lex.Slash&~marker.mask 297 firstCharacter = pablo.Advance(names_Callouts.starts) 298 names_Callouts.follows = pablo.ScanThru(firstCharacter, lex.Regular) 299 names_Callouts.escapes = (pablo.Advance(pablo.Advance(lex.Hash))&pablo.Advance(lex.Hex)&lex.Hex)&pablo.SpanUpTo(names_Callouts.starts, names_Callouts.follows) 300 marker.mask =names_Callouts.starts(firstCharacter&~names_Callouts.follows) 294 301 295 302 def Parse_HexStrings(lex, marker, hexStrings_Callouts) : 296 #Haven't confirmed that this is the correct behaviour with bad input297 303 hexStrings_Callouts.starts = lex.LAngle &~marker.mask 298 304 hexStrings_Callouts.ends = pablo.ScanThru(pablo.Advance(hexStrings_Callouts.starts),lex.Hexlex.WS) 299 305 hexStrings_Callouts.error = hexStrings_Callouts.ends &~ lex.RAngle 300 marker.mask = pablo.SpanUpTo(hexStrings_Callouts.starts,hexStrings_Callouts.ends) 306 mask = pablo.InclusiveSpan(hexStrings_Callouts.starts,hexStrings_Callouts.ends) 307 hexStrings_Callouts.hex = lex.Hex & mask 308 marker.mask = mask 301 309 302 310 def Parse_Numeric(lex, marker, numeric_Callouts) : … … 306 314 marker.mask = numeric_Callouts.starts 307 315 308 # aftersign = pablo.Advance(numeric_Callouts.starts & lex.Sign)  (numeric_Callouts.starts &~ lex.Sign)309 # temp = pablo.ScanThru(aftersign, lex.Digit)310 # afterperiod = pablo.Advance(temp & lex.Period)  (temp &~ lex.Period)311 # numeric_Callouts.follows = pablo.ScanThru(afterperiod, lex.Digit)312 # numeric_Callouts.error = numeric_Callouts.follows &~ (lex.WS  lex.Delimiter)313 # marker.mask = numeric_Callouts.starts314 315 316 def Parse_Keywords(lex, marker, keywords_Callouts) : 316 317 keywords_Callouts.starts = (lex.Regular &~ pablo.Advance(lex.Regular)) &~ marker.mask 317 318 keywords_Callouts.follows = pablo.ScanThru(keywords_Callouts.starts, lex.Regular) 318 319 319 def Parse_ Arrays(lex, marker, arrays_Callouts) :320 arrays_Callouts.starts = lex.LBracket&~ marker.mask321 arrays_Callouts.ends = lex.RBracket &~ marker.mask320 def Parse_SpecialChars(lex, marker, specialChars_Callouts) : 321 specialChars_Callouts.starts = (lex.Special) &~ marker.mask 322 specialChars_Callouts.follows = pablo.Advance(specialChars_Callouts.starts) 322 323 323 324 def Main(basis_bits, lex, parity, escaped_Callouts): … … 330 331 Parse_Numeric(lex, marker, numeric_Callouts) 331 332 Parse_Keywords(lex, marker, keywords_Callouts) 332 Parse_ Arrays(lex, marker, arrays_Callouts)333 333 Parse_SpecialChars(lex, marker, specialChars_Callouts) 334
Note: See TracChangeset
for help on using the changeset viewer.