Skip to content

Commit

Permalink
Fixes to exprTree
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Dec 8, 2023
1 parent dcfb215 commit 7efd2c9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Node(ABC):
node so that visiting code can navigate whole tree without
knowing exact types of each node.
Attributes
Parameters
----------
children : tuple of :py:class:`Node`
Possibly empty list of sub-nodes.
Expand All @@ -111,14 +111,14 @@ class BinaryOp(Node):
This class is used for representing all binary operators including
arithmetic and boolean operations.
Attributes
Parameters
----------
lhs : Node
Left-hand side of the operation
rhs : Node
Right-hand side of the operation
op : str
Operator name, e.g. '+', 'OR'
lhs : `Node`
Left-hand side of the operation.
op : `str`
Operator name, e.g. '+', 'OR'.
rhs : `Node`
Right-hand side of the operation.
"""

def __init__(self, lhs: Node, op: str, rhs: Node):
Expand All @@ -143,11 +143,11 @@ class UnaryOp(Node):
This class is used for representing all unary operators including
arithmetic and boolean operations.
Attributes
Parameters
----------
op : str
Operator name, e.g. '+', 'NOT'
operand : Node
op : `str`
Operator name, e.g. '+', 'NOT'.
operand : `Node`
Operand.
"""

Expand All @@ -168,9 +168,9 @@ def __str__(self) -> str:
class StringLiteral(Node):
"""Node representing string literal.
Attributes
Parameters
----------
value : str
value : `str`
Literal value.
"""

Expand All @@ -189,7 +189,7 @@ def __str__(self) -> str:
class TimeLiteral(Node):
"""Node representing time literal.
Attributes
Parameters
----------
value : `astropy.time.Time`
Literal string value.
Expand All @@ -213,7 +213,7 @@ class NumericLiteral(Node):
We do not convert literals to numbers, their text representation
is stored literally.
Attributes
Parameters
----------
value : str
Literal value.
Expand All @@ -237,7 +237,7 @@ class Identifier(Node):
Value of the identifier is its name, it may contain zero or one dot
character.
Attributes
Parameters
----------
name : str
Identifier name.
Expand All @@ -262,7 +262,7 @@ class RangeLiteral(Node):
end of the range (with inclusive end) and optional stride value
(default is 1).
Attributes
Parameters
----------
start : `int`
Start value of a range.
Expand Down Expand Up @@ -292,13 +292,13 @@ def __str__(self) -> str:
class IsIn(Node):
"""Node representing IN or NOT IN expression.
Attributes
Parameters
----------
lhs : Node
Left-hand side of the operation
values : list of Node
lhs : `Node`
Left-hand side of the operation.
values : `list` of `Node`
List of values on the right side.
not_in : bool
not_in : `bool`
If `True` then it is NOT IN expression, otherwise it is IN expression.
"""

Expand All @@ -325,9 +325,9 @@ def __str__(self) -> str:
class Parens(Node):
"""Node representing parenthesized expression.
Attributes
Parameters
----------
expr : Node
expr : `Node`
Expression inside parentheses.
"""

Expand All @@ -351,9 +351,9 @@ class TupleNode(Node):
with two items, though this class can be used to represent different
number of items in sequence.
Attributes
Parameters
----------
items : tuple of Node
items : `tuple` of `Node`
Expressions inside parentheses.
"""

Expand All @@ -374,7 +374,7 @@ def __str__(self) -> str:
class FunctionCall(Node):
"""Node representing a function call.
Attributes
Parameters
----------
function : `str`
Name of the function.
Expand All @@ -400,7 +400,7 @@ def __str__(self) -> str:
class PointNode(Node):
"""Node representing a point, (ra, dec) pair.
Attributes
Parameters
----------
ra : `Node`
Node representing ra value.
Expand All @@ -426,7 +426,7 @@ def __str__(self) -> str:
def function_call(function: str, args: list[Node]) -> Node:
"""Return node representing function calls.
Attributes
Parameters
----------
function : `str`
Name of the function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def _parseTimeString(time_str):
Returns
-------
time : `astropy.time.Time`
The parsed time.
Raises
------
Expand Down Expand Up @@ -184,6 +185,18 @@ class ParserYaccError(Exception):
class ParseError(ParserYaccError):
"""Exception raised for parsing errors.
Parameters
----------
expression : `str`
Full initial expression being parsed.
token : `str`
Current token at parsing position.
pos : `int`
Current parsing position, offset from beginning of expression in
characters.
lineno : `int`
Current line number in the expression.
Attributes
----------
expression : `str`
Expand Down Expand Up @@ -241,7 +254,7 @@ class ParserYacc:
expression. If identifier does not exist in the mapping then
`Identifier` is inserted into parse tree.
**kwargs
optional keyword arguments that are passed to `yacc.yacc` constructor.
Optional keyword arguments that are passed to `yacc.yacc` constructor.
"""

def __init__(self, idMap=None, **kwargs):
Expand Down

0 comments on commit 7efd2c9

Please sign in to comment.