Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
languages
Tagging
Commits
a652da52
Commit
a652da52
authored
May 15, 2018
by
Alexander David Hellwig
Browse files
Added support for parsing of qualified names with arrays(Port arrays, ComponentInstance arrays)
parent
36995b33
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/grammars/de/monticore/lang/Tagging.mc4
View file @
a652da52
...
...
@@ -32,6 +32,19 @@ grammar Tagging extends de.monticore.common.Common {
fragment
token
Recursion
=
'{'
(~(
'{'
|
'}'
|
'"'
)
|
String
|
Recursion
)+
'}'
;
fragment
token
TagToken
=
(~(
'"'
|
'{'
|
'}'
|
';'
))+;
NameWithArray
=
(
Name
(
"["
IntLiteral
"]"
)?);
ast
NameWithArray
=
method
public
String
toString
(){
return
name
+
(
intLiteral
.
isPresent
()
?
"["
+
intLiteral
.
get
().
getValue
()
+
"]"
:
""
);
};
QualifiedNameWithArray
=
(
NameWithArray
||
"."
)+;
ast
QualifiedNameWithArray
=
method
public
String
toString
(){
return
de
.
se_rwth
.
commons
.
Joiners
.
DOT
.
join
(
getNameWithArrays
());
};
interface
Scope
;
ast
Scope
=
method
public
String
getQualifiedNameString
()
{
...
...
@@ -42,19 +55,19 @@ grammar Tagging extends de.monticore.common.Common {
};
//
this
one
is
only
defined
here
,
to
get
Parser
Tags
NameScope
implements
Scope
=
QualifiedName
;
NameScope
implements
Scope
=
QualifiedName
WithArray
;
ast
NameScope
=
method
public
String
getQualifiedNameString
()
{
return
getQualifiedName
().
toString
();
return
getQualifiedName
WithArray
().
toString
();
}
method
public
String
getScopeKind
()
{
return
"NameScope"
;
};
ConnectorScope
extends
NameScope
=
source
:
QualifiedName
"->"
QualifiedName
;
ConnectorScope
extends
NameScope
=
source
:
QualifiedName
WithArray
"->"
QualifiedName
WithArray
;
ast
ConnectorScope
=
method
public
String
getQualifiedNameString
()
{
return
getQualifiedName
().
toString
();
return
getQualifiedName
WithArray
().
toString
();
}
method
public
String
getScopeKind
()
{
return
"ConnectorScope"
;
...
...
src/test/java/de/monticore/lang/tagging/ParserTagValueTest.java
View file @
a652da52
...
...
@@ -20,10 +20,22 @@
*/
package
de.monticore.lang.montiarc.tagging
;
import
de.monticore.lang.tagging._ast.ASTScope
;
import
de.monticore.lang.tagging._ast.ASTTag
;
import
de.monticore.lang.tagging._ast.ASTTagElement
;
import
de.monticore.lang.tagging._ast.ASTTaggingUnit
;
import
de.monticore.lang.tagging._parser.TaggingParser
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* Created by MichaelvonWenckstern on 13.06.2016.
*/
...
...
@@ -56,7 +68,7 @@ public class ParserTagValueTest {
// .forEachOrdered(t -> System.out.println(t.getTagValue().get()));
//// System.out.println(tags.getTags().get(0).getTagValue().length());
// }
@Ignore
@Test
public
void
testTagschema2
()
throws
Exception
{
TaggingParser
parser
=
new
TaggingParser
();
...
...
@@ -65,4 +77,29 @@ public class ParserTagValueTest {
// System.out.println(tags.getTags().size());
// System.out.println(tags.getTags().get(0).getTagValue().length());
}
@Test
public
void
testArrayTagging
()
throws
IOException
{
TaggingParser
parser
=
new
TaggingParser
();
ASTTaggingUnit
taggingUnit
=
parser
.
parse
(
"src/test/resources/array/Array.tag"
).
get
();
List
<
ASTTag
>
tags
=
taggingUnit
.
getTagBody
().
getTags
();
List
<
ASTScope
>
taggedElements
=
tags
.
stream
()
.
map
(
ASTTag:
:
getScopes
)
.
flatMap
(
Collection:
:
stream
)
.
collect
(
Collectors
.
toList
());
Set
<
String
>
nameStrings
=
taggedElements
.
stream
()
.
map
(
ASTScope:
:
getQualifiedNameString
)
.
collect
(
Collectors
.
toSet
());
assertTrue
(
nameStrings
.
size
()
==
5
);
assertTrue
(
nameStrings
.
contains
(
"InstanceArrayComp.subcomps[1]"
));
assertTrue
(
nameStrings
.
contains
(
"InstanceArrayComp.subcomps[5]"
));
assertTrue
(
nameStrings
.
contains
(
"PortArrayComp.arrayIn[1]"
));
assertTrue
(
nameStrings
.
contains
(
"PortArrayComp.arrayIn[3]"
));
assertTrue
(
nameStrings
.
contains
(
"Comp.subCompInst[6].portArray[4]"
));
}
}
src/test/resources/array/Array.tag
0 → 100644
View file @
a652da52
package
array
;
conforms
to
nfp
.
TracebilityTagSchema
;
tags
Array
{
//
Tag
a
Subcomponent
array
tag
InstanceArrayComp
.
subcomps
[
1
]
with
IsTraceable
;
tag
InstanceArrayComp
.
subcomps
[
5
]
with
IsTraceable
;
//
Tag
an
array
Port
tag
PortArrayComp
.
arrayIn
[
1
]
with
IsTraceable
;
tag
PortArrayComp
.
arrayIn
[
3
]
with
IsTraceable
;
//
Combination
of
both
tag
Comp
.
subCompInst
[
6
].
portArray
[
4
]
with
IsTraceable
;
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment