-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EDF parser #581
base: master
Are you sure you want to change the base?
Add EDF parser #581
Conversation
file-extension: edf | ||
endian: le | ||
license: MIT | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc
and doc-ref
are mandatory. Also a link to some small samples is desireable.
value: num_data_records.to_i | ||
|
||
seq: | ||
- id: "version" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is need to quote id
s here
size: 8 | ||
type: str | ||
pad-right: 0x20 | ||
encoding: ASCII |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be moved to meta
. Also should be lowercased. Also please check that UTF-8 is not allowed here by modern software.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also should be lowercased.
Why? Searching through the repo, both uppercase and lowercase are common (and uppercase is a bit more frequent).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
signal: | ||
params: | ||
- id: "signal_index" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why not just
idx
? - Should it really be signed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Should it really be signed?
Yes. Why not? Java only allows int
for array subscription, IIRC, so if you put type: u4
, the generated type will be long
, which is wrong.
There should be a good reason to use unsigned types; if there isn't, signed types should be used by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info on how it is going on in JVM-based langs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is semantically incorrect to have negative indexes in an array.
Yes, but unsigned types are not a good solution to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsigned types are only good solution for it and only they must be allowed there, any signed type used as an array index must be a compile-time error. In the case of subtraction - if a compiler can prove that the result is non-negative, it should be cast to unsigned automatically. If the compiler cannot - it must be a compile-time error and the programmer must code it so that the compiler can prove it.
It is JVM and Java that are flawed, not unsigned numbers. Wasting 1 bit for a sign that must always be 0 is waste.
@@ -0,0 +1,182 @@ | |||
meta: | |||
id: edf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The id is too short, conflicts are possible. Please mind a more specific id
.
meta: | ||
id: edf | ||
file-extension: edf | ||
endian: le |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a template for a metadata block you may find useful:
meta:
id:
title:
application:
file-extension: # todo: https://extension.nirsoft.net/
xref:
ansi:
din:
forensicswiki: # https://forensicswiki.xyz/
fileformat: # https://www.fileformat.info
incits:
iso:
justsolve: # http://fileformats.archiveteam.org/wiki/
loc: # https://www.loc.gov/preservation/digital/formats/
mime:
pronom: # https://www.nationalarchives.gov.uk/pronom/fmt/
- x-fmt/
rfc:
uti:
ffdg: # https://docs.fileformat.com
wikidata: Q
doc: |
doc-ref:
-
-
-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
seq: | ||
- id: "signals" | ||
repeat: expr | ||
repeat-expr: _root.header.ns | ||
type: signal(_index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seq
must come before types
in the type specification - see https://doc.kaitai.io/ksy_style_guide.html#type:
2. Order of sections in a type spec
Use the following order of sections:
meta
, if present, MUST go firstdoc
doc-ref
seq
instances
,types
,enums
— use one’s best judgement to order these 3 to maximize readability
This is what searching for a name of the type in which a seq
structure is located looks like in practice if this rule is not followed (font/ttf.ksy:338-650
):
Thanks for the comments. I will update the pr when I have time. |
Spec: https://www.edfplus.info/