diff options
author | Unai Martinez-Corral <38422348+umarcor@users.noreply.github.com> | 2021-06-22 12:05:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 12:05:45 +0100 |
commit | bf45d9939dc26d0d584dd549923b9962f83360ec (patch) | |
tree | 976beef99129705fa8d0e592dfba4fad61b80135 /pyGHDL/dom/Literal.py | |
parent | 15f447b1270a815748fdbcce46d97abd9eecc21d (diff) | |
parent | 0a69901be945dfb6c5372e657332d5e5ddfa10c7 (diff) | |
download | ghdl-bf45d9939dc26d0d584dd549923b9962f83360ec.tar.gz ghdl-bf45d9939dc26d0d584dd549923b9962f83360ec.tar.bz2 ghdl-bf45d9939dc26d0d584dd549923b9962f83360ec.zip |
More expression kinds and function calls (#1802)
Diffstat (limited to 'pyGHDL/dom/Literal.py')
-rw-r--r-- | pyGHDL/dom/Literal.py | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/pyGHDL/dom/Literal.py b/pyGHDL/dom/Literal.py index 7c722583b..209712ba3 100644 --- a/pyGHDL/dom/Literal.py +++ b/pyGHDL/dom/Literal.py @@ -30,16 +30,19 @@ # # SPDX-License-Identifier: GPL-2.0-or-later # ============================================================================ -from pyGHDL.libghdl import name_table - -from pyGHDL.libghdl.vhdl import nodes from pydecor import export from pyVHDLModel.VHDLModel import ( IntegerLiteral as VHDLModel_IntegerLiteral, FloatingPointLiteral as VHDLModel_FloatingPointLiteral, + PhysicalIntegerLiteral as VHDLModel_PhysicalIntegerLiteral, + PhysicalFloatingLiteral as VHDLModel_PhysicalFloatingLiteral, CharacterLiteral as VHDLModel_CharacterLiteral, + StringLiteral as VHDLModel_StringLiteral, ) +from pyGHDL.libghdl import name_table +from pyGHDL.libghdl.vhdl import nodes +from pyGHDL.dom._Utils import GetNameOfNode __all__ = [] @@ -61,9 +64,40 @@ class FloatingPointLiteral(VHDLModel_FloatingPointLiteral): @export +class PhysicalIntegerLiteral(VHDLModel_PhysicalIntegerLiteral): + @classmethod + def parse(cls, node): + value = nodes.Get_Value(node) + unit = nodes.Get_Unit_Name(node) + unitName = GetNameOfNode(unit) + + return cls(value, unitName) + + +@export +class PhysicalFloatingLiteral(VHDLModel_PhysicalFloatingLiteral): + @classmethod + def parse(cls, node): + value = nodes.Get_Fp_Value(node) + unit = nodes.Get_Unit_Name(node) + unitName = GetNameOfNode(unit) + + return cls(value, unitName) + + +@export class CharacterLiteral(VHDLModel_CharacterLiteral): @classmethod def parse(cls, node): identifier = nodes.Get_Identifier(node) value = name_table.Get_Character(identifier) return cls(value) + + +@export +class StringLiteral(VHDLModel_StringLiteral): + @classmethod + def parse(cls, node): + stringID = nodes.Get_String8_Id(node) + value = name_table.Get_Name_Ptr(stringID) + return cls(value) |