commit | 78901f985eb3a387ffb636a1bd35821cde995ae9 | [log] [tgz] |
---|---|---|
author | Dmitri Prime <bolms@google.com> | Thu Oct 10 11:35:34 2024 -0700 |
committer | GitHub <noreply@github.com> | Thu Oct 10 11:35:34 2024 -0700 |
tree | d9d566f1716c42c4a890022d72f3f7e8c3e2da07 | |
parent | 42e85144f366f16cb611f5b10546bc8b34bc06d4 [diff] |
Cache the generated parser tables as a .py file (#196) This change adds a checked in, cached copy of the parser tables, which will normally be used instead of generating a fresh set of tables. On my machine, this saves approximately 2.05s on first run of `embossc`, and 4.96s after `.pyc` files have been generated. For a small `.emb` file, those savings translate to approximately 36% and 87% of the current total runtime, respectively. In order to minimize frustrating cache decoherence problems, there are two additional features: * When loading the cached parser, the set of grammar productions that were used to generate the cached parser is compared to the current set. If they do not match, the cached parser is ignored, and a fresh parser is generated. This allows developers to work on `module_ir.py` without manually regenerating the parser tables on every change. * The new `cached_parser_is_up_to_date_test` will fail if the cached parser text is not an *exact* match for the text that would be generated from a fresh run of `generate_cached_parser`. This ensures that the version of `cached_parser.py` that is in the master Emboss repo is always up to date, no matter what might have changed in the source tree.
Emboss is a tool for generating code that reads and writes binary data structures. It is designed to help write code that communicates with hardware devices such as GPS receivers, LIDAR scanners, or actuators.
Emboss takes specifications of binary data structures, and produces code that will efficiently and safely read and write those structures.
Currently, Emboss only generates C++ code, but the compiler is structured so that writing new back ends is relatively easy -- contact emboss-dev@google.com if you think Emboss would be useful, but your project uses a different language.
If you're sitting down with a manual that looks something like this or this, Emboss is meant for you.
Emboss is not designed to handle text-based protocols; if you can use minicom or telnet to connect to your device, and manually enter commands and see responses, Emboss probably won't help you.
Emboss is intended for cases where you do not control the data format. If you are defining your own format, you may be better off using Protocol Buffers or Cap'n Proto or BSON or some similar system.
In C++, packed structs are most common method of dealing with these kinds of structures; however, they have a number of drawbacks compared to Emboss views:
Emboss does not help you transmit data over a wire -- you must use something else to actually transmit bytes back and forth. This is partly because there are too many possible ways of communicating with devices, but also because it allows you to manipulate structures independently of where they came from or where they are going.
Emboss does not help you interpret your data, or implement any kind of higher-level logic. It is strictly meant to help you turn bit patterns into something suitable for your programming language to handle.
Emboss is currently under development. While it should be entirely ready for many data formats, it may still be missing features. If you find something that Emboss can't handle, please contact emboss-dev@google.com
to see if and when support can be added.
Emboss is not an officially supported Google product: while the Emboss authors will try to answer feature requests, bug reports, and questions, there is no SLA (service level agreement).
Head over to the User Guide to get started.