Package gavo :: Package adql
[frames] | no frames]

Source Code for Package gavo.adql

 1  """ 
 2  Parsing, annotating, and morphing queries in the Astronomical Data 
 3  Query Language. 
 4  """ 
 5   
 6  #c Copyright 2008-2019, the GAVO project 
 7  #c 
 8  #c This program is free software, covered by the GNU GPL.  See the 
 9  #c COPYING file in the source distribution. 
10   
11   
12  # Not checked by pyflakes: API file with gratuitous imports 
13   
14  from gavo.adql.annotations import annotate 
15   
16  from gavo.adql.common import * 
17   
18  from gavo.adql.tree import ( 
19          getTreeBuildingGrammar, registerNode) 
20   
21  from gavo.adql.nodes import flatten 
22   
23  from gavo.adql.grammar import ( 
24          getADQLGrammar as getRawGrammar,  
25          allReservedWords, 
26          ParseException, ParseSyntaxException) 
27   
28  from gavo.adql.morphpg import ( 
29          morphPG) 
30   
31  from gavo.adql.fieldinfo import getSubsumingType, FieldInfo 
32   
33  from gavo.adql.ufunctions import userFunction 
34   
35  from gavo.adql.postproc import builtinMorph 
36   
37   
38 -def getSymbols():
39 return getTreeBuildingGrammar()[0]
40
41 -def getGrammar():
42 return getTreeBuildingGrammar()[1]
43
44 -def parseToTree(adqlStatement):
45 """returns a "naked" parse tree for adqlStatement. 46 47 It contains no annotations, so you'll usually not want to use this. 48 """ 49 return utils.pyparseString(getGrammar(), adqlStatement)[0]
50
51 -def parseAnnotating(adqlStatement, fieldInfoGetter):
52 """returns a tuple of context, parsedTree for parsing and annotating 53 adqlStatement. 54 55 The builtin morphs are performed on the tree. 56 """ 57 parsedTree = parseToTree(adqlStatement) 58 ctx = annotate(parsedTree, fieldInfoGetter) 59 return ctx, builtinMorph(parsedTree)[1]
60