From 2708b1e61f3c8a9ac132c7efb65e93053937e5ca Mon Sep 17 00:00:00 2001 From: Yury Kurlykov Date: Thu, 30 Apr 2020 00:55:25 +1000 Subject: [PATCH] Add specific Literal classes They are needed for the further development convenience. --- jasminesnake/ast/nodes.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/jasminesnake/ast/nodes.py b/jasminesnake/ast/nodes.py index f9e405f..6e4ddc8 100644 --- a/jasminesnake/ast/nodes.py +++ b/jasminesnake/ast/nodes.py @@ -1059,6 +1059,35 @@ class BigIntLiteral(Literal): self._fields.update({"bigint": self.bigint}) +class NullLiteral(Literal): + def __init__(self, loc: Optional[SourceLocation]): + super().__init__(loc, None) + + def __str__(self): + return "null" + + +class BooleanLiteral(Literal): + def __init__(self, loc: Optional[SourceLocation], value: bool): + super().__init__(loc, value) + + def __str__(self): + return str(self.value).lower() + + +class StringLiteral(Literal): + def __init__(self, loc: Optional[SourceLocation], value: str): + super().__init__(loc, value) + + def __str__(self): + return f'"{self.value}"' + + +class NumericLiteral(Literal): + def __init__(self, loc: Optional[SourceLocation], value: number): + super().__init__(loc, value) + + # "Property" block