Skip to content

lawref.query.parser

Рекурсивный спуск LawQL без внешних зависимостей (Ф2/Ф3/Ф5).

Attributes

NameDescription
KEYWORDSNo description.
TOKEN_RENo description.

Classes

NameDescription
BindingNo description.
ExprNo description.
InferenceQueryNo description.
MaterializationNo description.
ParserNo description.
QueryNo description.
SelectionNo description.
SourceNo description.
TokenNo description.

Functions

NameDescription
metadataNo description.
parseNo description.
tokenizeNo description.

KEYWORDSattributemodule attribute#

KEYWORDS = {
  'from',
  'in',
  'where',
  'select',
  'as',
  'and',
  'or',
  'exists',
  'not',
  'let',
  'eval',
  'true',
  'false',
  'null',
  'query',
  'over'
}

TOKEN_REattributemodule attribute#

TOKEN_RE = re.compile(
  '(?P<SPACE>[ \\t\\r\\n]+)|(?P<COMMENT>\\#[^\\n]*)|(?P<STRING>\\"(?:\\\\.|[^\\"\\\\])*\\"|\'(?:\\\\.|[^\'\\\\])*\')|(?P<NUMBER>-?[0-9]+(?:\\.[0-9]+)?)|(?P<OP>==|!=|>=|<=|>|<)|(?P<PUNCT>[(),.={}\\[\\]:;])|(?P<IDENT>[A-Za-z_][A-Za-z0-9_-]*)|(?P<BAD>.)'
)

Bindingclassdataclass#

class Binding(name: str, source: Source)

nameattributeinstance attribute#

name: str

sourceattributeinstance attribute#

source: Source

Exprclassdataclass#

class Expr(kind: str, value: Any = None, left: 'Expr | None' = None, right: 'Expr | None' = None, args: tuple['Expr', ...] = ())

argsattributeclass attributeinstance attribute#

args: tuple['Expr', ...] = ()

kindattributeinstance attribute#

kind: str

leftattributeclass attributeinstance attribute#

left: 'Expr | None' = None

rightattributeclass attributeinstance attribute#

right: 'Expr | None' = None

valueattributeclass attributeinstance attribute#

value: Any = None

InferenceQueryclassdataclass#

class InferenceQuery(name: str, package: str, body: str, metadata: dict[str, str], source: str)

bodyattributeinstance attribute#

body: str

metadataattributeinstance attribute#

metadata: dict[str, str]

nameattributeinstance attribute#

name: str

packageattributeinstance attribute#

package: str

sourceattributeinstance attribute#

source: str

Materializationclassdataclass#

class Materialization(name: str, package: str, case: str)

caseattributeinstance attribute#

case: str

nameattributeinstance attribute#

name: str

packageattributeinstance attribute#

package: str

Parserclass#

class Parser(source: str)

indexattributeinstance attribute#

index = 0

sourceattributeinstance attribute#

source = source

tokensattributeinstance attribute#

tokens = tokenize(source)

currentproperty#

current: Token

acceptmethod#

def accept(kind: str, value: str | None = None) -> Token | None

and_exprmethod#

def and_expr() -> Expr

comparisonmethod#

def comparison() -> Expr

exists_exprmethod#

def exists_expr() -> Expr

expectmethod#

def expect(kind: str, message: str | None = None) -> Token

expressionmethod#

def expression() -> Expr

field_namemethod#

def field_name(message: str) -> str

inferencemethod#

def inference() -> InferenceQuery

or_exprmethod#

def or_expr() -> Expr

parsemethod#

def parse() -> Query | InferenceQuery

primarymethod#

def primary() -> Expr

selectionmethod#

def selection() -> Selection

source_exprmethod#

def source_expr() -> Source

stringmethod#

def string() -> str

Queryclassdataclass#

class Query(bindings: list[Binding], where: Expr | None, selections: list[Selection], materializations: list[Materialization] = list(), metadata: dict[str, str] = dict(), source: str = '')

bindingsattributeinstance attribute#

bindings: list[Binding]

materializationsattributeclass attributeinstance attribute#

materializations: list[Materialization] = field(default_factory=list)

metadataattributeclass attributeinstance attribute#

metadata: dict[str, str] = field(default_factory=dict)

selectionsattributeinstance attribute#

selections: list[Selection]

sourceattributeclass attributeinstance attribute#

source: str = ''

whereattributeinstance attribute#

where: Expr | None

Selectionclassdataclass#

class Selection(expression: Expr, alias: str)

aliasattributeinstance attribute#

alias: str

expressionattributeinstance attribute#

expression: Expr

Sourceclassdataclass#

class Source(relation: str, package_glob: str = '*', document: str | None = None)

documentattributeclass attributeinstance attribute#

document: str | None = None

package_globattributeclass attributeinstance attribute#

package_glob: str = '*'

relationattributeinstance attribute#

relation: str

Tokenclassdataclass#

class Token(kind: str, value: str, line: int, column: int)

columnattributeinstance attribute#

column: int

kindattributeinstance attribute#

kind: str

lineattributeinstance attribute#

line: int

valueattributeinstance attribute#

value: str

metadatafunction#

def metadata(source: str) -> dict[str, str]

parsefunction#

def parse(source: str) -> Query | InferenceQuery

tokenizefunction#

def tokenize(source: str) -> list[Token]

Documentation for Arxo. Writings — blog.arxo.io.

Anonymous visit counts on stats.arxo.io, no cookies.