From 2d82f5e172577a498d19396b210ca28553683310 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 14 Jun 2010 12:36:42 +0200 Subject: [PATCH] Add CQL 1.2 / 2.0 YACC grammars --- src/cql1.2.y | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/cql2.0.y | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/cqlstd.y | 60 ------------------------------------------------------- 3 files changed, 122 insertions(+), 60 deletions(-) create mode 100644 src/cql1.2.y create mode 100644 src/cql2.0.y delete mode 100644 src/cqlstd.y diff --git a/src/cql1.2.y b/src/cql1.2.y new file mode 100644 index 0000000..0a908ec --- /dev/null +++ b/src/cql1.2.y @@ -0,0 +1,59 @@ +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2010 Index Data + * See the file LICENSE for details. + */ +/* + YACC CQL grammar taken verbatim from the official 1.2 spec + */ +%term GE LE NE AND OR NOT PROX CHARSTRING1 CHARSTRING2 SORTBY + +%% +sortedQuery : prefixAssignment sortedQuery + | scopedClause + | scopedClause SORTBY sortSpec; + +sortSpec : sortSpec singleSpec | singleSpec; +singleSpec : index modifierList | index ; + +cqlQuery : prefixAssignment cqlQuery | scopedClause; + +prefixAssignment : '>' prefix '=' uri | '>' uri; + +scopedClause : scopedClause booleanGroup searchClause | searchClause ; + +booleanGroup: boolean | boolean modifierList; + +boolean : AND | OR | NOT | PROX ; + +searchClause : '(' cqlQuery ')' + | index relation searchTerm + | searchTerm + ; + +relation : comparitor | comparitor modifierList; + +comparitor : comparitorSymbol | namedComparitor ; + +comparitorSymbol : '=' | '>' | '<' | GE | LE | NE; + +namedComparitor : identifier; + +modifierList : modifierList modifier | modifier; + +modifier : '/' modifierName + | '/' modifierName comparitorSymbol modifierValue + ; + + +prefix : term; +uri : term; +modifierName: term; +modifierValue: term; +searchTerm: term; +index: term; + +term: identifier | AND | OR | NOT | PROX | SORTBY ; + +identifier: CHARSTRING1 | CHARSTRING2; + +%% diff --git a/src/cql2.0.y b/src/cql2.0.y new file mode 100644 index 0000000..1c5f364 --- /dev/null +++ b/src/cql2.0.y @@ -0,0 +1,63 @@ +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2010 Index Data + * See the file LICENSE for details. + */ +/* + YACC CQL grammar taken verbatim from the 2.0 draft (June 2010). + */ +%term PREFIX_NAME QUOTED_URI_STRING QUOTED_STRING AND OR NOT PROX SORTBY SIMPLE_STRING + +%% +cql_query : query | query sort_spec; + +query : prefix_assignment search_clause_group | search_clause_group ; + +search_clause_group: search_clause_group boolean_modified subquery | subquery; + +subquery : '(' query ')' | search_clause; + +search_clause: index relation_modified search_term | search_term; + +search_term : SIMPLE_STRING | QUOTED_STRING; + +sort_spec : sort_by index_modified_list; + +sort_by: SORTBY; + +index_modified_list: index_modified_list index_modified | index_modified; + +prefix_assignment: '>' prefix '=' uri | '>' uri; + +prefix: SIMPLE_STRING; + +uri : QUOTED_URI_STRING; + +index_modified: index modifier_list | index; + +index : simple_name | PREFIX_NAME; + +relation_modified : relation modifier_list | relation; + +relation : relation_name | relation_symbol; + +relation_name: simple_name | PREFIX_NAME; + +relation_symbol : '=' | '>' | '<' ; + +boolean_modified : boolean modifier_list | boolean; + +boolean : AND | OR | NOT | PROX; + +modifier_list : modifier_list modifier | modifier; + +modifier : '/' modifier_name modifier_relation | '/' modifier_name; + +modifier_name: simple_name; + +modifier_relation : relation_symbol modifier_value; + +modifier_value : SIMPLE_STRING | QUOTED_STRING; + +simple_name: SIMPLE_STRING; + +%% diff --git a/src/cqlstd.y b/src/cqlstd.y deleted file mode 100644 index 2daec40..0000000 --- a/src/cqlstd.y +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2008 Index Data - * See the file LICENSE for details. - */ -/* - YACC CQL grammar taken verbatim from the official spec. We don't - use that in YAZ but I don't know of a better place to put it. - */ -%term GE LE NE AND OR NOT PROX CHARSTRING1 CHARSTRING2 SORTBY - -%% -sortedQuery : prefixAssignment sortedQuery - | scopedClause - | scopedClause SORTBY sortSpec; - -sortSpec : sortSpec singleSpec | singleSpec; -singleSpec : index modifierList | index ; - -cqlQuery : prefixAssignment cqlQuery | scopedClause; - -prefixAssignment : '>' prefix '=' uri | '>' uri; - -scopedClause : scopedClause booleanGroup searchClause | searchClause ; - -booleanGroup: boolean | boolean modifierList; - -boolean : AND | OR | NOT | PROX ; - -searchClause : '(' cqlQuery ')' - | index relation searchClause - | searchTerm - ; - -relation : comparitor | comparitor modifierList; - -comparitor : comparitorSymbol | namedComparitor ; - -comparitorSymbol : '=' | '>' | '<' | GE | LE | NE; - -namedComparitor : identifier; - -modifierList : modifierList modifier | modifier; - -modifier : '/' modifierName - | '/' modifierName comparitorSymbol modifierValue - ; - - -prefix : term; -uri : term; -modifierName: term; -modifierValue: term; -searchTerm: term; -index: term; - -term: identifier | AND | OR | NOT | PROX | SORTBY ; - -identifier: CHARSTRING1 | CHARSTRING2; - -%% -- 1.7.10.4