source: proto/CSV/csvclass.py @ 3820

Last change on this file since 3820 was 372, checked in by lindanl, 10 years ago

CSV parsing prototype with backslash escape convention

File size: 1.2 KB
RevLine 
[372]1#
2# csvclass.py
3#
4# Bitstream definitions for CSV character classes.
5# Automatically generated using
6# chardeflist2py(DefinitionSet['CSV'])
7#
8# Dan Lin
9# March, 06, 2010
10#
11
12
13 
14class lexical_streams ():
15  BackSlash = 0
16  DQuote = 0
17  SQuote = 0
18  CR = 0
19  LF = 0
20  Comma = 0
21  Period = 0
22  HT = 0
23
24
25def classify_bytes(bit) :
26   lex = lexical_streams()
27   temp1 = bit[1] &~ bit[0]
28   temp2 = bit[3] &~ bit[2]
29   temp3 = temp1 & temp2
30   temp4 = bit[4] & bit[5]
31   temp5 = bit[6] | bit[7]
32   temp6 = temp4 &~ temp5
33   lex.BackSlash = temp3 & temp6
34   temp7 = bit[0]| bit[1]
35   temp8 = bit[2] &~ bit[3]
36   temp9 = temp8 &~ temp7
37   temp10 = bit[4] | bit[5]
38   temp11 = bit[6] &~ bit[7]
39   temp12 = temp11 &~ temp10
40   lex.DQuote = temp9 & temp12
41   temp13 = bit[5] &~ bit[4]
42   temp14 = bit[6] & bit[7]
43   temp15 = temp13 & temp14
44   lex.SQuote = temp9 & temp15
45   temp16 = bit[2] | bit[3]
46   temp17 = temp7 | temp16
47   temp18 = bit[7] &~ bit[6]
48   temp19 = temp4 & temp18
49   lex.CR = temp19 &~ temp17
50   temp20 = bit[4] &~ bit[5]
51   temp21 = temp20 & temp11
52   lex.LF = temp21 &~ temp17
53   lex.Comma = temp9 & temp6
54   temp22 = temp20 & temp18
55   lex.HT = temp22 &~ temp17
56   temp23 = temp4 & temp11
57   lex.Period = temp9 & temp23
58   return lex
59
Note: See TracBrowser for help on using the repository browser.