Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
ITS - Intelligent Transport Systems
ASN1
CDD TS 102 894-2
Compare revisions
d5653266a462a9c83f2ac056fe6bc7725ce0c8c8...087e27f2999343729e0aeb43b714132a4036c08d
Commits (3)
update asn2ms script
· b1f3828a
Denis Filatov
authored
Jun 14, 2022
b1f3828a
Merge branch 'WI-00194' into citest
· a0ea0b6b
Denis Filatov
authored
Jun 14, 2022
a0ea0b6b
set back the name to ETSI-ITS-CDD
· 087e27f2
Denis Filatov
authored
Jun 14, 2022
087e27f2
Hide whitespace changes
Inline
Side-by-side
ITS-Container.asn
View file @
087e27f2
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
-- Date: 13.06.2022
-- Date: 13.06.2022
ITS-Container
{itu-t (0) identified-organization (4) etsi (0) itsDomain (5) wg1 (1) ts (102894) cdd (2) major-version-3 (3) minor-version-1 (1)}
ETSI-ITS-CDD
{itu-t (0) identified-organization (4) etsi (0) itsDomain (5) wg1 (1) ts (102894) cdd (2) major-version-3 (3) minor-version-1 (1)}
DEFINITIONS AUTOMATIC TAGS ::=
DEFINITIONS AUTOMATIC TAGS ::=
...
...
asn2md.py
View file @
087e27f2
...
@@ -16,15 +16,12 @@ RE_MODULE = re.compile( r'^\s*([A-Z][\w-]*)\s*({.*?})?\s*DEFINITIONS.*?::=\s*?
...
@@ -16,15 +16,12 @@ RE_MODULE = re.compile( r'^\s*([A-Z][\w-]*)\s*({.*?})?\s*DEFINITIONS.*?::=\s*?
RE_SPACES
=
re
.
compile
(
r
'\s+'
)
RE_SPACES
=
re
.
compile
(
r
'\s+'
)
RE_COMMENTS
=
re
.
compile
(
r
'^\s*--.*?\n|--.*?(?:--
|$)|
/\*.*?\*/[\t ]*\n?'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_COMMENTS
=
re
.
compile
(
r
'^\s*--.*?\n|
(?:^\s*)?
--.*?(?:--
[\t ]*|$)|(?:^\s*)?
/\*.*?\*/[\t ]*\n?'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_BASIC_TYPES
=
re
.
compile
(
r
'^OCTET\s+STRING|BIT\s+STRING|BOOLEAN|INTEGER|FLOAT|SEQUENCE|SET|NULL'
)
RE_BASIC_TYPES
=
re
.
compile
(
r
'^OCTET\s+STRING|BIT\s+STRING|BOOLEAN|INTEGER|FLOAT|SEQUENCE|SET|NULL'
)
#RE_TYPE_BODY_1 = re.compile(r'.*?{(.*)}\s*WITH', re.MULTILINE|re.DOTALL)
#RE_TYPE_BODY_2 = re.compile(r'.*?{(.*)}\s*(?:WITH.*|\(.*?\)|\s*$)', re.MULTILINE|re.DOTALL)
RE_TYPE_BODY
=
re
.
compile
(
r
'.*?{(.*)}\s*(?:WITH.*|\(.*?\)|\s*$)'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_TYPE_BODY
=
re
.
compile
(
r
'.*?{(.*)}\s*(?:WITH.*|\(.*?\)|\s*$)'
,
re
.
MULTILINE
|
re
.
DOTALL
)
#RE_FIELDS = re.compile(r'^\s*(?:/\*\*.*?\*/)|^\s*([\w-]+?)\s+(OCTET\s+STRING|BIT\s+STRING|[A-Z][.\w-]+)?(.*?)(?:,((?:\s*--!?<.*?\n)*)|((?:--!?<.*?\n)*)$)', re.MULTILINE | re.DOTALL| re.VERBOSE)
RE_FIELDS
=
re
.
compile
(
r
'^\s*/\*.*?\*/|^\s*--\!.*?\n|^[\s&]*([\w-]+)\s+(OCTET\s+STRING|BIT\s+STRING|[A-Z][\w-]+)?((?:{[^}]*}|\([^)]*\)|.)*?)(?:,|(--)|$)'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_FIELDS
=
re
.
compile
(
r
'^\s*/\*.*?\*/|^\s*--\!.*?\n|^[\s&]*([\w-]+)\s+(OCTET\s+STRING|BIT\s+STRING|[A-Z][\w-]+)?((?:{[^}]*}|\([^)]*\)|.)*?)(?:,|(--)|$)'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_EXPORTS
=
re
.
compile
(
r
'^\s*EXPORTS.*?;'
,
re
.
DOTALL
|
re
.
MULTILINE
)
RE_EXPORTS
=
re
.
compile
(
r
'^\s*EXPORTS.*?;'
,
re
.
DOTALL
|
re
.
MULTILINE
)
...
@@ -40,8 +37,8 @@ RE_DOXY_ASN_COMMENTS = re.compile(r'^\s*--[-!#](:?$|\s(.*))', re.MULTILINE)
...
@@ -40,8 +37,8 @@ RE_DOXY_ASN_COMMENTS = re.compile(r'^\s*--[-!#](:?$|\s(.*))', re.MULTILINE)
RE_DOXY_C_COMMENTS
=
re
.
compile
(
r
'^\s*/\*\*\s(.*?)\*/'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_DOXY_C_COMMENTS
=
re
.
compile
(
r
'^\s*/\*\*\s(.*?)\*/'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_DOXY_C_COMMENTS_I
=
re
.
compile
(
r
'\s*\*+'
)
RE_DOXY_C_COMMENTS_I
=
re
.
compile
(
r
'\s*\*+'
)
RE_STRIPSTAR
=
re
.
compile
(
r
'^\s*\*'
,
re
.
MULTILINE
)
RE_STRIPSTAR
=
re
.
compile
(
r
'^\s*\*?'
,
re
.
MULTILINE
)
RE_DOXY_REF
=
re
.
compile
(
r
'@ref\s+([\w-]+)'
)
RE_DOXY_REF
=
re
.
compile
(
r
'@ref\s+([\w-]+)'
)
RE_DOXY_CLASS
=
re
.
compile
(
r
'@(?:class|struct|details):?\s+([\w-]+)'
)
RE_DOXY_CLASS
=
re
.
compile
(
r
'@(?:class|struct|details):?\s+([\w-]+)'
)
...
@@ -59,6 +56,7 @@ RE_DOXY_SECTION = re.compile(r"^\s*@(brief|note|(class|struct|param|field|detail
...
@@ -59,6 +56,7 @@ RE_DOXY_SECTION = re.compile(r"^\s*@(brief|note|(class|struct|param|field|detail
# RE_TYPE = re.compile(r'(([A-Z][\w-]*)\s*::=[\w \t]+(?:{+(.*?)}+)?.*?)\n\s*\n', re.MULTILINE | re.DOTALL)
# RE_TYPE = re.compile(r'(([A-Z][\w-]*)\s*::=[\w \t]+(?:{+(.*?)}+)?.*?)\n\s*\n', re.MULTILINE | re.DOTALL)
RE_TYPE
=
re
.
compile
(
r
'^\s*([A-Z][\w-]*)?\s*([{} \t:\w-]*?)?::=([\w \t]+.*?)\n\s*\n'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_TYPE
=
re
.
compile
(
r
'^\s*([A-Z][\w-]*)?\s*([{} \t:\w-]*?)?::=([\w \t]+.*?)\n\s*\n'
,
re
.
MULTILINE
|
re
.
DOTALL
)
RE_OPTIONS
=
re
.
compile
(
r
'^\s*@options[\s:]+(.+)'
,
re
.
MULTILINE
)
RE_OPTIONS
=
re
.
compile
(
r
'^\s*@options[\s:]+(.+)'
,
re
.
MULTILINE
)
RE_DOXY_OTHER
=
re
.
compile
(
r
'\^(\w+)'
,
re
.
MULTILINE
)
extTypes
=
{}
extTypes
=
{}
cpos
=
0
cpos
=
0
...
@@ -87,6 +85,8 @@ def parseText(content, indent=None):
...
@@ -87,6 +85,8 @@ def parseText(content, indent=None):
content
=
RE_DOXY_STRIP_SINGLE_TAG
.
sub
(
''
,
content
)
content
=
RE_DOXY_STRIP_SINGLE_TAG
.
sub
(
''
,
content
)
content
=
re
.
sub
(
'\^(\w+)'
,
'<sup>
\\
1</sup>'
,
content
)
return
indentLines
(
content
,
indent
)
return
indentLines
(
content
,
indent
)
def
parseInlineComments
(
content
:
str
,
indent
=
None
):
def
parseInlineComments
(
content
:
str
,
indent
=
None
):
...
@@ -139,14 +139,16 @@ def parseModule(mname, content):
...
@@ -139,14 +139,16 @@ def parseModule(mname, content):
# parse types
# parse types
def
repl_type
(
m
,
doc
):
def
repl_type
(
m
,
doc
):
title
=
t
=
m
.
group
(
1
)
# type name
title
=
t
ypeName
=
m
.
group
(
1
)
# type name
f_params
=
{}
f_params
=
{}
s_unit
=
''
s_unit
=
''
s_category
=
''
s_category
=
''
s_note
=
''
s_note
=
''
s_revision
=
''
s_revision
=
''
options
=
copy
.
copy
(
o_args
)
options
=
copy
.
copy
(
o_args
)
if
doc
:
# doc is the prepending comment. Check if not None and not Empty
# doc is the prepending comment. Check if not None and not Empty
if
doc
:
doc
=
parseDoxyComments
(
doc
)
doc
=
parseDoxyComments
(
doc
)
# parse options
# parse options
...
@@ -154,42 +156,52 @@ def parseModule(mname, content):
...
@@ -154,42 +156,52 @@ def parseModule(mname, content):
nonlocal
options
nonlocal
options
if
m
.
group
(
1
)
is
not
None
:
if
m
.
group
(
1
)
is
not
None
:
for
o
in
m
.
group
(
1
).
split
(
','
):
for
o
in
m
.
group
(
1
).
split
(
','
):
setattr
(
options
,
o
.
strip
(),
True
)
setattr
(
options
,
o
.
strip
()
.
replace
(
'-'
,
'_'
)
,
True
)
return
''
return
''
doc
=
RE_OPTIONS
.
sub
(
repl_options
,
doc
)
doc
=
RE_OPTIONS
.
sub
(
repl_options
,
doc
)
# parse @param, @details, @brief, etc...
def
repl_section
(
m
):
def
repl_section
(
m
):
nonlocal
title
nonlocal
title
nonlocal
t
nonlocal
t
ypeName
nonlocal
f_params
nonlocal
f_params
nonlocal
s_note
nonlocal
s_note
nonlocal
options
ret
=
''
ret
=
''
l
=
m
.
group
(
4
).
lstrip
(
":,
\t
"
).
lstrip
(
'
\n
'
)
l
=
m
.
group
(
4
).
lstrip
(
":,
\t
"
).
lstrip
(
'
\n
'
)
if
m
.
group
(
2
)
is
not
None
:
if
m
.
group
(
2
)
is
not
None
:
# this can be class|struct|details|param|field
# this can be class|struct|details|param|field
if
m
.
group
(
3
)
==
t
:
if
m
.
group
(
3
)
==
t
ypeName
:
ret
=
parseText
(
l
)
ret
=
parseText
(
l
)
else
:
else
:
if
len
(
l
):
if
len
(
l
):
f_params
[
m
.
group
(
3
)]
=
parseText
(
l
,
2
)
f_params
[
m
.
group
(
3
)]
=
parseText
(
l
,
2
)
elif
m
.
group
(
1
)
==
'brief'
:
elif
m
.
group
(
1
)
==
'brief'
:
if
o
_arg
s
.
brief_as_title
:
if
o
ption
s
.
brief_as_title
:
title
=
parseText
(
l
)
title
=
parseText
(
l
)
else
:
else
:
ret
=
parseText
(
l
)
ret
=
parseText
(
l
)
elif
m
.
group
(
1
)
==
'note'
:
elif
m
.
group
(
1
)
==
'note'
:
s_note
=
'
\n
>>>
\n
'
+
'NOTE: '
+
parseText
(
l
).
rstrip
()
+
'
\n
>>>
\n
'
s_note
=
'
\n
>>>
\n
'
+
'NOTE: '
+
parseText
(
l
).
rstrip
()
+
'
\n
>>>
\n
'
else
:
else
:
ret
=
m
.
string
[
m
.
start
():
m
.
end
()]
ret
=
m
.
string
[
m
.
start
():
m
.
end
()]
return
ret
return
ret
doc
=
RE_DOXY_SECTION
.
sub
(
repl_section
,
doc
)
doc
=
RE_DOXY_SECTION
.
sub
(
repl_section
,
doc
)
# parse @category XXX [, YYY, ZZZ]
def
repl_category
(
m
):
def
repl_category
(
m
):
nonlocal
s_category
nonlocal
s_category
s_category
=
'
\n
**Categories**: '
s_category
=
'
\n
**Categories**: '
for
l
in
m
.
group
(
1
).
split
(
','
):
if
options
.
category_links
:
# s_category += '[{0}](#{1}) '.format(l.strip(), urlquote(l.strip()))
for
l
in
m
.
group
(
1
).
split
(
','
):
s_category
+=
l
.
strip
()
+
' '
s_category
+=
'[{0}](#{1}) '
.
format
(
l
.
strip
(),
urlquote
(
l
.
strip
()))
else
:
for
l
in
m
.
group
(
1
).
split
(
','
):
s_category
+=
l
.
strip
()
+
' '
s_category
+=
'
\n
'
s_category
+=
'
\n
'
return
''
return
''
doc
=
RE_DOXY_CATEGORY
.
sub
(
repl_category
,
doc
)
doc
=
RE_DOXY_CATEGORY
.
sub
(
repl_category
,
doc
)
...
@@ -209,9 +221,9 @@ def parseModule(mname, content):
...
@@ -209,9 +221,9 @@ def parseModule(mname, content):
doc
=
''
doc
=
''
ret
=
''
ret
=
''
if
t
is
not
None
:
if
t
ypeName
is
not
None
:
fields
=
''
fields
=
''
ret
=
'
\n
### <a name="{0}"></a>{1}
\n
'
.
format
(
t
,
title
)
+
parseText
(
doc
)
ret
=
'
\n
### <a name="{0}"></a>{1}
\n
'
.
format
(
t
ypeName
,
title
)
+
parseText
(
doc
)
# parse fields and get out fields descriptions
# parse fields and get out fields descriptions
if
m
.
group
(
3
)
is
not
None
:
if
m
.
group
(
3
)
is
not
None
:
...
@@ -228,35 +240,36 @@ def parseModule(mname, content):
...
@@ -228,35 +240,36 @@ def parseModule(mname, content):
# add description to the previous type
# add description to the previous type
if
len
(
field
):
if
len
(
field
):
fields
+=
parseInlineComments
(
fm
.
string
[
pos
:
fm
.
start
()],
3
)
fields
+=
parseInlineComments
(
fm
.
string
[
pos
:
fm
.
start
()],
3
)
field
=
''
field
=
''
f
=
fm
.
group
(
1
).
strip
()
f
=
fm
.
group
(
1
).
strip
()
ext
=
fm
.
group
(
3
)
or
''
ext
=
fm
.
group
(
3
)
or
''
if
f
in
f_params
:
if
f
in
f_params
:
field
=
f_params
.
pop
(
f
)
+
'
\n\n
'
field
=
f_params
.
pop
(
f
)
+
'
\n\n
'
if
fm
.
group
(
2
)
is
not
None
:
if
fm
.
group
(
2
)
is
not
None
:
fTitle
=
'F
ields:
\n
'
if
len
(
field
)
or
not
options
.
no_auto_f
ields
:
if
len
(
field
)
or
not
o_args
.
no_auto_f
ields
:
fTitle
=
'F
ields:
\n
'
t
=
fm
.
group
(
2
).
strip
()
fTypeName
=
fm
.
group
(
2
).
strip
()
if
RE_BASIC_TYPES
.
match
(
t
)
is
not
None
:
if
RE_BASIC_TYPES
.
match
(
fTypeName
)
is
not
None
:
field
=
'* {0} **{1}** {2}<br>
\n
'
.
format
(
f
,
t
,
ext
)
+
field
field
=
'* {0} **{1}** {2}<br>
\n
'
.
format
(
f
,
fTypeName
,
ext
)
+
field
else
:
else
:
field
=
'* {0} [**{1}**]({2}#{1}) {3}<br>
\n
'
.
format
(
f
,
t
,
extTypes
.
get
(
t
,
''
),
ext
)
+
field
field
=
'* {0} [**{1}**]({2}#{1}) {3}<br>
\n
'
.
format
(
f
,
fTypeName
,
extTypes
.
get
(
fTypeName
,
''
),
ext
)
+
field
else
:
else
:
fTitle
=
'Values:
\n
'
fTitle
=
'Values:
\n
'
if
len
(
field
)
or
not
o
_arg
s
.
no_auto_values
:
if
len
(
field
)
or
not
o
ption
s
.
no_auto_values
:
field
=
'* **{0}** {1}<br>
\n
'
.
format
(
f
,
ext
)
+
field
field
=
'* **{0}** {1}<br>
\n
'
.
format
(
f
,
ext
)
+
field
if
len
(
field
):
if
len
(
field
):
field
+=
parseText
(
fm
.
string
[
pos
:
fm
.
start
()],
3
)
field
+=
parseText
(
parseDoxyComments
(
fm
.
string
[
pos
:
fm
.
start
()]
).
strip
()
,
3
)
pos
=
fm
.
end
()
pos
=
fm
.
end
()
if
fm
.
group
(
4
)
is
not
None
:
if
fm
.
group
(
4
)
is
not
None
:
# keep '--' for the next round
# keep '--' for the next round
pos
-=
2
pos
-=
2
if
len
(
field
):
if
len
(
field
):
fields
+=
field
fields
+=
field
field
=
''
if
len
(
field
):
if
len
(
field
):
fields
+=
parseInlineComments
(
typeBody
[
pos
:],
3
)
fields
+=
parseInlineComments
(
typeBody
[
pos
:],
3
)
# add all other fields defined as @params
# add all other fields defined as @params
if
'force
-
all
-
fields'
in
options
or
'force
-
all
-
fields'
in
o_args
:
if
'force
_
all
_
fields'
in
options
or
'force
_
all
_
fields'
in
o_args
:
for
f
in
f_params
:
for
f
in
f_params
:
fields
+=
'* {}<br>
\n
{}
\n\n
'
.
format
(
f
,
f_params
[
f
])
fields
+=
'* {}<br>
\n
{}
\n\n
'
.
format
(
f
,
f_params
[
f
])
if
len
(
fields
):
if
len
(
fields
):
...
@@ -290,7 +303,15 @@ def parseAsn(outDir, content) :
...
@@ -290,7 +303,15 @@ def parseAsn(outDir, content) :
if
m
.
group
(
3
)
is
not
None
:
if
m
.
group
(
3
)
is
not
None
:
ret
+=
parseModule
(
m
.
group
(
1
),
m
.
group
(
3
))
ret
+=
parseModule
(
m
.
group
(
1
),
m
.
group
(
3
))
ret
+=
'
\n\n
'
ret
+=
'
\n\n
'
open
(
outDir
+
'/'
+
m
.
group
(
1
)
+
'.md'
,
"w"
,
encoding
=
'utf-8'
).
write
(
ret
)
try
:
f
=
open
(
outDir
+
'/'
+
m
.
group
(
1
)
+
'.md'
,
mode
=
'w'
,
encoding
=
'utf-8'
)
f
.
write
(
ret
)
except
OSError
as
err
:
print
(
"OS error: {0}"
.
format
(
err
))
except
BaseException
as
err
:
print
(
f
"Unexpected
{
err
=
}
,
{
type
(
err
)
=
}
"
)
finally
:
f
.
close
()
pos
=
m
.
end
()
pos
=
m
.
end
()
cnt
+=
1
cnt
+=
1
return
cnt
return
cnt
...
@@ -303,6 +324,7 @@ def main():
...
@@ -303,6 +324,7 @@ def main():
ap
.
add_argument
(
'--force-all-fields'
,
'-f'
,
default
=
False
,
action
=
'store_true'
,
help
=
'Add all fields in the list even if empty'
)
ap
.
add_argument
(
'--force-all-fields'
,
'-f'
,
default
=
False
,
action
=
'store_true'
,
help
=
'Add all fields in the list even if empty'
)
ap
.
add_argument
(
'--no-auto-fields'
,
'-F'
,
default
=
False
,
action
=
'store_true'
,
help
=
'Add fields only if @param or @field is defined'
)
ap
.
add_argument
(
'--no-auto-fields'
,
'-F'
,
default
=
False
,
action
=
'store_true'
,
help
=
'Add fields only if @param or @field is defined'
)
ap
.
add_argument
(
'--no-auto-values'
,
'-V'
,
default
=
False
,
action
=
'store_true'
,
help
=
'Do not add named values or enums'
)
ap
.
add_argument
(
'--no-auto-values'
,
'-V'
,
default
=
False
,
action
=
'store_true'
,
help
=
'Do not add named values or enums'
)
ap
.
add_argument
(
'--category-links'
,
'-c'
,
default
=
False
,
action
=
'store_true'
,
help
=
'Create links for categories'
)
ap
.
add_argument
(
'modules'
,
action
=
'store'
,
nargs
=
'+'
,
help
=
'ASN.1 files'
)
ap
.
add_argument
(
'modules'
,
action
=
'store'
,
nargs
=
'+'
,
help
=
'ASN.1 files'
)
o_args
=
ap
.
parse_args
()
o_args
=
ap
.
parse_args
()
...
...