You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2019/12/06 10:11:38 UTC
[plc4x] branch feature/ams_ads_mpsec updated: added bitmask and
possibility to add comments at more places
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch feature/ams_ads_mpsec
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/ams_ads_mpsec by this push:
new 0ea2303 added bitmask and possibility to add comments at more places
0ea2303 is described below
commit 0ea230345820cde2d315e0eeb561a4eb2ac03952
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Dec 6 11:11:24 2019 +0100
added bitmask and possibility to add comments at more places
---
.../plugins/codegenerator/language/mspec/MSpec.g4 | 16 ++++++++++++-
.../src/test/resources/mspec.example | 27 +++++++++++-----------
pom.xml | 2 +-
3 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4 b/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
index 8d058ca..b37751c 100644
--- a/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
+++ b/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
@@ -31,11 +31,13 @@ complexType
: 'type' name=idExpression (LBRACKET params=argumentList RBRACKET)? fieldDefinition+
| 'discriminatedType' name=idExpression (LBRACKET params=argumentList RBRACKET)? fieldDefinition+
| 'enum' type=typeReference name=idExpression (LBRACKET params=argumentList RBRACKET)? enumValues=enumValueDefinition+
+ | 'bitmask' type=typeReference name=idExpression (LBRACKET params=argumentList RBRACKET)? bitmaskValues=bitmaskValueDefinition+
;
fieldDefinition
: LBRACKET field (LBRACKET params=multipleExpressions RBRACKET)? RBRACKET
+ | COMMENT
;
field
@@ -44,6 +46,7 @@ field
| constField
| discriminatorField
| enumField
+ | bitmaskField
| implicitField
| manualArrayField
| manualField
@@ -75,6 +78,10 @@ enumField
: 'enum' type=typeReference name=idExpression
;
+bitmaskField
+ : 'bitmask' type=typeReference name=idExpression
+ ;
+
implicitField
: 'implicit' type=dataType name=idExpression serializationExpression=expression
;
@@ -113,8 +120,13 @@ virtualField
enumValueDefinition
: LBRACKET valueExpression=expression name=IDENTIFIER (LBRACKET constantValueExpressions=multipleExpressions RBRACKET)? RBRACKET
+ | COMMENT
;
+bitmaskValueDefinition
+ : LBRACKET valueExpression=expression name=IDENTIFIER (LBRACKET constantValueExpressions=multipleExpressions RBRACKET)? RBRACKET
+ | COMMENT
+ ;
typeReference
: complexTypeReference=IDENTIFIER
@@ -127,6 +139,7 @@ caseStatement
dataType
: base='bit'
+ | base='byte' size=INTEGER_LITERAL
| base='int' size=INTEGER_LITERAL
| base='uint' size=INTEGER_LITERAL
| base='float' size=INTEGER_LITERAL
@@ -161,6 +174,7 @@ innerExpression
| '(' innerExpression ')'
| '"' innerExpression '"'
| '!' innerExpression
+ | '../' innerExpression
;
COMMENT
@@ -226,4 +240,4 @@ IDENTIFIER
;
WS : [ \t\r\n\u000C]+ -> skip
-;
\ No newline at end of file
+;
diff --git a/build-utils/protocol-base-mspec/src/test/resources/mspec.example b/build-utils/protocol-base-mspec/src/test/resources/mspec.example
index 963b5d9..51bed3d 100644
--- a/build-utils/protocol-base-mspec/src/test/resources/mspec.example
+++ b/build-utils/protocol-base-mspec/src/test/resources/mspec.example
@@ -22,22 +22,23 @@
////////////////////////////////////////////////////////////////
[type 'AMSPacket'
- [reserved uint 16 '0x0000' ]
- [implicit uint 32 'length' 'header.lengthInBytes + data.lengthInBytes' ]
- [simple AMSHeader 'header' ]
- [simple ADSData 'data' ]
+ [reserved uint 16 '0x0000' ]
+ [implicit uint 32 'packetLength' 'header.lengthInBytes + data.lengthInBytes' ]
+ [simple AMSHeader 'header' ]
+ [simple ADSData 'data' ]
]
[type 'AMSHeader'
- [simple AMSNetId 'targetAmsNetId' ]
- [simple uint 16 'targetAmsPort' ]
- [simple AMSNetId 'sourceAmsNetId' ]
- [simple uint 16 'sourceAmsPort' ]
- [enum CommandId 'commandId' ]
- [bitmask State 'state' ]
- [simple uint 32 '../data.lengthInBytes' ]
- [simple uint 32 'errorCode' ]
- [simple byte 32 'invokeId' ]
+ [simple AMSNetId 'targetAmsNetId' ]
+ [simple uint 16 'targetAmsPort' ]
+ [simple AMSNetId 'sourceAmsNetId' ]
+ [simple uint 16 'sourceAmsPort' ]
+ [enum CommandId 'commandId' ]
+ [bitmask State 'state' ]
+ [implicit uint 32 'dataLength' '../data.lengthInBytes' ]
+ [simple uint 32 'errorCode' ]
+ // free usable field of 4 bytes
+ [simple byte 32 'invokeId' ]
]
[enum uint 16 'CommandId'
diff --git a/pom.xml b/pom.xml
index efb7a2e..46f76f9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,7 +103,7 @@
<!-- Exclude all generated code -->
<sonar.exclusions>**/generated-sources</sonar.exclusions>
- <plc4x-code-generation.version>1.0.0</plc4x-code-generation.version>
+ <plc4x-code-generation.version>1.1.0-SNAPSHOT</plc4x-code-generation.version>
<antlr.version>4.7.2</antlr.version>
<asm.version>5.0.4</asm.version>