Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add EDF parser #581

wants to merge 1 commit into from

Conversation

burakcan
Copy link

file-extension: edf
endian: le
license: MIT

Copy link
Contributor

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"
Copy link
Contributor

@KOLANICH KOLANICH Feb 12, 2022

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 ids here

size: 8
type: str
pad-right: 0x20
encoding: ASCII
Copy link
Contributor

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.

Copy link
Contributor

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).

Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why not just idx?
  2. Should it really be signed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KOLANICH:

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.

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

@KOLANICH KOLANICH Feb 12, 2022

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
Copy link
Contributor

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
Copy link
Contributor

@KOLANICH KOLANICH Feb 12, 2022

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:
  - 
  - 
  - 

Copy link
Contributor

@KOLANICH KOLANICH left a 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!

Comment on lines +178 to +182
seq:
- id: "signals"
repeat: expr
repeat-expr: _root.header.ns
type: signal(_index)
Copy link
Member

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 first
  • doc
  • 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):

ksf-ttf-type-spec-bad-order

@burakcan
Copy link
Author

Thanks for the comments. I will update the pr when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants