Skip to content

Commit

Permalink
Allow array with imported element type
Browse files Browse the repository at this point in the history
Ref. #347
  • Loading branch information
treiher committed Jul 17, 2020
1 parent 2e1d62b commit 3fd6329
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rflx/parser/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def enumeration_type_definition() -> Token:


def array_type_definition() -> Token:
return (Keyword("array of") + unqualified_identifier()).setName("Array")
return (Keyword("array of") + qualified_identifier()).setName("Array")


def message_type_definition() -> Token:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from rflx.model import (
FINAL,
INITIAL,
Array,
DerivedMessage,
Enumeration,
Field,
Expand Down Expand Up @@ -1231,3 +1232,27 @@ def test_parsed_field_locations() -> None:
Field(ID("F1", Location((6, 21), end=(6, 22)))),
Field(ID("F2", Location((7, 21), end=(7, 22)))),
)


def test_array_with_imported_element_type() -> None:
p = Parser()
p.parse_string(
"""
with Test;
package Array_Test is
type T is array of Test.T;
end Array_Test;
"""
)
p.parse_string(
"""
package Test is
type T is mod 256;
end Test;
"""
)
m = p.create_model()
arrays = [t for t in m.types if isinstance(t, Array)]
assert len(arrays) == 1
assert arrays[0].identifier == ID("Array_Test.T")
assert arrays[0].element_type == ModularInteger("Test.T", Number(256))

0 comments on commit 3fd6329

Please sign in to comment.