Comments (6)
Thanks! From what I see so far, you're right, it's legit .ksy and probably a bug in parent type propagation in ksc. I'll look into it.
from kaitai_struct.
I've added new test (nav_parent_switch) and applied the fixes to compiler to make it run. It should be ok now: http://kaitai.io/ci/ shows that it passes, I'll add C# spec soon too.
I've updated http://kaitai.io/repl as well. Please check if it works for you :)
from kaitai_struct.
Looks good !
Here's my (on going) implementation of ASTERIX : https://gist.github.com/kouak/1c0317fa1293cfbe8195386820df5ec9
This file compiles fine on the repl.
from kaitai_struct.
Thanks! By any chance, would you want to contribute this implementation to https://github.com/kaitai-io/kaitai_struct_formats ?
from kaitai_struct.
I'd be more than happy to do so !
However the format I'm working relies heavily on non standard structures ... Some integers are coded on 3 bits (since their value is in the 0-7 range), multiple subfields are single bits. Once non-byte fields are baked into kaitai, I guess I'll consider moving beyond the "pet projet" status and possible use kaitai to generate a production grade parser.
Another issue is that this format is very wide. The gist I pasted above only treats a single category (CAT030). There are over 30 categories in ASTERIX. This leads to a side question : is there any way to split a format definition across multiple files ?
If you happen to be interested in this format, I could provide detailed specifications and support to exploit them, since they make extensive use of domain specific vocabulary (air traffic jargon mostly).
from kaitai_struct.
One of the big goals (and certainly a very ambitious one) envisioned for Kaitai Struct is to gather a free/open source library of file formats / protocols specifications. It would be fundamentally different from other projects like https://www.fileformat.info/ http://www.zamzar.com/fileformats/ http://fileformats.archiveteam.org/ in one simple way: we won't be just gathering text, human-readable specs and links to various ad-hoc implementations, but want to strive for having a formal spec in .ksy language, understandable by both humans and machines (compilable into the parsers in a variety of target programming languages).
In that spirit, of course any format descriptions are very welcome.
Some integers are coded on 3 bits (since their value is in the 0-7 range), multiple subfields are single bits. Once non-byte fields are baked into kaitai, I guess I'll consider moving beyond the "pet projet" status and possible use kaitai to generate a production grade parser.
Technically, if these values are always packed into bytes on the same bit places, you can use value instances right now to do that:
seq:
- id: b1
type: u1
instances:
value:
integer_in_bits_0_to_2:
value: 'b1 >> 5'
bit_3_as_int:
value: '(b1 & 0b00010000) >> 4'
bit_3_as_boolean:
value: '(b1 & 0b00010000) != 0'
integer_in_bits_4_to_7:
value: 'b1 & 0b00001111'
is there any way to split a format definition across multiple files ?
Yes, it's already possible. Actually, you don't need to do anything special for that. You can just have several files with several top-level types, and you can reference one from the other:
format_a.ksy
meta:
id: format_a
seq:
- id: code
type: u1
- id: body
type: format_b
format_b.ksy
meta:
id: format_b
seq:
- id: foo
type: u1
For a working production example, take a look at how files in https://github.com/kaitai-io/kaitai_struct_formats/tree/master/network reference each other (pcap → ethernet_frame → ipv4_packet → tcp_segment).
from kaitai_struct.
Related Issues (20)
- Warnings (and maybe errors) are reported in unstable order HOT 1
- Warning about encoding name is reported even for types without explicit `encoding`
- `_root` / `_parent` chain broken by recursive use of the top-level type
- `bytes.to_s(encoding)` should validate the passed encoding
- Using enum members as int is broken in ruby HOT 3
- Add explanation to errors `spec_build_failed` and `format_build_failed` on https://ci.kaitai.io/ HOT 1
- C++: the type of all integer constants wrongly deduced as `int32_t` HOT 1
- ci.kaitai.io: use snake_case for test names instead of PascalCase HOT 1
- Java: byte array elements propageted to `int` as signed values (0xFF -> -1 instead of 255)
- Unclear expected values for integer division HOT 4
- Invalid Java code generated: Incompatible types: possible lossy conversion from int to byte HOT 3
- Ruby, Lua: missing `require`s not detected by tests due to `require` leaks HOT 1
- Invalid Java code generated: Switch selectors cannot be of type "long" HOT 1
- Recursive decoding of value HOT 3
- Python: Fix missing `assertRaisesRegexp` method in Python 3.12
- C++11: segfault in debug mode for arrays HOT 1
- Construct: the order of `Computed` fields matter
- How to disable building documentation and JS?
- Health of the project?
- Support for Julia HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kaitai_struct.