source: proto/PDF/cb_pablo.py @ 3942

Last change on this file since 3942 was 3252, checked in by cameron, 6 years ago

Add numeric_starts and keyword_starts markers

File size: 20.1 KB
Line 
1# cb_pdf.py
2#
3# (c) 2012 Robert D. Cameron, Ken Herdy, Ben Hull, Dan Lin
4# All rights reserved.
5#
6import sys
7import pablo
8
9class Basis_bits():     
10        bit_0 = 0
11        bit_1 = 0
12        bit_2 = 0
13        bit_3 = 0
14        bit_4 = 0
15        bit_5 = 0
16        bit_6 = 0
17        bit_7 = 0
18
19class Parity():
20        odd = 0
21        even = 0
22
23class Lex ():
24        pdf_mod_bit_1 = 0
25        pdf_mod_bit_2 = 0
26        pdf_mod_bit_3 = 0
27        pdf_mod_bit_4 = 0
28        pdf_mod_bit_5 = 0
29        pdf_mod_bit_6 = 0
30        pdf_mod_bit_7 = 0
31        LParen = 0
32        RParen = 0
33        Backslash = 0
34        Special = 0
35        Percent = 0
36        Period = 0
37        LAngle = 0
38        RAngle = 0
39        LBracket = 0
40        RBracket = 0
41        Slash = 0
42        EOL = 0
43        WS = 0
44        Digit = 0
45        Sign = 0
46        Hex = 0
47        Hash = 0
48        CR = 0
49        LF = 0
50        Oct = 0
51        Nonoct = 0
52        Regular = 0
53       
54class Escape_Callouts():
55    LParen = 0
56    RParen = 0
57    Oct1 = 0
58    Oct2 = 0
59    Oct3 = 0
60    Nonoct = 0
61
62
63class Out_Callouts():
64    mask = 0
65    hex_opener = 0
66    zeromask = 0
67    delmask = 0
68    hexString_mask = 0
69    names_escapes = 0
70    bit_0 = 0
71    bit_1 = 0
72    bit_2 = 0
73    bit_3 = 0
74    bit_4 = 0
75    bit_5 = 0
76    bit_6 = 0
77    bit_7 = 0
78   
79class marker():
80    starts = 0
81    ends = 0
82    error = 0
83    numeric_starts = 0
84    keyword_starts = 0
85   
86
87def Classify_bytes(basis_bits, lex):
88        temp1 = (basis_bits.bit_1 &~ basis_bits.bit_0)
89        temp2 = (basis_bits.bit_2 &~ basis_bits.bit_3)
90        temp3 = (temp1 & temp2)
91        temp4 = (basis_bits.bit_6 &~ basis_bits.bit_7)
92        temp5 = (basis_bits.bit_4 | basis_bits.bit_5)
93        temp6 = (basis_bits.bit_5 &~ basis_bits.bit_4)
94        temp7 = (temp5 &~ temp6)
95        temp8 = (basis_bits.bit_4 & basis_bits.bit_5)
96        temp9 = (temp7 &~ temp8)
97        temp10 = (temp4 &~ temp9)
98        temp11 = (temp3 & temp10)
99        temp12 = (basis_bits.bit_2 & basis_bits.bit_3)
100        temp13 = (temp1 & temp12)
101        temp14 = (temp4 &~ temp5)
102        temp15 = (temp13 & temp14)
103        temp16 = (temp11 | temp15)
104        temp17 = (basis_bits.bit_6 | basis_bits.bit_7)
105        temp18 = (temp6 &~ temp17)
106        temp19 = (temp13 & temp18)
107        lex.pdf_mod_bit_1 = (temp16 | temp19)
108        lex.pdf_mod_bit_2 = (temp16 | temp19)
109        temp20 = (temp14 | temp18)
110        lex.pdf_mod_bit_3 = (temp13 & temp20)
111        temp21 = (temp4 &~ temp7)
112        temp22 = (temp3 & temp21)
113        temp23 = (temp22 | temp15)
114        lex.pdf_mod_bit_4 = (temp23 | temp19)
115        temp24 = (temp8 & temp4)
116        temp25 = (temp3 & temp24)
117        temp26 = (temp25 | temp15)
118        lex.pdf_mod_bit_5 = (temp26 | temp19)
119        lex.pdf_mod_bit_6 = (temp22 | temp15)
120        lex.pdf_mod_bit_7 = (temp13 & temp20)
121        temp27 = (basis_bits.bit_0 | basis_bits.bit_1)
122        temp28 = (temp2 &~ temp27)
123        temp29 = (basis_bits.bit_4 &~ basis_bits.bit_5)
124        temp30 = (temp29 &~ temp17)
125        lex.LParen = (temp28 & temp30)
126        temp31 = (basis_bits.bit_7 &~ basis_bits.bit_6)
127        temp32 = (temp29 & temp31)
128        lex.RParen = (temp28 & temp32)
129        temp33 = (basis_bits.bit_3 &~ basis_bits.bit_2)
130        temp34 = (temp1 & temp33)
131        temp35 = (temp8 &~ temp17)
132        lex.Backslash = (temp34 & temp35)
133        temp36 = (temp17 &~ temp31)
134        temp37 = (temp29 &~ temp36)
135        temp38 = (temp28 & temp37)
136        temp39 = (temp12 &~ temp27)
137        temp40 = (temp39 & temp35)
138        temp41 = (temp38 | temp40)
139        temp42 = (temp39 & temp24)
140        temp43 = (temp41 | temp42)
141        temp44 = (basis_bits.bit_6 & basis_bits.bit_7)
142        temp45 = (temp29 & temp44)
143        temp46 = (temp34 & temp45)
144        temp47 = (temp43 | temp46)
145        temp48 = (temp8 & temp31)
146        temp49 = (temp34 & temp48)
147        temp50 = (temp47 | temp49)
148        temp51 = (temp13 & temp45)
149        temp52 = (temp50 | temp51)
150        temp53 = (temp13 & temp48)
151        temp54 = (temp52 | temp53)
152        temp55 = (temp6 & temp31)
153        temp56 = (temp28 & temp55)
154        temp57 = (temp54 | temp56)
155        temp58 = (temp8 & temp44)
156        temp59 = (temp28 & temp58)
157        lex.Special = (temp57 | temp59)
158        lex.Percent = (temp28 & temp55)
159        lex.Period = (temp28 & temp24)
160        lex.LAngle = (temp39 & temp35)
161        lex.RAngle = (temp39 & temp24)
162        lex.LBracket = (temp34 & temp45)
163        lex.RBracket = (temp34 & temp48)
164        lex.Slash = (temp28 & temp58)
165        temp60 = (basis_bits.bit_2 | basis_bits.bit_3)
166        temp61 = (temp27 | temp60)
167        temp62 = (temp29 & temp4)
168        temp63 = (temp48 | temp62)
169        lex.EOL = (temp63 &~ temp61)
170        temp64 = (temp5 | temp17)
171        temp65 = (temp61 | temp64)
172        temp66 = (temp35 &~ temp61)
173        temp67 = (temp65 &~ temp66)
174        temp68 = (temp48 &~ temp61)
175        temp69 = (temp67 &~ temp68)
176        temp70 = (temp62 &~ temp61)
177        temp71 = (temp69 &~ temp70)
178        temp72 = (temp32 &~ temp61)
179        temp73 = (temp71 &~ temp72)
180        temp74 = (temp28 &~ temp64)
181        temp75 = (temp73 &~ temp74)
182        lex.WS = (~temp75)
183        temp76 = (basis_bits.bit_5 | basis_bits.bit_6)
184        temp77 = (basis_bits.bit_4 & temp76)
185        lex.Digit = (temp39 &~ temp77)
186        temp78 = (temp48 | temp45)
187        lex.Sign = (temp28 & temp78)
188        temp79 = (temp1 &~ temp60)
189        temp80 = (temp79 &~ basis_bits.bit_4)
190        temp81 = (~temp44)
191        temp82 = ((basis_bits.bit_5 & temp81)|(~(basis_bits.bit_5) & temp17))
192        temp83 = (temp80 & temp82)
193        temp84 = (lex.Digit | temp83)
194        temp85 = (temp3 &~ basis_bits.bit_4)
195        temp86 = (temp85 & temp82)
196        lex.Hex = (temp84 | temp86)
197        temp87 = (temp44 &~ temp5)
198        lex.Hash = (temp28 & temp87)
199        lex.CR = (temp48 &~ temp61)
200        lex.LF = (temp62 &~ temp61)
201        lex.Oct = (temp39 &~ basis_bits.bit_4)
202        lex.Nonoct = (temp16 | temp19)
203        lex.Regular = ~ (lex.Special | lex.WS)
204
205       
206def Parse_Escaped(lex, parity, escape_Callouts, out_Callouts):
207 
208        escape_Callouts.LParen = lex.LParen
209        escape_Callouts.RParen = lex.RParen
210        escape_Callouts.Nonoct = 0
211        escape_Callouts.Oct1 = 0
212        escape_Callouts.Oct2 = 0
213        escape_Callouts.Oct3 = 0
214        out_Callouts.delmask = 0
215 
216        if lex.Backslash:
217
218          odd = parity.odd
219          even = parity.even
220
221          escape_mark = lex.Backslash
222          escaped = pablo.Advance(lex.Backslash)
223          # Check for \\ and longer backslash runs; mark the 1st, 3rd, 5th ...
224          # as escape_marks, the 2nd, 4th, 6th as escaped.
225          start = escape_mark & escaped
226          if start:
227                  #
228                  even_start = start & even     
229                  even_final = pablo.ScanThru(even_start, lex.Backslash) 
230                  escaped = even_final & odd
231                  escape_mark = even & pablo.SpanUpTo(even_start, even_final)
232                 
233                  odd_start = start & odd
234                  odd_final = pablo.ScanThru(odd_start, lex.Backslash)
235                  escaped = escaped | (odd_final & even)
236                  escape_mark |= (odd & pablo.SpanUpTo(odd_start, odd_final))
237
238          escape_Callouts.LParen = lex.LParen &~ escaped
239          escape_Callouts.RParen = lex.RParen &~ escaped
240          escape_Callouts.Nonoct = lex.Nonoct & escaped
241          escape_Callouts.Oct1 = lex.Oct & escaped
242          escape_Callouts.Oct2 = escape_Callouts.Oct1 & pablo.Lookahead(lex.Oct)
243          escape_Callouts.Oct1 &= ~escape_Callouts.Oct2
244          escape_Callouts.Oct3 = escape_Callouts.Oct2 & pablo.Lookahead(lex.Oct, 2)
245          escape_Callouts.Oct2 &= ~escape_Callouts.Oct3
246          out_Callouts.delmask = escape_mark
247
248# Modified version with comment processing
249#
250# Let pending_LParen be left parentheses for which we have a pending
251#   obligation to find the corresponding right parentheses.
252#
253# Let pending_Pct be Percent marks that have not yet been
254#   ruled out as comment opening delimiters
255#
256#
257def Match_Parens_With_Comments(lex, escape_Callouts, marker, out_Callouts):
258        instring = 0
259        closed_RParen = 0
260        marker.error = 0
261        line_starts = ~pablo.Advance(~lex.EOL)
262        line_ends1 = pablo.ScanTo(line_starts, lex.EOL | lex.Percent)
263        pending_Pct = line_ends1 & lex.Percent
264        known_outside_Ct = pablo.SpanUpTo(line_starts, line_ends1)
265        pending_LParen = known_outside_Ct & escape_Callouts.LParen
266        unmatched_RParen = escape_Callouts.RParen
267
268        inPlay = pending_LParen | unmatched_RParen | pending_Pct
269
270        while pending_LParen:
271
272                # Scan from pending ( marks to next [()%].   Everything we find
273                # must be within a string.
274                pscan = pablo.AdvanceThenScanTo(pending_LParen, inPlay)
275                instring |= pablo.ExclusiveSpan(pending_LParen, pscan) | pscan &~ escape_Callouts.RParen
276                closed_RParen |= pscan & escape_Callouts.RParen
277                marker.error |= pablo.atEOF(pscan)
278                pending_LParen = pscan & escape_Callouts.LParen
279                # Did we scan into a pending comment region?
280                pct_found = pscan & pending_Pct
281               
282                if pct_found:
283                        # The scan from the "(" was terminated prematurely by the "%" mark.
284                        # We include this position in pending_LParen so that the scan can
285                        # continue next time around.
286                        pending_LParen |= pct_found
287                        # Clear this % position as a line terminator, and find the next.
288                        # Determine the region that was previously identified as potentially
289                        # inside a comment and mark it as outside.
290                        line_ends1 &= ~pct_found
291                        line_ends1 |= pablo.AdvanceThenScanTo(pct_found, lex.EOL | lex.Percent)
292                        # Add any new potential comment delimiter to the pending ones.
293                        pending_Pct |= line_ends1 & lex.Percent
294                        newly_outside = pablo.SpanUpTo(pct_found, line_ends1)
295                        known_outside_Ct |= newly_outside
296                        # If any LParens have been revealed, add scan obligations for them
297                        pending_LParen |= newly_outside & escape_Callouts.LParen
298               
299                unmatched_RParen = escape_Callouts.RParen &~ closed_RParen                             
300                inPlay = pending_LParen | unmatched_RParen | pending_Pct
301        #
302        # No more scans to do.  Any pending pct marks are now known
303        # as definite comment delimiters.
304        comment_start = line_ends1 & lex.Percent
305        comment_end = pablo.ScanTo(comment_start, lex.EOL)
306        out_Callouts.mask = pablo.InclusiveSpan(comment_start, comment_end)
307        out_Callouts.mask |= instring
308        #
309        # Any closing paren that was not actually used to close
310        # an opener is in error.
311        marker.starts = escape_Callouts.LParen &~ out_Callouts.mask
312        marker.ends = pablo.AdvanceThenScanThru(marker.starts, instring)
313        marker.error |= escape_Callouts.RParen &~ closed_RParen &~ pablo.SpanUpTo(comment_start, comment_end)
314
315         
316def Parse_HexStrings(lex, marker, out_Callouts) :
317        hexString_starts = lex.LAngle &~ out_Callouts.mask
318        out_Callouts.hex_opener = hexString_starts
319        out_Callouts.hexString_mask = 0 
320        if hexString_starts:
321                hexString_ends = pablo.ScanThru(pablo.Advance(hexString_starts),lex.Hex|lex.WS)
322                marker.error |= hexString_ends &~ lex.RAngle
323                out_Callouts.hexString_mask = pablo.InclusiveSpan(hexString_starts,hexString_ends)
324                out_Callouts.mask |= out_Callouts.hexString_mask
325                marker.starts |= hexString_starts
326                marker.ends |= hexString_ends
327
328
329def Parse_Names(lex, marker, out_Callouts) :
330        name_starts =lex.Slash &~ out_Callouts.mask
331        names_follows = pablo.ScanThru(pablo.Advance(name_starts), lex.Regular)
332        out_Callouts.names_escapes = lex.Hash & pablo.Lookahead(lex.Hex) & pablo.Lookahead(lex.Hex,2) &~ out_Callouts.mask
333        out_Callouts.mask |= pablo.SpanUpTo(name_starts,names_follows)
334        marker.starts |= name_starts
335        marker.ends |= names_follows
336       
337def Parse_Numeric(lex, marker, out_Callouts) :
338        numeric_characters = (lex.Digit | lex.Period | lex.Sign)
339        numeric_starts = (numeric_characters &~ pablo.Advance(lex.Regular)) &~ out_Callouts.mask
340        numeric_follows = pablo.ScanThru(numeric_starts, lex.Regular)
341        marker.numeric_starts = numeric_starts 
342        marker.starts |= numeric_starts
343        marker.ends |= numeric_follows
344
345# Parse everything else: keywords, operators, array brackets   
346def Parse_Keywords(lex, marker, out_Callouts) :
347        keywords_starts = (lex.Regular &~ pablo.Advance(lex.Regular)) &~ out_Callouts.mask
348        keywords_follows = pablo.ScanThru(keywords_starts, lex.Regular)
349        marker.keyword_starts = keyword_starts
350        marker.starts |= keywords_starts | ((lex.LBracket | lex.RBracket)&~ out_Callouts.mask)
351        marker.ends |= keywords_follows
352       
353       
354       
355def Prepare_content_buffer(basis_bits, lex, marker, parity, escape_Callouts, out_Callouts):
356
357    out_Callouts.bit_0 = basis_bits.bit_0
358    out_Callouts.bit_1 = basis_bits.bit_1
359    out_Callouts.bit_2 = basis_bits.bit_2
360    out_Callouts.bit_3 = basis_bits.bit_3
361    out_Callouts.bit_4 = basis_bits.bit_4
362    out_Callouts.bit_5 = basis_bits.bit_5
363    out_Callouts.bit_6 = basis_bits.bit_6
364    out_Callouts.bit_7 = basis_bits.bit_7
365   
366    names_escapes_scope1 = pablo.Advance(out_Callouts.names_escapes)
367    names_escapes_scope2 = pablo.Advance(names_escapes_scope1)
368    hexstring_nameescape_mask = out_Callouts.hexString_mask | names_escapes_scope1 | names_escapes_scope2
369   
370    if hexstring_nameescape_mask:
371     
372        out_Callouts.delmask |= out_Callouts.hexString_mask & lex.WS
373       
374        NondigitHexString = lex.Hex &~ lex.Digit
375        out_Callouts.bit_0 &= ~hexstring_nameescape_mask
376        out_Callouts.bit_1 &= ~hexstring_nameescape_mask
377        out_Callouts.bit_2 &= ~hexstring_nameescape_mask
378        out_Callouts.bit_3 &= ~hexstring_nameescape_mask
379        out_Callouts.bit_4 |= (hexstring_nameescape_mask & NondigitHexString)
380        carry7 = out_Callouts.bit_7 & NondigitHexString & hexstring_nameescape_mask
381        out_Callouts.bit_7 ^= NondigitHexString & hexstring_nameescape_mask
382        carry6 = out_Callouts.bit_6 & carry7
383        out_Callouts.bit_6 ^= carry7
384        out_Callouts.bit_5 ^= carry6
385       
386    if out_Callouts.hexString_mask:
387        hexsting_partial_start = out_Callouts.hex_opener
388        hexsting_partial_odd_start = hexsting_partial_start & parity.odd
389        hexsting_partial_even_start = hexsting_partial_start & parity.even
390        hexsting_partial_odd_end = pablo.ScanThru(pablo.Advance(hexsting_partial_odd_start),lex.Hex)
391        hexsting_partial_even_end = pablo.ScanThru(pablo.Advance(hexsting_partial_even_start),lex.Hex)
392        hexsting_partial_odd_mask = pablo.ExclusiveSpan(hexsting_partial_odd_start,hexsting_partial_odd_end) | (hexsting_partial_odd_end & parity.odd)       
393        hexsting_partial_even_mask = pablo.ExclusiveSpan(hexsting_partial_even_start,hexsting_partial_even_end) | (hexsting_partial_even_end & parity.even)
394       
395        del_position = (hexsting_partial_odd_mask & parity.even) | (hexsting_partial_even_mask & parity.odd)
396        kept_position = (hexsting_partial_odd_mask & parity.odd) | (hexsting_partial_even_mask & parity.even)
397       
398         
399        hexsting_partial_end = hexsting_partial_odd_end | hexsting_partial_even_end
400        hexsting_partial_ends = hexsting_partial_end
401        kept_positions = kept_position
402        del_positions = del_position
403        del_pre_ends = 0
404        while hexsting_partial_end & lex.WS:
405          del_pre_end = del_position & pablo.Lookahead(lex.WS) 
406          kept_pre_end = kept_position & pablo.Lookahead(lex.WS) 
407         
408          del_even_start = pablo.ScanThru(pablo.Advance(del_pre_end),lex.WS) & parity.even
409          del_odd_start = pablo.ScanThru(pablo.Advance(del_pre_end),lex.WS) & parity.odd
410          kept_even_start = pablo.ScanThru(pablo.Advance(kept_pre_end),lex.WS) & parity.even
411          kept_odd_start = pablo.ScanThru(pablo.Advance(kept_pre_end),lex.WS) & parity.odd
412           
413          del_even_end = pablo.ScanThru(del_even_start,lex.Hex)
414          del_odd_end = pablo.ScanThru(del_odd_start,lex.Hex)
415          kept_even_end = pablo.ScanThru(kept_even_start,lex.Hex)
416          kept_odd_end = pablo.ScanThru(kept_odd_start,lex.Hex)
417         
418          hexsting_partial_odd_mask = pablo.InclusiveSpan(del_even_start,del_even_end) | pablo.InclusiveSpan(kept_odd_start,kept_odd_end) 
419          hexsting_partial_even_mask = pablo.InclusiveSpan(del_odd_start,del_odd_end) | pablo.InclusiveSpan(kept_even_start,kept_even_end)   
420         
421          hexsting_partial_end = del_even_end | del_odd_end | kept_even_end | kept_odd_end
422         
423          kept_position = (hexsting_partial_odd_mask & parity.even) | (hexsting_partial_even_mask & parity.odd)
424          del_position = (hexsting_partial_odd_mask & parity.odd) | (hexsting_partial_even_mask & parity.even)
425          del_position = del_position &~ hexsting_partial_end
426         
427          hexsting_partial_ends |= hexsting_partial_end
428          kept_positions |= kept_position
429          del_positions |= del_position
430          del_pre_ends |= del_pre_end
431         
432     
433        out_Callouts.bit_4 &= ~hexsting_partial_ends
434        out_Callouts.bit_5 &= ~hexsting_partial_ends
435        out_Callouts.bit_6 &= ~hexsting_partial_ends
436        out_Callouts.bit_7 &= ~hexsting_partial_ends
437     
438        out_Callouts.bit_0 = pablo.Advance(del_positions & out_Callouts.bit_4) | (out_Callouts.bit_0 & ~kept_positions) | pablo.ScanThru(pablo.Advance((out_Callouts.bit_4 & del_pre_ends)), lex.WS)
439        out_Callouts.bit_1 = pablo.Advance(del_positions & out_Callouts.bit_5) | (out_Callouts.bit_1 & ~kept_positions) | pablo.ScanThru(pablo.Advance((out_Callouts.bit_5 & del_pre_ends)), lex.WS)
440        out_Callouts.bit_2 = pablo.Advance(del_positions & out_Callouts.bit_6) | (out_Callouts.bit_2 & ~kept_positions) | pablo.ScanThru(pablo.Advance((out_Callouts.bit_6 & del_pre_ends)), lex.WS) 
441        out_Callouts.bit_3 = pablo.Advance(del_positions & out_Callouts.bit_7) | (out_Callouts.bit_3 & ~kept_positions) | pablo.ScanThru(pablo.Advance((out_Callouts.bit_7 & del_pre_ends)), lex.WS) 
442       
443        out_Callouts.delmask |= del_positions
444           
445       
446
447    if escape_Callouts.Nonoct:       
448        out_Callouts.bit_1 ^= ( lex.pdf_mod_bit_1 & escape_Callouts.Nonoct)
449        out_Callouts.bit_2 ^= ( lex.pdf_mod_bit_2 & escape_Callouts.Nonoct)
450        out_Callouts.bit_3 ^= ( lex.pdf_mod_bit_3 & escape_Callouts.Nonoct)
451        out_Callouts.bit_4 ^= ( lex.pdf_mod_bit_4 & escape_Callouts.Nonoct)
452        out_Callouts.bit_5 ^= ( lex.pdf_mod_bit_5 & escape_Callouts.Nonoct)
453        out_Callouts.bit_6 ^= ( lex.pdf_mod_bit_6 & escape_Callouts.Nonoct)
454        out_Callouts.bit_7 ^= ( lex.pdf_mod_bit_7 & escape_Callouts.Nonoct)
455       
456    if out_Callouts.names_escapes:
457        out_Callouts.delmask |= out_Callouts.names_escapes | names_escapes_scope1
458        out_Callouts.bit_0 = (out_Callouts.bit_0 &~ names_escapes_scope2) 
459        out_Callouts.bit_1 = (out_Callouts.bit_1 &~ names_escapes_scope2)
460        out_Callouts.bit_2 = (out_Callouts.bit_2 &~ names_escapes_scope2) 
461        out_Callouts.bit_3 = (out_Callouts.bit_3 &~ names_escapes_scope2) 
462        out_Callouts.bit_0 |= pablo.Advance(out_Callouts.bit_4 & names_escapes_scope1)
463        out_Callouts.bit_1 |= pablo.Advance(out_Callouts.bit_5 & names_escapes_scope1)
464        out_Callouts.bit_2 |= pablo.Advance(out_Callouts.bit_6 & names_escapes_scope1)
465        out_Callouts.bit_3 |= pablo.Advance(out_Callouts.bit_7 & names_escapes_scope1) 
466       
467    if escape_Callouts.Oct1:
468        out_Callouts.bit_0 = (out_Callouts.bit_0 &~ escape_Callouts.Oct1) 
469        out_Callouts.bit_1 = (out_Callouts.bit_1 &~ escape_Callouts.Oct1)
470        out_Callouts.bit_2 = (out_Callouts.bit_2 &~ escape_Callouts.Oct1) 
471        out_Callouts.bit_3 = (out_Callouts.bit_3 &~ escape_Callouts.Oct1) 
472     
473    if escape_Callouts.Oct2:
474        out_Callouts.delmask |= escape_Callouts.Oct2
475        Oct2_scope1 = pablo.Advance(escape_Callouts.Oct2)
476        out_Callouts.bit_2 = (out_Callouts.bit_2 &~ Oct2_scope1) | pablo.Advance(out_Callouts.bit_5 & escape_Callouts.Oct2)
477        out_Callouts.bit_3 = (out_Callouts.bit_3 &~ Oct2_scope1) | pablo.Advance(out_Callouts.bit_6 & escape_Callouts.Oct2)
478        out_Callouts.bit_4 = (out_Callouts.bit_4 &~ Oct2_scope1) | pablo.Advance(out_Callouts.bit_7 & escape_Callouts.Oct2)
479       
480    if escape_Callouts.Oct3:
481        Oct3_scope1 = pablo.Advance(escape_Callouts.Oct3)
482        Oct3_scope2 = pablo.Advance(Oct3_scope1)
483        out_Callouts.delmask |= escape_Callouts.Oct3 | Oct3_scope1
484        temp0 = pablo.Advance(out_Callouts.bit_6 & escape_Callouts.Oct3)
485        temp1 = pablo.Advance(out_Callouts.bit_7 & escape_Callouts.Oct3)
486        out_Callouts.bit_0 = (out_Callouts.bit_0 &~ Oct3_scope2) | pablo.Advance(temp0)
487        out_Callouts.bit_1 = (out_Callouts.bit_1 &~ Oct3_scope2) | pablo.Advance(temp1)
488        out_Callouts.bit_2 = (out_Callouts.bit_2 &~ Oct3_scope2) | pablo.Advance(out_Callouts.bit_5 & Oct3_scope1)
489        out_Callouts.bit_3 = (out_Callouts.bit_3 &~ Oct3_scope2) | pablo.Advance(out_Callouts.bit_6 & Oct3_scope1)
490        out_Callouts.bit_4 = (out_Callouts.bit_4 &~ Oct3_scope2) | pablo.Advance(out_Callouts.bit_7 & Oct3_scope1)       
491     
492 
493    out_Callouts.zeromask = out_Callouts.delmask 
494    out_Callouts.bit_0 = out_Callouts.bit_0 &~ out_Callouts.zeromask   
495    out_Callouts.bit_1 = out_Callouts.bit_1 &~ out_Callouts.zeromask
496    out_Callouts.bit_2 = out_Callouts.bit_2 &~ out_Callouts.zeromask
497    out_Callouts.bit_3 = out_Callouts.bit_3 &~ out_Callouts.zeromask
498    out_Callouts.bit_4 = out_Callouts.bit_4 &~ out_Callouts.zeromask
499    out_Callouts.bit_5 = out_Callouts.bit_5 &~ out_Callouts.zeromask
500    out_Callouts.bit_6 = out_Callouts.bit_6 &~ out_Callouts.zeromask
501    out_Callouts.bit_7 = out_Callouts.bit_7 &~ out_Callouts.zeromask
502    marker.starts =  marker.starts &~ out_Callouts.zeromask
503    marker.ends =  marker.ends &~ out_Callouts.zeromask
504   
505#
506# Make sure all three forms of linebreak (CR, CRLF, LF) are translated to a
507# single LF.
508#
509def Normalize_WS(lex, out_Callouts):
510        if lex.CR:
511                # Modify CR (#x0D) to LF (#x0A)
512                out_Callouts.bit_5 ^= lex.CR
513                out_Callouts.bit_6 ^= lex.CR
514                out_Callouts.bit_7 ^= lex.CR
515                CRLF = pablo.Advance(lex.CR) & lex.LF
516                out_Callouts.delmask |= CRLF
517
518
519def Main(basis_bits, lex, escape_Callouts, out_Callouts):
520  pass
521
522
523
524
Note: See TracBrowser for help on using the repository browser.