Skip to content

operators

Classes:

AndOp

AndOp(
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BoolBinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
def __init__(
    self,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Instantiate AST class for logical AND operation.
    parameters:
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(
        op_code=self.op_code,
        lhs=lhs,
        rhs=rhs,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_BINARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {
        "lhs": self.lhs.get_struct(simplified),
        "rhs": self.rhs.get_struct(simplified),
    }
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BinaryOp

BinaryOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: DataTypeOps

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BoolBinaryOp

BoolBinaryOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    super().__init__(
        op_code=op_code,
        lhs=lhs,
        rhs=rhs,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_BINARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {
        "lhs": self.lhs.get_struct(simplified),
        "rhs": self.rhs.get_struct(simplified),
    }
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BoolUnaryOp

BoolUnaryOp(
    op_code: str,
    operand: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: UnaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
474
475
476
477
478
479
480
481
482
483
484
485
486
def __init__(
    self,
    op_code: str,
    operand: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    super().__init__(
        op_code=op_code,
        operand=operand,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
496
497
498
499
500
501
502
503
504
505
506
507
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_UNARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {"operand": self.operand.get_struct(simplified)}
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

DataTypeOps

DataTypeOps(
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: DataType

Methods:

Source code in packages/astx/src/astx/base.py
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
def __init__(
    self,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the data type.
    parameters:
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)
    self.name = f"temp_{DataType._tmp_id}"
    DataType._tmp_id += 1
    # set it as a generic data type
    self.type_: ExprType = ExprType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/base.py
685
686
687
688
689
690
691
692
693
694
695
696
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return a simple structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"DATA-TYPE[{self.__class__.__name__}]"
    value = self.name
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

NandOp

NandOp(
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BoolBinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
def __init__(
    self,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Instantiate AST class for logical NAND operation.
    parameters:
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(
        op_code=self.op_code,
        lhs=lhs,
        rhs=rhs,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_BINARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {
        "lhs": self.lhs.get_struct(simplified),
        "rhs": self.rhs.get_struct(simplified),
    }
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

NorOp

NorOp(
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BoolBinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
def __init__(
    self,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Instantiate AST class for logical NOR operation.
    parameters:
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(
        op_code=self.op_code,
        lhs=lhs,
        rhs=rhs,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_BINARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {
        "lhs": self.lhs.get_struct(simplified),
        "rhs": self.rhs.get_struct(simplified),
    }
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

NotOp

NotOp(
    operand: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BoolUnaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
def __init__(
    self,
    operand: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Instantiate AST class for logical NOT operation.
    parameters:
      operand:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(
        op_code=self.op_code,
        operand=operand,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
496
497
498
499
500
501
502
503
504
505
506
507
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_UNARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {"operand": self.operand.get_struct(simplified)}
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

OrOp

OrOp(
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BoolBinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
def __init__(
    self,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Instantiate AST class for logical OR operation.
    parameters:
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(
        op_code=self.op_code,
        lhs=lhs,
        rhs=rhs,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_BINARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {
        "lhs": self.lhs.get_struct(simplified),
        "rhs": self.rhs.get_struct(simplified),
    }
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

UnaryOp

UnaryOp(
    op_code: str,
    operand: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: DataTypeOps

Methods:

Source code in packages/astx/src/astx/types/operators.py
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
def __init__(
    self,
    op_code: str,
    operand: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the UnaryOp instance.
    parameters:
      op_code:
        type: str
      operand:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)
    self.op_code = op_code
    self.operand = operand
    self.kind = ASTKind.UnaryOpKind

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
290
291
292
293
294
295
296
297
298
299
300
301
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure of the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"UNARY[{self.op_code}]"
    value = self.operand.get_struct(simplified)
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

XnorOp

XnorOp(
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BoolBinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
def __init__(
    self,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Instantiate AST class for logical XNOR operation.
    parameters:
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(
        op_code=self.op_code,
        lhs=lhs,
        rhs=rhs,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_BINARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {
        "lhs": self.lhs.get_struct(simplified),
        "rhs": self.rhs.get_struct(simplified),
    }
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

XorOp

XorOp(
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BoolBinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
def __init__(
    self,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Instantiate AST class for logical XOR operation.
    parameters:
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(
        op_code=self.op_code,
        lhs=lhs,
        rhs=rhs,
        loc=loc,
        parent=parent,
    )

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BOOL_BINARY_OP[{self.__class__.__name__}]"
    value: ReprStruct = {
        "lhs": self.lhs.get_struct(simplified),
        "rhs": self.rhs.get_struct(simplified),
    }
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )