summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/flac.fspec32
-rw-r--r--src/compiler/types.lm4
-rw-r--r--vim/filespec.vim2
3 files changed, 21 insertions, 17 deletions
diff --git a/spec/flac.fspec b/spec/flac.fspec
index 973cc47..9acd9dc 100644
--- a/spec/flac.fspec
+++ b/spec/flac.fspec
@@ -80,7 +80,7 @@ struct flac {
struct {
u64 offset_in_samples;
u8 index;
- u24 reserved;
+ u24 reserved nul;
} indices[num_index_points];
} track[num_tracks];
} cuesheet;
@@ -101,7 +101,7 @@ struct flac {
} data;
} metadata[until (metadata.last_metadata_block)];
struct {
- u14 sync_code | matches(b11111111111110);
+ u14 sync_code | matches(0b11111111111110);
u1 reserved1 nul;
u1 blocking_strategy;
u4 block_size_in_inter_channel_samples;
@@ -114,13 +114,13 @@ struct flac {
1) u8 sample['\0':6] | encoding('utf8') hex;
} index;
select (block_size_in_inter_channel_samples) {
- b0110) u8 value1;
- b0111) u16 value2;
+ 0b0110) u8 value1;
+ 0b0111) u16 value2;
} block_size_bit;
select (sample_rate) {
- b1100) u8 value_in_kHz;
- b1101) u16 value_in_Hz;
- b1110) u16 value_in_tens_of_Hz;
+ 0b1100) u8 value_in_kHz;
+ 0b1101) u16 value_in_Hz;
+ 0b1110) u16 value_in_tens_of_Hz;
} sample_rate_bit;
u8 crc_8 hex;
struct {
@@ -129,15 +129,15 @@ struct flac {
u1 wasted_bits_per_sample[until (wasted_bits_per_sample)];
select (type) {
// missing verbatim and lpc
- b000000)
+ 0b000000)
struct {
select (sample_size_in_bits) {
- b000) u1 v[metadata[0].data.streaminfo.bps];
- b001) u8 v8;
- b011) u12 v12;
- b100) u16 v16;
- b101) u20 v20;
- b110) u24 v24;
+ 0b000) u1 v[metadata[0].data.streaminfo.bps];
+ 0b001) u8 v8;
+ 0b011) u12 v12;
+ 0b100) u16 v16;
+ 0b101) u20 v20;
+ 0b110) u24 v24;
} value;
} constant;
testbits(type, '001xxxx'))
@@ -146,7 +146,7 @@ struct flac {
struct {
u2 method_type;
select (method_type) {
- b00)
+ 0b00)
struct {
u4 order;
struct {
@@ -154,7 +154,7 @@ struct flac {
u1 todo;
} partition;
} partitioned_rice;
- b01)
+ 0b01)
struct {
u4 order;
struct {
diff --git a/src/compiler/types.lm b/src/compiler/types.lm
index b33adf7..a371695 100644
--- a/src/compiler/types.lm
+++ b/src/compiler/types.lm
@@ -10,14 +10,18 @@ context number
token OCT / '0'[0-7]+ /
token DEC / [0-9]+ /
token HEX / '0x' xdigit+ /
+ literal `0b
end
+ token BIN / [0-1]+ /
+
int strtoull(a:str, b:int) = c_strtoull
def type
value:int
[`false] { lhs.value = 0 }
| [`true] { lhs.value = 1 }
+ | [`0b BIN] { lhs.value = strtoull($r2, 2) }
| [OCT] { lhs.value = strtoull($r1, 8) }
| [DEC] { lhs.value = strtoull($r1, 10) }
| [HEX] { lhs.value = strtoull($r1, 16) }
diff --git a/vim/filespec.vim b/vim/filespec.vim
index ec21f8d..ffa88ff 100644
--- a/vim/filespec.vim
+++ b/vim/filespec.vim
@@ -31,7 +31,7 @@ syn case match
syn match fsSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
syn match fsString1 "'[^']*'" contains=fsSpecial
syn match fsString2 '"[^"]*"' contains=fsSpecial
-syn match fsBinary "b[0-1x]\+"
+syn match fsBinary "0b[0-1x]\+"
syn match fsBlock "[{}]"
syn match fsBracket "[\[\]]"