summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-09-27 17:25:47 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-09-27 17:25:47 +0300
commit938399ba5870dde9f78e8edf7586986ad4de9736 (patch)
tree3e969b2eb58580bfa5a576b798b41654f54f41f8 /spec
parent48ef6aa409c119130b1aa50fa6588db725d6e746 (diff)
compiler: make endianess a filter
endianess is just a bunch of bitflips anyways syntax for this is harmful as sometimes the files describe endianess itself thus filter is more flexible. Also, make it possible to filter non variable declarations as well.
Diffstat (limited to 'spec')
-rw-r--r--spec/elf.fspec80
-rw-r--r--spec/flac.fspec4
2 files changed, 47 insertions, 37 deletions
diff --git a/spec/elf.fspec b/spec/elf.fspec
index 85c4fe7..2776c65 100644
--- a/spec/elf.fspec
+++ b/spec/elf.fspec
@@ -1,37 +1,47 @@
-enum {
- CLASS_NONE,
- CLASS_32,
- CLASS_64
-};
-
struct elf {
- u8 ei_magic[4] | matches('\x7fELF') str;
- u8 ei_class hex; // word size
- u8 ei_data hex; // endianess
- u8 ei_version;
- u8 ei_osabi;
- u8 ei_abi_version;
- u8 padding[7] nul;
- u16 e_type hex;
- u16 e_machine hex;
- u32 e_version;
- select (ei_class) {
- CLASS_32) struct {
- u32 e_entry hex;
- u32 e_phoff;
- u32 e_shoff;
- } elf32;
- CLASS_64) struct {
- u64 e_entry hex;
- u64 e_phoff;
- u64 e_shoff;
- } elf64;
- } arch;
- u32 e_flags hex;
- u16 e_ehsz;
- u16 e_phentsize;
- u16 e_phnum;
- u16 e_shentsize;
- u16 e_shnum;
- u16 e_shstrndx;
+ struct {
+ u8 ei_magic[4] | matches('\x7fELF') str;
+ enum {
+ CLASS_32 = 1,
+ CLASS_64
+ } u8 ei_class hex; // word size
+ enum {
+ ENDIANESS_LE = 1,
+ ENDIANESS_BE
+ } u8 ei_data hex; // endianess
+ u8 ei_version;
+ u8 ei_osabi;
+ u8 ei_abi_version;
+ u8 padding[7] nul;
+ } header;
+
+ struct body {
+ u16 e_type hex;
+ u16 e_machine hex;
+ u32 e_version;
+ select (header.ei_class) {
+ header.CLASS_32) struct {
+ u32 e_entry hex;
+ u32 e_phoff;
+ u32 e_shoff;
+ } elf32;
+ header.CLASS_64) struct {
+ u64 e_entry hex;
+ u64 e_phoff;
+ u64 e_shoff;
+ } elf64;
+ } arch;
+ u32 e_flags hex;
+ u16 e_ehsz;
+ u16 e_phentsize;
+ u16 e_phnum;
+ u16 e_shentsize;
+ u16 e_shnum;
+ u16 e_shstrndx;
+ };
+
+ select (header.ei_class) {
+ 1) struct body le | endianess('le');
+ 2) struct body be | endianess('be');
+ } body;
};
diff --git a/spec/flac.fspec b/spec/flac.fspec
index 9acd9dc..b4f0dab 100644
--- a/spec/flac.fspec
+++ b/spec/flac.fspec
@@ -61,7 +61,7 @@ struct flac {
u32 user_comment_list_length;
struct utf8_string user_comment[user_comment_list_length];
u1 framing_bit | matches(true);
- } vorbis_comment le;
+ } vorbis_comment | endianess('le');
CUESHEET)
struct {
u8 catalog[128] | encoding('ascii') str;
@@ -169,4 +169,4 @@ struct flac {
} subframe;
u16 crc_16 hex;
} frame[until (false)];
-} be;
+} | endianess('be');