Skip to content
Snippets Groups Projects

Add CP-DSL Declaration SymbolTable and Visitor

Merged Armin Mackensen requested to merge cp-dsl_symbolTable into main
43 files
+ 2191
997
Compare changes
  • Side-by-side
  • Inline
Files
43
@@ -467,10 +467,13 @@ class UnitSymbol( TypedSymbol ):
@@ -467,10 +467,13 @@ class UnitSymbol( TypedSymbol ):
A symbol with an attached unit (physical units such as second, metre, gram etc.).
A symbol with an attached unit (physical units such as second, metre, gram etc.).
"""
"""
attached_unit: Optional[Unit]
attached_unit: Optional[Unit]
 
attached_description: Optional[str]
def __init__(self, name: str, attached_unit: Unit, attached_type: Type = None):
def __init__(self, name: str, attached_description: str, attached_unit: Unit, attached_type: Type = None):
super().__init__( name, attached_type )
super().__init__( name, attached_type )
self.attached_unit = attached_unit
self.attached_unit = attached_unit
 
self.attached_description = attached_description
 
class TypeAlias( Symbol, Type ):
class TypeAlias( Symbol, Type ):
@@ -865,10 +868,11 @@ class BlockSymbol( ScopedSymbol ):
@@ -865,10 +868,11 @@ class BlockSymbol( ScopedSymbol ):
class VariableSymbol( UnitSymbol ):
class VariableSymbol( UnitSymbol ):
is_tree = False
def __init__(self, name: str, value=None, attached_type: Type = None):
super().__init__( name, attached_type )
def __init__(self, name: str, description: str = "", value = None, attached_unit : Unit = None, attached_type: Type = None):
super().__init__( name, description, attached_unit, attached_type )
 
self.is_tree = isinstance(value, ParseTree)
self.value = value
self.value = value
@@ -887,6 +891,21 @@ class LiteralSymbol( UnitSymbol ):
@@ -887,6 +891,21 @@ class LiteralSymbol( UnitSymbol ):
class ParameterSymbol( VariableSymbol ):
class ParameterSymbol( VariableSymbol ):
pass
pass
 
class GroupSymbol(ScopedSymbol):
 
"""
 
A Class for Group Declarations
 
"""
 
description: Optional[str]
 
groupType: Optional[T]
 
 
def __init__(self, name: str, groupType: T, description: str = ""):
 
super().__init__(name)
 
self.description = description
 
self.groupType = groupType
 
 
def getGroupVars(self, localOnly=True) -> Coroutine[List[T]]:
 
return self.getSymbolsOfType(self.groupType)
 
class RoutineSymbol( ScopedSymbol ):
class RoutineSymbol( ScopedSymbol ):
"""
"""
@@ -904,6 +923,12 @@ class RoutineSymbol( ScopedSymbol ):
@@ -904,6 +923,12 @@ class RoutineSymbol( ScopedSymbol ):
def getParameters(self, localOnly=True) -> Coroutine[List[T]]:
def getParameters(self, localOnly=True) -> Coroutine[List[T]]:
return self.getSymbolsOfType( ParameterSymbol )
return self.getSymbolsOfType( ParameterSymbol )
 
def getUnits(self, localOnly=True) -> Coroutine[List[T]]:
 
return self.getSymbolsOfType(UnitSymbol)
 
 
def getFeatures(self, localOnly=True) -> Coroutine[List[T]]:
 
return self.getSymbolsOfType(RoutineSymbol)
 
class MethodFlags( Enum ):
class MethodFlags( Enum ):
NoneFL = 0
NoneFL = 0
Loading