Skip to content

Commit

Permalink
Merge pull request sifive#36 from sifive/hifive
Browse files Browse the repository at this point in the history
Add HiFive board Devicetrees to integration tests
  • Loading branch information
nategraff-sifive authored Dec 4, 2019
2 parents e4fc07f + 571c5e6 commit cb0d078
Show file tree
Hide file tree
Showing 6 changed files with 767 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pydevicetree/ast/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __len__(self) -> int:

def to_dts(self, formatHex: bool = False) -> str:
"""Format the values in Devicetree Source format"""
return " ".join(wrapStrings(self.values, formatHex))
return ", ".join(wrapStrings(self.values, formatHex))

def __getitem__(self, key) -> Any:
return self.values[key]
Expand Down
6 changes: 3 additions & 3 deletions pydevicetree/ast/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Reference:
This is the parent class for both types of references, LabelReference and PathReference
"""
# pylint: disable=no-self-use
def to_dts(self) -> str:
def to_dts(self, formatHex: bool = False) -> str:
"""Format the Reference in Devicetree Source format"""
return ""

Expand All @@ -90,7 +90,7 @@ def __init__(self, label: Union[Label, str]):
def __repr__(self) -> str:
return "<LabelReference " + self.to_dts() + ">"

def to_dts(self) -> str:
def to_dts(self, formatHex: bool = False) -> str:
"""Format the LabelReference in Devicetree Source format"""
return "&" + self.label.name

Expand All @@ -106,6 +106,6 @@ def __init__(self, path: Union[Path, str]):
def __repr__(self) -> str:
return "<PathReference " + self.to_dts() + ">"

def to_dts(self) -> str:
def to_dts(self, formatHex: bool = False) -> str:
"""Format the PathReference in Devicetree Source format"""
return "&{" + self.path.to_dts() + "}"
3 changes: 2 additions & 1 deletion pydevicetree/source/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
(p.OneOrMore(p.Word(p.hexnums, exact=2) ^ label_creation.suppress())) + \
p.Literal("]").suppress()
property_values = p.Forward()
property_values = p.delimitedList(property_values ^ cell_array ^ bytestring ^ stringlist)
property_values = p.delimitedList(property_values ^ cell_array ^ bytestring ^ stringlist ^ \
reference)
property_assignment = property_name("property_name") + p.Optional(p.Literal("=").suppress() + \
(property_values)).setResultsName("value") + p.Literal(";").suppress()

Expand Down
2 changes: 2 additions & 0 deletions pydevicetree/source/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def transformPropertyAssignment(string, location, tokens):
return Property(tokens.property_name, v)
if isinstance(v, StringList):
return Property(tokens.property_name, v)
if isinstance(v, Reference):
return Property(tokens.property_name, v)

return Property(tokens.property_name, PropertyValues([]))

Expand Down
Loading

0 comments on commit cb0d078

Please sign in to comment.