Skip to main content

%DeepSee.Query.Parser

Class %DeepSee.Query.Parser Extends %RegisteredObject [ System = 3 ]

Contains the DeepSee MDX query parser and related APIs.
This class contains no publicly accessible code.

Properties

Trace

Property Trace As %Boolean [ InitialExpression = 0 ];

Debug flag.

Text

Property Text As %String;

Query text.

Position

Property Position As %Integer;

Current position within query text.

LastToken

Property LastToken As %String;

Most recently parsed token (used for error reporting).

InSearch

Property InSearch As %Boolean [ InitialExpression = 0 ];

Indicates the current tokens are within the %SEARCH context

Bookmark

Property Bookmark As %Integer;

Current bookmark position within query text.

%Stack

Property %Stack As %Integer [ MultiDimensional ];

Context stack.

Query

Property Query As %DeepSee.Query.query;

The query object this parser is constructing.

CubeName

Property CubeName As %DeepSee.Datatype.entityName;

Cubename within the current query.

Methods

%ParseMDX

ClassMethod %ParseMDX(pText As %String, pQuery As %DeepSee.Query.query = "", pTrace As %Boolean = 0) As %Status [ Internal ]

Simple MDX parser. Convert the MDX query in pText into a set of DeepSee query objects (applied to pQuery).
If pQuery is not supplied, a new query object is created and returned.

%ParseMDXExpression

ClassMethod %ParseMDXExpression(pText As %String, pQuery As %DeepSee.Query.query, pGroup As %DeepSee.Query.group, Output pNode As %DeepSee.Query.node, pCube As %String = "") As %Status [ Internal ]

Simple MDX expression parser. Convert the MDX expression in pExpression into a set of DeepSee query objects (applied to pGroup).
pQuery is the outer query context which is calling this. pCube is an optional cube to query, otherwise the one in the query context is used.

%Tokenize

ClassMethod %Tokenize(pText As %String, Output pTokens As %List) As %Status [ Internal ]

Take the text in pText and convert it to a list of tokens using MDX grammar: pTokens(n) = $LB(type,value)

%AtEnd

Method %AtEnd() As %Boolean [ CodeMode = expression, Internal ]

Test if we are the end of the statement.

%SetBookmark

Method %SetBookmark() [ Internal ]

Bookmark the current parsing position.
This allows us to push a token back onto the incoming stream.

%GotoBookmark

Method %GotoBookmark() [ Internal ]

Revert to last set bookmark.

%PushContext

Method %PushContext(pText As %String) [ Internal ]

Push the current parsing state and use pText as a token source.

%PopContext

Method %PopContext() [ Internal ]

Pop the current parsing state restore the prior state.

%IsSpecialChar

ClassMethod %IsSpecialChar(char As %String) As %Boolean [ CodeMode = expression, Internal ]

Test if char is a special character

%IsArrowToken

ClassMethod %IsArrowToken(token As %String) As %Boolean [ CodeMode = expression, Internal ]

Test if token is a special token

%IsOperatorChar

ClassMethod %IsOperatorChar(char As %String) As %Boolean [ CodeMode = expression, Internal ]

Test if char is a part of an operator name

%IsOperatorToken

ClassMethod %IsOperatorToken(token As %String) As %Boolean [ CodeMode = expression, Internal ]

Test if token is an operator name.

%IsUnaryOperatorToken

ClassMethod %IsUnaryOperatorToken(token As %String) As %Boolean [ CodeMode = expression, Internal ]

Test if token is a unary operator name.

%IsQuotedIdent

ClassMethod %IsQuotedIdent(pIdent As %String) As %Boolean [ CodeMode = expression, Internal ]

Test whether pIdent is a quoted identifier.

%UnquoteIdent

ClassMethod %UnquoteIdent(pIdent As %String) As %String [ CodeMode = expression, Internal ]

Return the string portion of a quoted identifier.

%QuoteIdent

ClassMethod %QuoteIdent(pIdent As %String) As %String [ CodeMode = expression, Internal ]

Return a quoted version of the given identifier. Ignore special "&" character as well as @namedParms Do not add quotes if pIdent is already bounded by a [] pair

%QuoteTrustedIdent

ClassMethod %QuoteTrustedIdent(pIdent As %String) As %String [ CodeMode = expression, Internal ]

Return a quoted version of the given identifier. Do not check to see if the identifier is already quoted Ignore special "&" character as well as @namedParms

%BuildEscapedSpec

ClassMethod %BuildEscapedSpec(pIdentifierList As %List, Output pStatus As %Status, pIncludeKey As %Boolean = 0) As %String

Return a spec with escaped identifiers, translating each "]" into a "]]" to escape the closing quote. The argument pIdentifierList may be a list of any length. The method will terminate construction upon encountering the first null entry in the list.
The pIncludeKey flag can be used to add a "&[]"-enclosed key as the final pice of the spec generated from the pIdentifierList. By default the method will asume no key is included in the list.

%NextToken

Method %NextToken(Output pType As %String, Output tSC As %Status) As %String [ Internal ]

Return next token within the query text and its type. Type can be NUM[ber], LIT[eral], STR[ing], QSTR, OP[erator], SPEC[ial], END. If there are comments, they are removed.

%ValidateNamedParm

Method %ValidateNamedParm(pParmName As %String) As %Status [ Internal ]

Syntactically validate the given named parameter.

%Trace

Method %Trace(pText As %String, pIndent As %Integer = 0) As %Boolean [ CodeMode = expression, Internal ]

Print a trace message if trace is enabled.

%TraceMsg

Method %TraceMsg(pText As %String, pIndent As %Integer = 0) As %Boolean [ Internal ]

Print out trace message (do not call directly).

%Error

Method %Error(pMsg As %String, pToken As %String = "") As %Status [ Internal ]

Construct a parser error message.

%ParseStatement

Method %ParseStatement(pQuery As %DeepSee.Query.query) As %Status [ Internal ]

Parse an MDX statement.
Apply the results to pQuery.

%ParseWITH

Method %ParseWITH(pMode As %String = "with") As %Status

Parse an MDX WITH statement. If pMode is "with", then this is a WITH clause of a query; If pMode is "set" or "member", then this is a CREATE statement;

%ParseSELECT

Method %ParseSELECT() As %Status [ Internal ]

Parse an MDX SELECT statement.

%ParseAXIS

Method %ParseAXIS(Output pAxisNum As %String, Output pAxis As %DeepSee.Query.axis, pMode As %Integer = 0) As %Status [ Internal ]

Parse an MDX Axis Specification statement.
pMode specifies context: 0 = axis, 1 = slicer, 2 = %filter, (3 = named set).

%ParseMEMBER

Method %ParseMEMBER(pParent As %DeepSee.Query.group, Output pNode As %DeepSee.Query.node, pCloseToken As %String, pMode As %Integer, ByRef pFlags As %String, pLevel As %Integer = 1) As %Status [ Internal ]

Parse a member expression within an MDX axis.
This can be a simple member specifier: "[Measures].[Sales]"
A range: "[Time].[2005]:[Time].[2008]"
or an expression: "[Measures].[Sales]>100*[Measures].[X]"
The member expression can contain a function: "FILTER(A.B,C.D)"
or a set: "{A.A,B.B}"
or a range: "{A.A:A.B}"
or a tuple: "(A.A,B.B)"
or some combination of these.
On return, pNode is the newly created query object along with whatever children it needs..
pCloseToken is the token expected to end the tuple (such as ")" for a function).
pMode specifies context: 0 = axis, 1 = slicer, 2 = %filter, 3 = named set.
n.b., mode 2 is not used! If pFlags is present, it contains the set of valid function flags (we are parsing a function call in this case)...

%RemoveParens

Method %RemoveParens(pNodeNo As %Integer, ByRef pTree, pEmpty As %Boolean) As %Status [ Internal ]

Remove unneeded parens from tree. pEmpty is set true (1) if the node has only parens and can be removed.

%ProcessMemberNode

Method %ProcessMemberNode(pNodeNo As %Integer, ByRef pTree, ByRef pObjList, Output pObj As %DeepSee.Query.node) As %Status [ Internal ]

Used by parseMEMBER to convert expression trees into query objects.
pNodeNo is the top node number in the tree.
pTree is the expression tree.
pObjList an array of objects referenced by the tree.
pObj is the newly created object.

%ParseFROM

Method %ParseFROM() As %Status [ Internal ]

Parse an MDX FROM statement.

%ParseWHERE

Method %ParseWHERE() As %Status [ Internal ]

Parse an MDX WHERE statement.

%ParseFILTER

Method %ParseFILTER() As %Status [ Internal ]

Parse an MDX %FILTER statement. %FILTER is an ISC extension.

%ParseRETURN

Method %ParseRETURN() As %Status [ Internal ]

Parse an MDX RETURN statement (used by DRILLTHROUGH statements). A RETURN statement is basically the SELECT list used against the source table to return rows.
Also tests for %LISTING statement: "DRILLTHROUGH ... %LISTING LISTINGNAME"

%ParseMemberSpec

ClassMethod %ParseMemberSpec(pText As %String, Output pInfo, Output pQuoted, Output pMemberKey) As %Status [ Internal ]

Take a string containing a member specification, "[Member1].[Member2]", and return an array of the member names indexed by ordinal position as well as an array of whether a term was quoted or not.
pMemberKey is array indicating if a member key (&[]) is specified for an item.
This is used later in query processing.

%OnNew

Method %OnNew(text As %RawString) As %Status [ Internal, Private, ServerOnly = 1 ]

This callback method is invoked by the %New method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status

%TestPrecedence

ClassMethod %TestPrecedence(op1 As %String, op2 As %String) As %Boolean [ Internal ]

Returns true if op1 has precedence over op2.

%ValidateText

Method %ValidateText(pQuery As %DeepSee.Query.query = {$$$NULLOREF}, pText = "") As %Status

Perform initial checks on the MDX text itself to see if there are obvious errors that can be reported without further processing.