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
e57c6123
Commit
e57c6123
authored
Jul 16, 2018
by
Ferdinand Alexander Mehlan
Browse files
change templates for valuetagtypecreator
parent
0b0fac3d
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/main/resources/templates/de/monticore/lang/tagschema/ValuedTagTypeCreator.ftl
View file @
e57c6123
...
...
@@ -13,9 +13,9 @@ import de.monticore.lang.tagging._ast.ASTScope;
import
de.monticore.lang.tagging._ast.ASTTag;
import
de.monticore.lang.tagging._ast.ASTTaggingUnit;
import
de.monticore.lang.tagging._symboltable.TagSymbolCreator;
import
de.monticore.lang.tagging._symboltable.TaggingResolver;
import
de.monticore.symboltable.Scope;
import
de.monticore.symboltable.Symbol;
import
de.monticore.symboltable.SymbolKind;
import
de.se_rwth.commons.Joiners;
import
de.se_rwth.commons.logging.Log;
...
...
@@ -47,27 +47,26 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
return
s
;
}
public
void
create
(
ASTT
aggingUnit
unit
,
S
cope
gs
)
{
if
(
unit
.getQualifiedName
s
()
.stream
()
public
void
create
(
ASTT
aggingUnit
unit
,
T
aggingResolver
tagging
)
{
if
(
unit
.getQualifiedName
List
()
.stream
()
.map
(
q
->
q
.toString
())
.filter
(
n
->
n
.endsWith
(
"${schemaName}"
))
.count
()
==
0
)
{
return
;
//
the
tagging
model
is
not
conform
to
the
$
{
schemaName
}
tagging
schema
}
final
S
tring
packageName
=
J
oiners
.DOT.join
(
unit
.getPackage
())
;
final
S
tring
packageName
=
J
oiners
.DOT.join
(
unit
.getPackage
List
())
;
final
S
tring
rootCmp
=
//
if-else
does
not
work
b
/
c
of
final
(
required
by
streams
)
(
unit
.getTagBody
()
.getTargetModel
()
.isPresent
())
?
J
oiners
.DOT.join
(
packageName
,
unit
.getTagBody
()
.getTargetModel
()
.get
()
.getQualifiedNameString
())
:
(
unit
.getTagBody
()
.getTargetModelOpt
()
.isPresent
())
?
J
oiners
.DOT.join
(
packageName
,
((
ASTN
ameScope
)
unit
.getTagBody
()
.getTargetModelOpt
()
.get
())
.getQualifiedName
()
.toString
())
:
packageName
;
for
(
ASTT
ag
element
:
unit
.getTagBody
()
.getTagList
())
{
element
.getTagElement
s
()
.stream
()
.filter
(
t
->
t
.getName
()
.equals
(
"${tagTypeName}"
))
.filter
(
t
->
t
.getTagValue
()
.isPresent
())
.map
(
t
->
checkContent
(
t
.getTagValue
()
.get
()))
.filter
(
v
->
v
!=
null
)
element
.getTagElement
List
()
.stream
()
.filter
(
t
->
t
.getName
()
.equals
(
"${tagTypeName}"
))
.filter
(
t
->
!
t
.getTagValue
Opt
()
.isPresent
())
.map
(
t
->
checkContent
(
t
.getTagValue
Opt
()
.get
()))
.filter
(
r
->
r
!=
null
)
<#
if
isUnit
>
.filter
(
this
::
checkUnit
)
</#
if
>
...
...
@@ -75,18 +74,16 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
element
.getScopeList
()
.stream
()
.filter
(
this
::
checkScope
)
.map
(
s
->
(
ASTN
ameScope
)
s
)
.map
(
s
->
getGlobalScope
(
gs
)
.<
S
ymbol
>
resolveDownMany
(
J
oiners
.DOT.join
(
rootCmp
,
s
.getQualifiedName
()
.toString
()),
S
ymbolKind
.KIND
))
.filter
(
s
->
!
s
.isEmpty
())
.map
(
this
::
checkKind
)
.filter
(
s
->
s
!=
null
)
.map
(
s
->
tagging
.resolve
(
J
oiners
.DOT.join
(
rootCmp
,
//
resolve
down
does
not
try
to
reload
symbol
s
.getQualifiedName
()
.toString
()),
$
{
scopeSymbol
}
.KIND
))
.filter
(
O
ptional
::
isPresent
)
.map
(
O
ptional
::
get
)
<#
if
isUnit
>
.forEachOrdered
(
s
->
s
.addTag
(
new
$
{
tagTypeName
}
S
ymbol
(
.forEachOrdered
(
s
->
tagging
.addTag
(
s
,
new
$
{
tagTypeName
}
S
ymbol
(
N
umericLiteral
.getValue
(
v
.getNumericLiteral
()),
U
nit
.valueOf
(
v
.getUnit
())
.asType
(
$
{
dataType
}
.class
)))))
;
<#
else
>
.forEachOrdered
(
s
->
s
.addTag
(
new
$
{
tagTypeName
}
S
ymbol
(
v
))))
;
.forEachOrdered
(
s
->
tagging
.addTag
(
s
,
new
$
{
tagTypeName
}
S
ymbol
(
v
))))
;
</#
if
>
}
}
...
...
@@ -118,14 +115,14 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
L
og
.enableFailQuick
(
false
)
;
long
errorCount
=
L
og
.getErrorCount
()
;
ast
=
parser
.parse
String_
UnitTagValue
(
s
)
;
ast
=
parser
.parseUnitTagValue
(
s
)
;
L
og
.enableFailQuick
(
enableFailQuick
)
;
if
(
L
og
.getErrorCount
()
>
errorCount
)
{
throw
new
E
xception
(
"Error occured during parsing."
)
;
}
}
catch
(
E
xception
e
)
{
L
og
.error
(
S
tring
.format
(
"0xT0004 Could not parse '%s' with TagValueParser#parse
String_
UnitTagValue"
,
L
og
.error
(
S
tring
.format
(
"0xT0004 Could not parse '%s' with TagValueParser#parseUnitTagValue"
,
s
),
e
)
;
return
null
;
}
...
...
@@ -143,14 +140,14 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
L
og
.enableFailQuick
(
false
)
;
long
errorCount
=
L
og
.getErrorCount
()
;
ast
=
parser
.parseString
_String
TagValue
(
s
)
;
ast
=
parser
.parseStringTagValue
(
s
)
;
L
og
.enableFailQuick
(
enableFailQuick
)
;
if
(
L
og
.getErrorCount
()
>
errorCount
)
{
throw
new
E
xception
(
"Error occured during parsing."
)
;
}
}
catch
(
E
xception
e
)
{
L
og
.error
(
S
tring
.format
(
"0xT0004 Could not parse %s with TagValueParser#parseString
_String
TagValue."
,
L
og
.error
(
S
tring
.format
(
"0xT0004 Could not parse %s with TagValueParser#parseStringTagValue."
,
s
),
e
)
;
return
null
;
}
...
...
@@ -168,14 +165,14 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
L
og
.enableFailQuick
(
false
)
;
long
errorCount
=
L
og
.getErrorCount
()
;
ast
=
parser
.parse
String_
BooleanTagValue
(
s
)
;
ast
=
parser
.parseBooleanTagValue
(
s
)
;
L
og
.enableFailQuick
(
enableFailQuick
)
;
if
(
L
og
.getErrorCount
()
>
errorCount
)
{
throw
new
E
xception
(
"Error occured during parsing."
)
;
}
}
catch
(
E
xception
e
)
{
L
og
.error
(
S
tring
.format
(
"0xT0004 Could not parse %s with TagValueParser#parse
String_
BooleanTagValue."
,
L
og
.error
(
S
tring
.format
(
"0xT0004 Could not parse %s with TagValueParser#parseBooleanTagValue."
,
s
),
e
)
;
return
null
;
}
...
...
@@ -193,14 +190,14 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
L
og
.enableFailQuick
(
false
)
;
long
errorCount
=
L
og
.getErrorCount
()
;
ast
=
parser
.parse
String_
NumericTagValue
(
s
)
;
ast
=
parser
.parseNumericTagValue
(
s
)
;
L
og
.enableFailQuick
(
enableFailQuick
)
;
if
(
L
og
.getErrorCount
()
>
errorCount
)
{
throw
new
E
xception
(
"Error occured during parsing."
)
;
}
}
catch
(
E
xception
e
)
{
L
og
.error
(
S
tring
.format
(
"0xT0004 Could not parse %s with TagValueParser#parse
String_
NumericTagValue."
,
L
og
.error
(
S
tring
.format
(
"0xT0004 Could not parse %s with TagValueParser#parseNumericTagValue."
,
s
),
e
)
;
return
null
;
}
...
...
src/test/java/nfp/PhysicalTags/PhysicalTags.java
0 → 100644
View file @
e57c6123
/* generated by template templates.de.monticore.lang.tagschema.TagSchema*/
package
nfp.PhysicalTags
;
import
de.monticore.lang.tagging._symboltable.TaggingResolver
;
import
de.monticore.symboltable.resolving.CommonResolvingFilter
;
/**
* generated by TagSchema.ftl
*/
public
class
PhysicalTags
{
protected
static
PhysicalTags
instance
=
null
;
protected
PhysicalTags
()
{}
protected
static
PhysicalTags
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
PhysicalTags
();
}
return
instance
;
}
protected
void
doRegisterTagTypes
(
TaggingResolver
tagging
)
{
tagging
.
addTagSymbolCreator
(
new
WeightSymbolCreator
());
tagging
.
addTagSymbolResolvingFilter
(
CommonResolvingFilter
.
create
(
WeightSymbol
.
KIND
));
tagging
.
addTagSymbolCreator
(
new
SizeSymbolCreator
());
tagging
.
addTagSymbolResolvingFilter
(
CommonResolvingFilter
.
create
(
SizeSymbol
.
KIND
));
}
public
static
void
registerTagTypes
(
TaggingResolver
tagging
)
{
getInstance
().
doRegisterTagTypes
(
tagging
);
}
}
\ No newline at end of file
src/test/java/nfp/PhysicalTags/SizeSymbol.java
0 → 100644
View file @
e57c6123
/* generated by template templates.de.monticore.lang.tagschema.ComplexTagType*/
package
nfp.PhysicalTags
;
import
de.monticore.lang.tagging._symboltable.TagKind
;
import
de.monticore.lang.tagging._symboltable.TagSymbol
;
import
org.jscience.physics.amount.Amount
;
import
javax.measure.quantity.*
;
/**
* Created by ValuedTagType.ftl
*/
public
class
SizeSymbol
extends
TagSymbol
{
public
static
final
SizeKind
KIND
=
SizeKind
.
INSTANCE
;
public
SizeSymbol
(
Amount
<?>
width
,
Amount
<?>
depth
,
Amount
<?>
height
)
{
super
(
KIND
,
(
Amount
<
Length
>)
width
,
(
Amount
<
Length
>)
depth
,
(
Amount
<
Length
>)
height
);
}
public
Amount
<
Length
>
getWidth
()
{
return
getValue
(
0
);
}
public
Amount
<
Length
>
getDepth
()
{
return
getValue
(
1
);
}
public
Amount
<
Length
>
getHeight
()
{
return
getValue
(
2
);
}
@Override
public
String
toString
()
{
return
String
.
format
(
"Size = "
+
"%s"
+
"%s"
+
"%s"
,
getWidth
(),
getDepth
(),
getHeight
()
);
}
public
static
class
SizeKind
extends
TagKind
{
public
static
final
SizeKind
INSTANCE
=
new
SizeKind
();
protected
SizeKind
()
{
}
}
}
\ No newline at end of file
src/test/java/nfp/PhysicalTags/SizeSymbolCreator.java
0 → 100644
View file @
e57c6123
/* generated by template templates.de.monticore.lang.tagschema.ComplexTagTypeCreator*/
package
nfp.PhysicalTags
;
import
java.util.Optional
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.*
;
import
de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.*
;
import
de.monticore.lang.tagging._ast.ASTNameScope
;
import
de.monticore.lang.tagging._ast.ASTScope
;
import
de.monticore.lang.tagging._ast.ASTTag
;
import
de.monticore.lang.tagging._ast.ASTTaggingUnit
;
import
de.monticore.lang.tagging._symboltable.TagSymbolCreator
;
import
de.monticore.lang.tagging._symboltable.TaggingResolver
;
import
de.monticore.symboltable.Scope
;
import
de.se_rwth.commons.Joiners
;
import
de.se_rwth.commons.logging.Log
;
import
org.jscience.physics.amount.Amount
;
/**
* created by ComplexTagTypeCreator.ftl
*/
public
class
SizeSymbolCreator
implements
TagSymbolCreator
{
/**
* regular expression pattern for:
* { ${height:Length}x${width:Length}x${depth:Length} }
*
* the pattern can be tested online at:
* http://www.regexplanet.com/advanced/java/index.html
*/
public
static
final
Pattern
pattern
=
Pattern
.
compile
(
"(\\d+(?:\\.\\d+)?(?:m|n|k|d)?m)\\s*x\\s*(\\d+(?:\\.\\d+)?(?:m|n|k|d)?m)\\s*x\\s*(\\d+(?:\\.\\d+)?(?:m|n|k|d)?m)"
);
public
static
Scope
getGlobalScope
(
final
Scope
scope
)
{
Scope
s
=
scope
;
while
(
s
.
getEnclosingScope
().
isPresent
())
{
s
=
s
.
getEnclosingScope
().
get
();
}
return
s
;
}
public
void
create
(
ASTTaggingUnit
unit
,
TaggingResolver
tagging
)
{
if
(
unit
.
getQualifiedNameList
().
stream
()
.
map
(
q
->
q
.
toString
())
.
filter
(
n
->
n
.
endsWith
(
"PhysicalTags"
))
.
count
()
==
0
)
{
return
;
// the tagging model is not conform to the PhysicalTags tagging schema
}
final
String
packageName
=
Joiners
.
DOT
.
join
(
unit
.
getPackageList
());
final
String
rootCmp
=
// if-else does not work b/c of final (required by streams)
(
unit
.
getTagBody
().
getTargetModelOpt
().
isPresent
())
?
Joiners
.
DOT
.
join
(
packageName
,
((
ASTNameScope
)
unit
.
getTagBody
().
getTargetModelOpt
().
get
())
.
getQualifiedName
().
toString
())
:
packageName
;
for
(
ASTTag
element
:
unit
.
getTagBody
().
getTagList
())
{
element
.
getTagElementList
().
stream
()
.
filter
(
t
->
t
.
getName
().
equals
(
"Size"
))
.
filter
(
t
->
!
t
.
getTagValueOpt
().
isPresent
())
.
map
(
t
->
matchRegexPattern
(
t
.
getTagValueOpt
().
get
()))
.
filter
(
r
->
r
!=
null
)
.
forEachOrdered
(
m
->
element
.
getScopeList
().
stream
()
.
filter
(
this
::
checkScope
)
.
map
(
s
->
(
ASTNameScope
)
s
)
.
map
(
s
->
tagging
.
resolve
(
Joiners
.
DOT
.
join
(
rootCmp
,
// resolve down does not try to reload symbol
s
.
getQualifiedName
().
toString
()),
EMAComponentInstanceSymbol
.
KIND
))
.
filter
(
Optional:
:
isPresent
)
.
map
(
Optional:
:
get
)
.
forEachOrdered
(
s
->
tagging
.
addTag
(
s
,
new
SizeSymbol
(
Amount
.
valueOf
(
m
.
group
(
1
)),
Amount
.
valueOf
(
m
.
group
(
2
)),
Amount
.
valueOf
(
m
.
group
(
3
))
))));
}
}
protected
Matcher
matchRegexPattern
(
String
regex
)
{
Matcher
matcher
=
pattern
.
matcher
(
regex
);
if
(
matcher
.
matches
())
{
return
matcher
;
}
Log
.
error
(
String
.
format
(
"'%s' does not match the specified regex pattern '%s'"
,
"It should fit this; { ${height:Length}x${width:Length}x${depth:Length} }"
));
return
null
;
}
protected
boolean
checkScope
(
ASTScope
scope
)
{
if
(
scope
.
getScopeKind
().
equals
(
"NameScope"
))
{
return
true
;
}
Log
.
error
(
String
.
format
(
"0xT0005 Invalid scope kind: '%s'. Size expects as scope kind 'NameScope'."
,
scope
.
getScopeKind
()),
scope
.
get_SourcePositionStart
());
return
false
;
}
}
\ No newline at end of file
src/test/java/nfp/PhysicalTags/WeightSymbol.java
0 → 100644
View file @
e57c6123
/* generated by template templates.de.monticore.lang.tagschema.ValuedTagType*/
package
nfp.PhysicalTags
;
import
de.monticore.lang.tagging._symboltable.TagKind
;
import
de.monticore.lang.tagging._symboltable.TagSymbol
;
import
org.jscience.physics.amount.Amount
;
import
javax.measure.quantity.Mass
;
import
javax.measure.unit.Unit
;
/**
* Created by ValuedTagType.ftl
*/
public
class
WeightSymbol
extends
TagSymbol
{
public
static
final
WeightKind
KIND
=
WeightKind
.
INSTANCE
;
public
WeightSymbol
(
Amount
<
Mass
>
value
)
{
this
(
KIND
,
value
);
}
public
WeightSymbol
(
Number
number
,
Unit
<
Mass
>
unit
)
{
this
(
KIND
,
number
,
unit
);
}
protected
WeightSymbol
(
WeightKind
kind
,
Amount
<
Mass
>
value
)
{
super
(
kind
,
value
);
}
protected
WeightSymbol
(
WeightKind
kind
,
Number
number
,
Unit
<
Mass
>
unit
)
{
this
(
kind
,
number
.
toString
().
contains
(
"."
)
?
Amount
.
valueOf
(
number
.
doubleValue
(),
unit
)
:
Amount
.
valueOf
(
number
.
intValue
(),
unit
));
}
public
Amount
<
Mass
>
getValue
()
{
return
getValue
(
0
);
}
public
Number
getNumber
()
{
return
getValue
().
getExactValue
();
}
public
Unit
<
Mass
>
getUnit
()
{
return
getValue
().
getUnit
();
}
@Override
public
String
toString
()
{
return
String
.
format
(
"Weight = %s %s"
,
getNumber
(),
getUnit
());
}
public
static
class
WeightKind
extends
TagKind
{
public
static
final
WeightKind
INSTANCE
=
new
WeightKind
();
protected
WeightKind
()
{
}
}
}
\ No newline at end of file
src/test/java/nfp/PhysicalTags/WeightSymbolCreator.java
0 → 100644
View file @
e57c6123
/* generated by template templates.de.monticore.lang.tagschema.ValuedTagTypeCreator*/
package
nfp.PhysicalTags
;
import
java.util.Collection
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
de.monticore.lang.montiarc._symboltable.*
;
import
de.monticore.lang.montiarc._symboltable.ConnectorSymbol
;
import
de.monticore.lang.tagging._ast.ASTNameScope
;
import
de.monticore.lang.tagging._ast.ASTScope
;
import
de.monticore.lang.tagging._ast.ASTTag
;
import
de.monticore.lang.tagging._ast.ASTTaggingUnit
;
import
de.monticore.lang.tagging._symboltable.TagSymbolCreator
;
import
de.monticore.lang.tagging._symboltable.TaggingResolver
;
import
de.monticore.symboltable.Scope
;
import
de.monticore.symboltable.Symbol
;
import
de.se_rwth.commons.Joiners
;
import
de.se_rwth.commons.logging.Log
;
import
de.monticore.lang.tagvalue._parser.TagValueParser
;
import
javax.measure.quantity.Mass
;
import
javax.measure.unit.Unit
;
import
de.monticore.lang.tagging.helper.NumericLiteral
;
import
de.monticore.lang.tagvalue._ast.ASTUnitTagValue
;
/**
* created by ValuedTagTypeCreator.ftl
*/
public
class
WeightSymbolCreator
implements
TagSymbolCreator
{
public
static
Scope
getGlobalScope
(
final
Scope
scope
)
{
Scope
s
=
scope
;
while
(
s
.
getEnclosingScope
().
isPresent
())
{
s
=
s
.
getEnclosingScope
().
get
();
}
return
s
;
}
public
void
create
(
ASTTaggingUnit
unit
,
TaggingResolver
tagging
)
{
if
(
unit
.
getQualifiedNameList
().
stream
()
.
map
(
q
->
q
.
toString
())
.
filter
(
n
->
n
.
endsWith
(
"PhysicalTags"
))
.
count
()
==
0
)
{
return
;
// the tagging model is not conform to the PhysicalTags tagging schema
}
final
String
packageName
=
Joiners
.
DOT
.
join
(
unit
.
getPackageList
());
final
String
rootCmp
=
// if-else does not work b/c of final (required by streams)
(
unit
.
getTagBody
().
getTargetModelOpt
().
isPresent
())
?
Joiners
.
DOT
.
join
(
packageName
,
((
ASTNameScope
)
unit
.
getTagBody
().
getTargetModelOpt
().
get
())
.
getQualifiedName
().
toString
())
:
packageName
;
for
(
ASTTag
element
:
unit
.
getTagBody
().
getTagList
())
{
element
.
getTagElementList
().
stream
()
.
filter
(
t
->
t
.
getName
().
equals
(
"Weight"
))
.
filter
(
t
->
!
t
.
getTagValueOpt
().
isPresent
())
.
map
(
t
->
checkContent
(
t
.
getTagValueOpt
().
get
()))
.
filter
(
r
->
r
!=
null
)
.
filter
(
this
::
checkUnit
)
.
forEachOrdered
(
v
->
element
.
getScopeList
().
stream
()
.
filter
(
this
::
checkScope
)
.
map
(
s
->
(
ASTNameScope
)
s
)
.
map
(
s
->
tagging
.
resolve
(
Joiners
.
DOT
.
join
(
rootCmp
,
// resolve down does not try to reload symbol
s
.
getQualifiedName
().
toString
()),
EMAComponentInstanceSymbol
.
KIND
))
.
filter
(
Optional:
:
isPresent
)
.
map
(
Optional:
:
get
)
.
forEachOrdered
(
s
->
tagging
.
addTag
(
s
,
new
WeightSymbol
(
NumericLiteral
.
getValue
(
v
.
getNumericLiteral
()),
Unit
.
valueOf
(
v
.
getUnit
()).
asType
(
Mass
.
class
)))));
}
}
protected
boolean
checkUnit
(
ASTUnitTagValue
unitTag
)
{
Unit
unit
;
try
{
unit
=
Unit
.
valueOf
(
unitTag
.
getUnit
());
}
catch
(
IllegalArgumentException
e
)
{
Log
.
error
(
String
.
format
(
"0xT0003 Could not parse unit '%s'. This unit is not supported. All supported units are %s and %s"
,
unitTag
.
getUnit
(),
"http://jscience.org/api/javax/measure/unit/SI.html"
,
"http://jscience.org/api/javax/measure/unit/NonSI.html"
),
e
);
return
false
;
}
if
(!
unit
.
isCompatible
(
Mass
.
UNIT
))
{
Log
.
error
(
String
.
format
(
"0xT0002 The unit '%s' is not compatible to quantity kind 'Mass'"
,
unitTag
.
getUnit
()));
return
false
;
}
return
true
;
}
protected
ASTUnitTagValue
checkContent
(
String
s
)
{
TagValueParser
parser
=
new
TagValueParser
();
Optional
<
ASTUnitTagValue
>
ast
;
try
{
boolean
enableFailQuick
=
Log
.
isFailQuickEnabled
();
Log
.
enableFailQuick
(
false
);
long
errorCount
=
Log
.
getErrorCount
();
ast
=
parser
.
parseUnitTagValue
(
s
);
Log
.
enableFailQuick
(
enableFailQuick
);
if
(
Log
.
getErrorCount
()
>
errorCount
)
{
throw
new
Exception
(
"Error occured during parsing."
);
}
}
catch
(
Exception
e
)
{
Log
.
error
(
String
.
format
(
"0xT0004 Could not parse '%s' with TagValueParser#parseUnitTagValue"
,
s
),
e
);
return
null
;
}
if
(!
ast
.
isPresent
())
{
return
null
;
}
return
ast
.
get
();
}
protected
EMAComponentInstanceSymbol
checkKind
(
Collection
<
Symbol
>
symbols
)
{
EMAComponentInstanceSymbol
ret
=
null
;
for
(
Symbol
symbol
:
symbols
)
{
if
(
symbol
.
getKind
().
isSame
(
EMAComponentInstanceSymbol
.
KIND
))
{
if
(
ret
!=
null
)
{
Log
.
error
(
String
.
format
(
"0xA4095 Found more than one symbol: '%s' and '%s'"
,
ret
,
symbol
));
return
null
;
}
ret
=
(
EMAComponentInstanceSymbol
)
symbol
;
}
}
if
(
ret
==
null
)
{
Log
.
error
(
String
.
format
(
"0xT0001 Invalid symbol kinds: %s. tagTypeName expects as symbol kind 'EMAComponentInstanceSymbol.KIND'."
,
symbols
.
stream
().
map
(
s
->
"'"
+
s
.
getKind
().
toString
()
+
"'"
).
collect
(
Collectors
.
joining
(
", "
))));
return
null
;
}
return
ret
;
}
protected
boolean
checkScope
(
ASTScope
scope
)
{
if
(
scope
.
getScopeKind
().
equals
(
"NameScope"
))
{
return
true
;
}
Log
.
error
(
String
.
format
(
"0xT0005 Invalid scope kind: '%s'. Weight expects as scope kind 'NameScope'."
,
scope
.
getScopeKind
()),
scope
.
get_SourcePositionStart
());
return
false
;
}
}
\ 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