File: README

package info (click to toggle)
libcql-parser-perl 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 324 kB
  • sloc: perl: 2,388; makefile: 2
file content (113 lines) | stat: -rw-r--r-- 4,148 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
NAME
    CQL::Parser - compiles CQL strings into parse trees of Node subtypes.

SYNOPSIS
        use CQL::Parser;
        my $parser = CQL::Parser->new();
        my $root = $parser->parse( $cql );

DESCRIPTION
    CQL::Parser provides a mechanism to parse Common Query Language (CQL)
    statements. The best description of CQL comes from the CQL homepage at
    the Library of Congress <http://www.loc.gov/z3950/agency/zing/cql/>

    CQL is a formal language for representing queries to information
    retrieval systems such as web indexes, bibliographic catalogs and museum
    collection information. The CQL design objective is that queries be
    human readable and human writable, and that the language be intuitive
    while maintaining the expressiveness of more complex languages.

    A CQL statement can be as simple as a single keyword, or as complicated
    as a set of compoenents indicating search indexes, relations, relational
    modifiers, proximity clauses and boolean logic. CQL::Parser will parse
    CQL statements and return the root node for a tree of nodes which
    describes the CQL statement. This data structure can then be used by a
    client application to analyze the statement, and possibly turn it into a
    query for a local repository.

    Each CQL component in the tree inherits from CQL::Node and can be one of
    the following: CQL::AndNode, CQL::NotNode, CQL::OrNode, CQL::ProxNode,
    CQL::TermNode, CQL::PrefixNode. See the documentation for those modules
    for their respective APIs.

    Here are some examples of CQL statements:

    *   george

    *   dc.creator=george

    *   dc.creator="George Clinton"

    *   clinton and funk

    *   clinton and parliament and funk

    *   (clinton or bootsy) and funk

    *   dc.creator="clinton" and dc.date="1976"

METHODS
  new()
  parse( $query )
    Pass in a CQL query and you'll get back the root node for the CQL parse
    tree. If the CQL is invalid an exception will be thrown.

  parseSafe( $query )
    Pass in a CQL query and you'll get back the root node for the CQL parse
    tree. If the CQL is invalid, an error code from the SRU Diagnostics List
    will be returned.

XCQL
    CQL has an XML representation which you can generate from a CQL parse
    tree. Just call the toXCQL() method on the root node you get back from a
    call to parse().

ERRORS AND DIAGNOSTICS
    As mentioned above, a CQL syntax error will result in an exception being
    thrown. So if you have any doubts about the CQL that you are parsing you
    should wrap the call to parse() in an eval block, and check $@
    afterwards to make sure everything went ok.

        eval {
            my $node = $parser->parse( $cql );
        };
        if ( $@ ) {
            print "uhoh, exception $@\n";
        }

    If you'd like to see blow by blow details while your CQL is being parsed
    set $CQL::DEBUG equal to 1, and you will get details on STDERR. This is
    useful if the parse tree is incorrect and you want to locate where
    things are going wrong. Hopefully this won't happen, but if it does
    please notify the author.

TODO
    *   toYourEngineHere() please feel free to add functionality and send in
        patches!

THANKYOUS
    CQL::Parser is essentially a Perl port of Mike Taylor's cql-java package
    http://zing.z3950.org/cql/java/. Mike and IndexData were kind enough to
    allow the author to write this port, and to make it available under the
    terms of the Artistic License. Thanks Mike!

    The CQL::Lexer package relies heavily on Stevan Little's excellent
    String::Tokenizer. Thanks Stevan!

    CQL::Parser was developed as a component of the Ockham project, which is
    funded by the National Science Foundation. See http://www.ockham.org for
    more information about Ockham.

AUTHOR
    *   Ed Summers - ehs at pobox dot com

    *   Brian Cassidy - bricas at cpan dot org

    *   Wilbert Hengst - W.Hengst at uva dot nl

COPYRIGHT AND LICENSE
    Copyright 2004-2009 by Ed Summers

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.