OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
generate_TableFunctionsFactory_init.Parser Class Reference

Public Member Functions

def __init__
 
def tokens
 
def is_at_end
 
def current_token
 
def advance
 
def expect
 
def consume
 
def current_pos
 
def raise_parser_error
 
def match
 
def lookahead
 
def parse_udtf
 
def parse_args
 
def parse_arg
 
def parse_type
 
def parse_composed
 
def parse_primitive
 
def parse_templates
 
def parse_template
 
def parse_annotation
 
def parse_identifier
 
def parse_string
 
def parse_number
 
def parse
 

Public Attributes

 line
 

Private Attributes

 _tokens
 
 _curr
 

Detailed Description

Definition at line 1281 of file generate_TableFunctionsFactory_init.py.

Constructor & Destructor Documentation

Member Function Documentation

def generate_TableFunctionsFactory_init.Parser.advance (   self)

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.consume (   self,
  expected_type 
)
consumes the current token iff its type matches the
expected_type. Otherwise, an error is raised

Definition at line 1311 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Tokenize._tokens, generate_TableFunctionsFactory_init.Parser._tokens, generate_TableFunctionsFactory_init.Tokenize.advance(), generate_TableFunctionsFactory_init.Parser.advance(), anonymous_namespace{RelAlgDag.cpp}::RANodeIterator.advance(), generate_TableFunctionsFactory_init.Tokenize.current_token(), generate_TableFunctionsFactory_init.Parser.current_token(), and generate_TableFunctionsFactory_init.Parser.raise_parser_error().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_annotation(), generate_TableFunctionsFactory_init.Parser.parse_arg(), generate_TableFunctionsFactory_init.Parser.parse_args(), generate_TableFunctionsFactory_init.Parser.parse_composed(), generate_TableFunctionsFactory_init.Parser.parse_identifier(), generate_TableFunctionsFactory_init.Parser.parse_number(), generate_TableFunctionsFactory_init.Parser.parse_string(), generate_TableFunctionsFactory_init.Parser.parse_template(), generate_TableFunctionsFactory_init.Parser.parse_templates(), and generate_TableFunctionsFactory_init.Parser.parse_udtf().

1312  def consume(self, expected_type):
1313  """consumes the current token iff its type matches the
1314  expected_type. Otherwise, an error is raised
1315  """
1316  curr_token = self.current_token()
1317  if curr_token.type == expected_type:
1318  self.advance()
1319  return curr_token
1320  else:
1321  expected_token = Token.tok_name(expected_type)
1322  self.raise_parser_error(
1323  'Token mismatch at function consume. '
1324  'Expected type "%s" but got token "%s"\n\n'
1325  'Tokens: %s\n' % (expected_token, curr_token, self._tokens)
1326  )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.current_pos (   self)

Definition at line 1327 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser._curr.

Referenced by generate_TableFunctionsFactory_init.Parser.raise_parser_error().

1328  def current_pos(self):
1329  return self._curr

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.current_token (   self)

Definition at line 1294 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser._curr, generate_TableFunctionsFactory_init.Tokenize._tokens, and generate_TableFunctionsFactory_init.Parser._tokens.

Referenced by generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.Parser.expect(), generate_TableFunctionsFactory_init.Parser.match(), and generate_TableFunctionsFactory_init.Parser.raise_parser_error().

1295  def current_token(self):
1296  return self._tokens[self._curr]

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.expect (   self,
  expected_type 
)

Definition at line 1300 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser._curr, generate_TableFunctionsFactory_init.Tokenize._tokens, generate_TableFunctionsFactory_init.Parser._tokens, generate_TableFunctionsFactory_init.Tokenize.advance(), generate_TableFunctionsFactory_init.Parser.advance(), anonymous_namespace{RelAlgDag.cpp}::RANodeIterator.advance(), generate_TableFunctionsFactory_init.Tokenize.current_token(), and generate_TableFunctionsFactory_init.Parser.current_token().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_udtf().

1301  def expect(self, expected_type):
1302  curr_token = self.current_token()
1303  msg = "Expected token %s but got %s at pos %d.\n Tokens: %s" % (
1304  curr_token,
1305  Token.tok_name(expected_type),
1306  self._curr,
1307  self._tokens,
1308  )
1309  assert curr_token.type == expected_type, msg
1310  self.advance()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.is_at_end (   self)

Definition at line 1291 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser._curr, generate_TableFunctionsFactory_init.Tokenize._tokens, and generate_TableFunctionsFactory_init.Parser._tokens.

Referenced by generate_TableFunctionsFactory_init.Parser.parse_annotation(), generate_TableFunctionsFactory_init.Parser.parse_arg(), generate_TableFunctionsFactory_init.Parser.parse_args(), generate_TableFunctionsFactory_init.Parser.parse_templates(), generate_TableFunctionsFactory_init.Parser.parse_type(), and generate_TableFunctionsFactory_init.Parser.parse_udtf().

1292  def is_at_end(self):
1293  return self._curr >= len(self._tokens)

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.lookahead (   self)

Definition at line 1346 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser._curr, generate_TableFunctionsFactory_init.Tokenize._tokens, and generate_TableFunctionsFactory_init.Parser._tokens.

Referenced by generate_TableFunctionsFactory_init.Parser.parse_arg().

1347  def lookahead(self):
1348  return self._tokens[self._curr + 1]

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.match (   self,
  expected_type 
)

Definition at line 1342 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Tokenize.current_token(), and generate_TableFunctionsFactory_init.Parser.current_token().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_annotation(), generate_TableFunctionsFactory_init.Parser.parse_arg(), generate_TableFunctionsFactory_init.Parser.parse_args(), generate_TableFunctionsFactory_init.Parser.parse_composed(), generate_TableFunctionsFactory_init.Parser.parse_primitive(), generate_TableFunctionsFactory_init.Parser.parse_template(), generate_TableFunctionsFactory_init.Parser.parse_templates(), generate_TableFunctionsFactory_init.Parser.parse_type(), and generate_TableFunctionsFactory_init.Parser.parse_udtf().

1343  def match(self, expected_type):
1344  curr_token = self.current_token()
1345  return curr_token.type == expected_type

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse (   self)
fmt: off

udtf: IDENTIFIER "(" (args)? ")" ("|" annotation)* "->" args ("," templates)? ("|" "output_row_size" "=" primitive)?

args: arg ("," arg)*

arg: type IDENTIFIER? ("|" annotation)*

type: composed
    | primitive

composed: "Cursor" "<" arg ("," arg)* ">"
| IDENTIFIER "<" type ("," type)* ">"

primitive: IDENTIFIER
 | NUMBER
 | STRING

annotation: IDENTIFIER "=" IDENTIFIER ("<" NUMBER ("," NUMBER) ">")?
  | IDENTIFIER "=" "[" PRIMITIVE? ("," PRIMITIVE)* "]"
  | "require" "=" STRING

templates: template ("," template)
template: IDENTIFIER "=" "[" IDENTIFIER ("," IDENTIFIER)* "]"

IDENTIFIER: [A-Za-z_][A-Za-z0-9_]*
NUMBER: [0-9]+
STRING: \".*?\"

fmt: on

Definition at line 1607 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser._curr, and generate_TableFunctionsFactory_init.Parser.parse_udtf().

1608  def parse(self):
1609  """fmt: off
1610 
1611  udtf: IDENTIFIER "(" (args)? ")" ("|" annotation)* "->" args ("," templates)? ("|" "output_row_size" "=" primitive)?
1612 
1613  args: arg ("," arg)*
1614 
1615  arg: type IDENTIFIER? ("|" annotation)*
1616 
1617  type: composed
1618  | primitive
1619 
1620  composed: "Cursor" "<" arg ("," arg)* ">"
1621  | IDENTIFIER "<" type ("," type)* ">"
1622 
1623  primitive: IDENTIFIER
1624  | NUMBER
1625  | STRING
1626 
1627  annotation: IDENTIFIER "=" IDENTIFIER ("<" NUMBER ("," NUMBER) ">")?
1628  | IDENTIFIER "=" "[" PRIMITIVE? ("," PRIMITIVE)* "]"
1629  | "require" "=" STRING
1630 
1631  templates: template ("," template)
1632  template: IDENTIFIER "=" "[" IDENTIFIER ("," IDENTIFIER)* "]"
1633 
1634  IDENTIFIER: [A-Za-z_][A-Za-z0-9_]*
1635  NUMBER: [0-9]+
1636  STRING: \".*?\"
1637 
1638  fmt: on
1639  """
1640  self._curr = 0
1641  udtf = self.parse_udtf()
1642 
1643  # set parent
1644  udtf.parent = None
1645  d = deque()
1646  d.append(udtf)
1647  while d:
1648  node = d.pop()
1649  if isinstance(node, Iterable):
1650  for child in node:
1651  child.parent = node
1652  d.append(child)
1653  return udtf
1654 
1655 
# fmt: off

+ Here is the call graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_annotation (   self)
fmt: off

annotation: IDENTIFIER "=" IDENTIFIER ("<" NUMBER ("," NUMBER) ">")?
  | IDENTIFIER "=" "[" PRIMITIVE? ("," PRIMITIVE)* "]"
  | "require" "=" STRING

fmt: on

Definition at line 1537 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.Tokenize.is_at_end(), generate_TableFunctionsFactory_init.Parser.is_at_end(), generate_TableFunctionsFactory_init.Parser.match(), generate_TableFunctionsFactory_init.Parser.parse_identifier(), generate_TableFunctionsFactory_init.Parser.parse_number(), generate_TableFunctionsFactory_init.Parser.parse_primitive(), and generate_TableFunctionsFactory_init.Parser.parse_string().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_arg(), and generate_TableFunctionsFactory_init.Parser.parse_udtf().

1538  def parse_annotation(self):
1539  """fmt: off
1540 
1541  annotation: IDENTIFIER "=" IDENTIFIER ("<" NUMBER ("," NUMBER) ">")?
1542  | IDENTIFIER "=" "[" PRIMITIVE? ("," PRIMITIVE)* "]"
1543  | "require" "=" STRING
1544 
1545  fmt: on
1546  """
1547  key = self.parse_identifier()
1548  self.consume(Token.EQUAL)
1549 
1550  if key == "require":
1551  value = self.parse_string()
1552  elif not self.is_at_end() and self.match(Token.LSQB):
1553  value = []
1554  self.consume(Token.LSQB)
1555  if not self.match(Token.RSQB):
1556  value.append(self.parse_primitive())
1557  while self.match(Token.COMMA):
1558  self.consume(Token.COMMA)
1559  value.append(self.parse_primitive())
1560  self.consume(Token.RSQB)
1561  else:
1562  value = self.parse_identifier()
1563  if not self.is_at_end() and self.match(Token.LESS):
1564  self.consume(Token.LESS)
1565  if self.match(Token.GREATER):
1566  value += "<%s>" % (-1) # Signifies no input
1567  else:
1568  num1 = self.parse_number()
1569  if self.match(Token.COMMA):
1570  self.consume(Token.COMMA)
1571  num2 = self.parse_number()
1572  value += "<%s,%s>" % (num1, num2)
1573  else:
1574  value += "<%s>" % (num1)
1575  self.consume(Token.GREATER)
1576  return AnnotationNode(key, value)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_arg (   self)
fmt: off

arg: type IDENTIFIER? ("|" annotation)*

fmt: on

Definition at line 1419 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.Tokenize.is_at_end(), generate_TableFunctionsFactory_init.Parser.is_at_end(), generate_TableFunctionsFactory_init.Tokenize.lookahead(), generate_TableFunctionsFactory_init.Parser.lookahead(), generate_TableFunctionsFactory_init.Parser.match(), generate_TableFunctionsFactory_init.Parser.parse_annotation(), generate_TableFunctionsFactory_init.Parser.parse_identifier(), and generate_TableFunctionsFactory_init.Parser.parse_type().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_args(), and generate_TableFunctionsFactory_init.Parser.parse_composed().

1420  def parse_arg(self):
1421  """fmt: off
1422 
1423  arg: type IDENTIFIER? ("|" annotation)*
1424 
1425  fmt: on
1426  """
1427  typ = self.parse_type()
1428 
1429  annotations = []
1430 
1431  if not self.is_at_end() and self.match(Token.IDENTIFIER):
1432  name = self.parse_identifier()
1433  annotations.append(AnnotationNode('name', name))
1434 
1435  while not self.is_at_end() and self.match(Token.VBAR):
1436  ahead = self.lookahead()
1437  if ahead.type == Token.IDENTIFIER and ahead.lexeme == 'output_row_size':
1438  break
1439  self.consume(Token.VBAR)
1440  annotations.append(self.parse_annotation())
1441 
1442  return ArgNode(typ, annotations)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_args (   self)
fmt: off

args: arg IDENTIFIER ("," arg)*

fmt: on

Definition at line 1397 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser._curr, generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.Tokenize.is_at_end(), generate_TableFunctionsFactory_init.Parser.is_at_end(), generate_TableFunctionsFactory_init.Parser.match(), generate_TableFunctionsFactory_init.Parser.parse_arg(), and generate_TableFunctionsFactory_init.Parser.parse_type().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_udtf().

1398  def parse_args(self):
1399  """fmt: off
1400 
1401  args: arg IDENTIFIER ("," arg)*
1402 
1403  fmt: on
1404  """
1405  args = []
1406  args.append(self.parse_arg())
1407  while not self.is_at_end() and self.match(Token.COMMA):
1408  curr = self._curr
1409  self.consume(Token.COMMA)
1410  self.parse_type() # assuming that we are not ending with COMMA
1411  if not self.is_at_end() and self.match(Token.EQUAL):
1412  # arg type cannot be assigned, so this must be a template specification
1413  self._curr = curr # step back and let the code below parse the templates
1414  break
1415  else:
1416  self._curr = curr + 1 # step back from self.parse_type(), parse_arg will parse it again
1417  args.append(self.parse_arg())
1418  return args

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_composed (   self)
fmt: off

composed: "Cursor" "<" arg ("," arg)* ">"
| IDENTIFIER "<" type ("," type)* ">"

fmt: on

Definition at line 1463 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.is_identifier_cursor(), generate_TableFunctionsFactory_init.Parser.match(), generate_TableFunctionsFactory_init.Parser.parse_arg(), generate_TableFunctionsFactory_init.Parser.parse_identifier(), and generate_TableFunctionsFactory_init.Parser.parse_type().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_type().

1464  def parse_composed(self):
1465  """fmt: off
1466 
1467  composed: "Cursor" "<" arg ("," arg)* ">"
1468  | IDENTIFIER "<" type ("," type)* ">"
1469 
1470  fmt: on
1471  """
1472  idtn = self.parse_identifier()
1473  self.consume(Token.LESS)
1474  if is_identifier_cursor(idtn):
1475  inner = [self.parse_arg()]
1476  while self.match(Token.COMMA):
1477  self.consume(Token.COMMA)
1478  inner.append(self.parse_arg())
1479  else:
1480  inner = [self.parse_type()]
1481  while self.match(Token.COMMA):
1482  self.consume(Token.COMMA)
1483  inner.append(self.parse_type())
1484  self.consume(Token.GREATER)
1485  return ComposedNode(idtn, inner)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_identifier (   self)
fmt: off

IDENTIFIER: [A-Za-z_][A-Za-z0-9_]*

fmt: on

Definition at line 1577 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_annotation(), generate_TableFunctionsFactory_init.Parser.parse_arg(), generate_TableFunctionsFactory_init.Parser.parse_composed(), generate_TableFunctionsFactory_init.Parser.parse_primitive(), generate_TableFunctionsFactory_init.Parser.parse_template(), and generate_TableFunctionsFactory_init.Parser.parse_udtf().

1578  def parse_identifier(self):
1579  """ fmt: off
1580 
1581  IDENTIFIER: [A-Za-z_][A-Za-z0-9_]*
1582 
1583  fmt: on
1584  """
1585  token = self.consume(Token.IDENTIFIER)
1586  return token.lexeme

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_number (   self)
fmt: off

NUMBER: [0-9]+

fmt: on

Definition at line 1597 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_annotation(), and generate_TableFunctionsFactory_init.Parser.parse_primitive().

1598  def parse_number(self):
1599  """ fmt: off
1600 
1601  NUMBER: [0-9]+
1602 
1603  fmt: on
1604  """
1605  token = self.consume(Token.NUMBER)
1606  return token.lexeme

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_primitive (   self)
fmt: off

primitive: IDENTIFIER
 | NUMBER
 | STRING

fmt: on

Definition at line 1486 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.match(), generate_TableFunctionsFactory_init.Parser.parse_identifier(), generate_TableFunctionsFactory_init.Parser.parse_number(), generate_TableFunctionsFactory_init.Parser.parse_string(), and generate_TableFunctionsFactory_init.Parser.raise_parser_error().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_annotation(), generate_TableFunctionsFactory_init.Parser.parse_type(), and generate_TableFunctionsFactory_init.Parser.parse_udtf().

1487  def parse_primitive(self):
1488  """fmt: off
1489 
1490  primitive: IDENTIFIER
1491  | NUMBER
1492  | STRING
1493 
1494  fmt: on
1495  """
1496  if self.match(Token.IDENTIFIER):
1497  lexeme = self.parse_identifier()
1498  elif self.match(Token.NUMBER):
1499  lexeme = self.parse_number()
1500  elif self.match(Token.STRING):
1501  lexeme = self.parse_string()
1502  else:
1503  raise self.raise_parser_error()
1504  return PrimitiveNode(lexeme)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_string (   self)
fmt: off

STRING: \".*?\"

fmt: on

Definition at line 1587 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_annotation(), and generate_TableFunctionsFactory_init.Parser.parse_primitive().

1588  def parse_string(self):
1589  """ fmt: off
1590 
1591  STRING: \".*?\"
1592 
1593  fmt: on
1594  """
1595  token = self.consume(Token.STRING)
1596  return token.lexeme

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_template (   self)
fmt: off

template: IDENTIFIER "=" "[" IDENTIFIER ("," IDENTIFIER)* "]"

fmt: on

Definition at line 1519 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.Parser.match(), and generate_TableFunctionsFactory_init.Parser.parse_identifier().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_templates().

1520  def parse_template(self):
1521  """fmt: off
1522 
1523  template: IDENTIFIER "=" "[" IDENTIFIER ("," IDENTIFIER)* "]"
1524 
1525  fmt: on
1526  """
1527  key = self.parse_identifier()
1528  types = []
1529  self.consume(Token.EQUAL)
1530  self.consume(Token.LSQB)
1531  types.append(self.parse_identifier())
1532  while self.match(Token.COMMA):
1533  self.consume(Token.COMMA)
1534  types.append(self.parse_identifier())
1535  self.consume(Token.RSQB)
1536  return TemplateNode(key, tuple(types))

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_templates (   self)
fmt: off

templates: template ("," template)*

fmt: on

Definition at line 1505 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.Tokenize.is_at_end(), generate_TableFunctionsFactory_init.Parser.is_at_end(), generate_TableFunctionsFactory_init.Parser.match(), and generate_TableFunctionsFactory_init.Parser.parse_template().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_udtf().

1506  def parse_templates(self):
1507  """fmt: off
1508 
1509  templates: template ("," template)*
1510 
1511  fmt: on
1512  """
1513  T = []
1514  T.append(self.parse_template())
1515  while not self.is_at_end() and self.match(Token.COMMA):
1516  self.consume(Token.COMMA)
1517  T.append(self.parse_template())
1518  return T

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_type (   self)
fmt: off

type: composed
    | primitive

fmt: on

Definition at line 1443 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser._curr, generate_TableFunctionsFactory_init.Tokenize.is_at_end(), generate_TableFunctionsFactory_init.Parser.is_at_end(), generate_TableFunctionsFactory_init.Parser.match(), generate_TableFunctionsFactory_init.Parser.parse_composed(), and generate_TableFunctionsFactory_init.Parser.parse_primitive().

Referenced by generate_TableFunctionsFactory_init.Parser.parse_arg(), generate_TableFunctionsFactory_init.Parser.parse_args(), and generate_TableFunctionsFactory_init.Parser.parse_composed().

1444  def parse_type(self):
1445  """fmt: off
1446 
1447  type: composed
1448  | primitive
1449 
1450  fmt: on
1451  """
1452  curr = self._curr # save state
1453  primitive = self.parse_primitive()
1454  if self.is_at_end():
1455  return primitive
1456 
1457  if not self.match(Token.LESS):
1458  return primitive
1459 
1460  self._curr = curr # return state
1461 
1462  return self.parse_composed()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.parse_udtf (   self)
fmt: off

udtf: IDENTIFIER "(" (args)? ")" ("|" annotation)* "->" args ("," templates)? ("|" "output_row_size" "=" primitive)?

fmt: on

Definition at line 1349 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.Parser.expect(), generate_TableFunctionsFactory_init.Tokenize.is_at_end(), generate_TableFunctionsFactory_init.Parser.is_at_end(), generate_TableFunctionsFactory_init.UdtfNode.line, generate_TableFunctionsFactory_init.Parser.line, generate_TableFunctionsFactory_init.Parser.match(), generate_TableFunctionsFactory_init.Parser.parse_annotation(), generate_TableFunctionsFactory_init.Parser.parse_args(), generate_TableFunctionsFactory_init.Parser.parse_identifier(), generate_TableFunctionsFactory_init.Parser.parse_primitive(), and generate_TableFunctionsFactory_init.Parser.parse_templates().

Referenced by generate_TableFunctionsFactory_init.Parser.parse().

1350  def parse_udtf(self):
1351  """fmt: off
1352 
1353  udtf: IDENTIFIER "(" (args)? ")" ("|" annotation)* "->" args ("," templates)? ("|" "output_row_size" "=" primitive)?
1354 
1355  fmt: on
1356  """
1357  name = self.parse_identifier()
1358  self.expect(Token.LPAR) # (
1359  input_args = []
1360  if not self.match(Token.RPAR):
1361  input_args = self.parse_args()
1362  self.expect(Token.RPAR) # )
1363  annotations = []
1364  while not self.is_at_end() and self.match(Token.VBAR): # |
1365  self.consume(Token.VBAR)
1366  annotations.append(self.parse_annotation())
1367  self.expect(Token.RARROW) # ->
1368  output_args = self.parse_args()
1369 
1370  templates = None
1371  if not self.is_at_end() and self.match(Token.COMMA):
1372  self.consume(Token.COMMA)
1373  templates = self.parse_templates()
1374 
1375  sizer = None
1376  if not self.is_at_end() and self.match(Token.VBAR):
1377  self.consume(Token.VBAR)
1378  idtn = self.parse_identifier()
1379  assert idtn == "output_row_size", idtn
1380  self.consume(Token.EQUAL)
1381  node = self.parse_primitive()
1382  key = "kPreFlightParameter"
1383  sizer = AnnotationNode(key, value=node.type)
1384 
1385  # set arg_pos
1386  i = 0
1387  for arg in input_args:
1388  arg.arg_pos = i
1389  arg.kind = "input"
1390  i += arg.type.cursor_length() if arg.type.is_cursor() else 1
1391 
1392  for i, arg in enumerate(output_args):
1393  arg.arg_pos = i
1394  arg.kind = "output"
1395 
1396  return UdtfNode(name, input_args, output_args, annotations, templates, sizer, self.line)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.raise_parser_error (   self,
  msg = None 
)

Definition at line 1330 of file generate_TableFunctionsFactory_init.py.

References ChunkIter.current_pos, generate_TableFunctionsFactory_init.Parser.current_pos(), generate_TableFunctionsFactory_init.Tokenize.current_token(), generate_TableFunctionsFactory_init.Parser.current_token(), generate_TableFunctionsFactory_init.Tokenize.tokens(), and generate_TableFunctionsFactory_init.Parser.tokens().

Referenced by generate_TableFunctionsFactory_init.Parser.consume(), and generate_TableFunctionsFactory_init.Parser.parse_primitive().

1331  def raise_parser_error(self, msg=None):
1332  if not msg:
1333  token = self.current_token()
1334  pos = self.current_pos()
1335  tokens = self.tokens
1336  msg = "\n\nError while trying to parse token %s at pos %d.\n" "Tokens: %s" % (
1337  token,
1338  pos,
1339  tokens,
1340  )
1341  raise ParserException(msg)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def generate_TableFunctionsFactory_init.Parser.tokens (   self)

Definition at line 1288 of file generate_TableFunctionsFactory_init.py.

References generate_TableFunctionsFactory_init.Tokenize._tokens, and generate_TableFunctionsFactory_init.Parser._tokens.

Referenced by generate_TableFunctionsFactory_init.Parser.raise_parser_error().

1289  def tokens(self):
1290  return self._tokens

+ Here is the caller graph for this function:

Member Data Documentation

generate_TableFunctionsFactory_init.Parser._curr
private

Definition at line 1284 of file generate_TableFunctionsFactory_init.py.

Referenced by generate_TableFunctionsFactory_init.Parser.advance(), generate_TableFunctionsFactory_init.Parser.current_pos(), generate_TableFunctionsFactory_init.Parser.current_token(), generate_TableFunctionsFactory_init.Parser.expect(), generate_TableFunctionsFactory_init.Parser.is_at_end(), generate_TableFunctionsFactory_init.Parser.lookahead(), generate_TableFunctionsFactory_init.Parser.parse(), generate_TableFunctionsFactory_init.Parser.parse_args(), and generate_TableFunctionsFactory_init.Parser.parse_type().

generate_TableFunctionsFactory_init.Parser._tokens
private

Definition at line 1283 of file generate_TableFunctionsFactory_init.py.

Referenced by generate_TableFunctionsFactory_init.Parser.consume(), generate_TableFunctionsFactory_init.Parser.current_token(), generate_TableFunctionsFactory_init.Parser.expect(), generate_TableFunctionsFactory_init.Parser.is_at_end(), generate_TableFunctionsFactory_init.Parser.lookahead(), and generate_TableFunctionsFactory_init.Parser.tokens().

generate_TableFunctionsFactory_init.Parser.line

Definition at line 1285 of file generate_TableFunctionsFactory_init.py.

Referenced by generate_TableFunctionsFactory_init.Tokenize.add_token(), generate_TableFunctionsFactory_init.Tokenize.current_token(), generate_TableFunctionsFactory_init.Tokenize.is_at_end(), generate_TableFunctionsFactory_init.Tokenize.lookahead(), generate_TableFunctionsFactory_init.Parser.parse_udtf(), generate_TableFunctionsFactory_init.Tokenize.peek(), and generate_TableFunctionsFactory_init.Tokenize.raise_tokenize_error().


The documentation for this class was generated from the following file: