2007-06-02 | paulb | file changeset files shortlog | Changed the pyparsing implementation to return the same regions output as the regular expression implementation. Added a simple test program. |
paulb@2 | 1 | #!/usr/bin/env python |
paulb@2 | 2 | |
paulb@2 | 3 | "Test sqlliterals." |
paulb@2 | 4 | |
paulb@2 | 5 | import sqlliterals.pyparser |
paulb@2 | 6 | import sqlliterals.regexp |
paulb@2 | 7 | |
paulb@2 | 8 | def show(regions): |
paulb@2 | 9 | non_literal = 1 |
paulb@2 | 10 | for region in regions: |
paulb@2 | 11 | print region, |
paulb@2 | 12 | if non_literal: |
paulb@2 | 13 | print "(NL)", |
paulb@2 | 14 | else: |
paulb@2 | 15 | print "(L)", |
paulb@2 | 16 | non_literal = not non_literal |
paulb@2 | 17 | print |
paulb@2 | 18 | |
paulb@2 | 19 | l = [ |
paulb@2 | 20 | "a = a", |
paulb@2 | 21 | "a = 'a'", |
paulb@2 | 22 | "'a' = a", |
paulb@2 | 23 | "'a' = 'a'", |
paulb@2 | 24 | "a = ''''", |
paulb@2 | 25 | "'''' = a", |
paulb@2 | 26 | "'''' = ''''", |
paulb@2 | 27 | "a = '''a'''", |
paulb@2 | 28 | "'''a''' = a", |
paulb@2 | 29 | "'''a''' = '''a'''" |
paulb@2 | 30 | ] |
paulb@2 | 31 | |
paulb@2 | 32 | for s in l: |
paulb@2 | 33 | show(sqlliterals.pyparser.parseString(s)) |
paulb@2 | 34 | show(sqlliterals.regexp.parseString(s)) |
paulb@2 | 35 | |
paulb@2 | 36 | # vim: tabstop=4 expandtab shiftwidth=4 |