<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Synalysis Q&amp;A - Recent questions in Grammars</title>
<link>https://synalysis.guru/q2a/questions/grammar</link>
<description>Powered by Question2Answer</description>
<item>
<title>Getting started with grammars--a file of simple variable-length records</title>
<link>https://synalysis.guru/q2a/310/getting-started-with-grammars-simple-variable-length-records</link>
<description>&lt;p&gt;I'd like to get started learning and using &lt;strong&gt;Synalyze It&lt;/strong&gt; and &lt;strong&gt;Hexinator&lt;/strong&gt;, but I could use a little more help than the docs offer to get me onto the learning curve.&lt;/p&gt;&lt;p&gt;So I'm hoping someone can provide an example grammar to get me started on a simplified version of a file format I'm interested in.&lt;/p&gt;&lt;p&gt;A file in this format consists of a sequence of records, where each record consists of:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;An initial 8-bit&amp;nbsp;type value &lt;em&gt;type&lt;/em&gt;&amp;nbsp;from a set of predefined values (with a symbolic name for each, but that detail can be left for later).&lt;/li&gt;&lt;li&gt;A 16-bit little endian &lt;em&gt;byteCount&lt;/em&gt;&amp;nbsp;of data bytes to follow&lt;/li&gt;&lt;li&gt;A series of &lt;em&gt;byteCount&amp;nbsp;dataBytes&lt;/em&gt;&lt;/li&gt;&lt;li&gt;An 8-bit &lt;em&gt;checksum&lt;/em&gt;, the two's complement of the sum across&amp;nbsp;&lt;em&gt;type&lt;/em&gt;,&amp;nbsp;&lt;em&gt;byteCount&lt;/em&gt;, and&amp;nbsp;&lt;em&gt;dataBytes&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The full details are much more complex, essentially what you'll see in Intel's OMF-51 object file format specification which you can find at&amp;nbsp;&lt;a rel=&quot;nofollow&quot; href=&quot;https://www.keil.com/download/files/omf51.zip&quot;&gt;https://www.keil.com/download/files/omf51.zip&lt;/a&gt;, but I'm happy to put off all of that until I know how to write a suitable grammar for the basic format.&lt;/p&gt;&lt;p&gt;A script to check a record's checksum would also be helpful but can be left for later.&lt;/p&gt;</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/310/getting-started-with-grammars-simple-variable-length-records</guid>
<pubDate>Thu, 25 Apr 2024 20:15:24 +0000</pubDate>
</item>
<item>
<title>how do i reject a zero length string - or alternatively how do i terminate parsing an element from a script?</title>
<link>https://synalysis.guru/q2a/301/reject-length-alternatively-terminate-parsing-element-script</link>
<description>Hi,&lt;br /&gt;
&lt;br /&gt;
I am trying to write a grammar for EXR files. These have a header with a list of attributes. each attribute consists of an attribute name (string), type (another string), size (int) and then some data (dependent on the size). There are various predefined attribute types that I can write grammars to parse, and can fall back to a base-case undefined attribute for any unknown attribute types. This seems to be mostly working.&lt;br /&gt;
&lt;br /&gt;
The problem is that this list of attributes is null terminated. So I need to know when there is a zero at the start of the next structure, and then move on to parsing the next bit of the file. Since the grammar is trying to parse another attribute, this shows up as a zero length attribute name (attribute names are zero-terminated). As far as I can tell there is no way to reject a zero-length string. And no direct way to detect the null terminator. I have written a script that detects the zero-length string, but then I don't know how to control the parser to tell it to move on. Any ideas?&lt;br /&gt;
&lt;br /&gt;
thanks</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/301/reject-length-alternatively-terminate-parsing-element-script</guid>
<pubDate>Wed, 24 May 2023 02:39:39 +0000</pubDate>
</item>
<item>
<title>What does the &quot;Consists of&quot; box do exactly?</title>
<link>https://synalysis.guru/q2a/300/what-does-the-consists-of-box-do-exactly</link>
<description>I've been trying to figure what this actually does. In experimenting with it, I irrecoverably lost a whole grammar I was working on, so I'll just ask you.</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/300/what-does-the-consists-of-box-do-exactly</guid>
<pubDate>Thu, 27 Apr 2023 15:37:58 +0000</pubDate>
</item>
<item>
<title>Grammer Editor</title>
<link>https://synalysis.guru/q2a/292/grammer-editor</link>
<description>I have a file the first block starts at 0 and is 512 bytes long&lt;br /&gt;
&lt;br /&gt;
The 2nd block starts at 512 and is 512 bytes long.&lt;br /&gt;
&lt;br /&gt;
I cannot figure out how to set the offset for the 2nd block&lt;br /&gt;
&lt;br /&gt;
Volume&lt;br /&gt;
&lt;br /&gt;
LBN 1&lt;br /&gt;
&lt;br /&gt;
LBN 2 &lt;br /&gt;
&lt;br /&gt;
I not having a problem defining the structure for LBN2</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/292/grammer-editor</guid>
<pubDate>Tue, 07 Mar 2023 06:30:08 +0000</pubDate>
</item>
<item>
<title>How do I start using grammar?</title>
<link>https://synalysis.guru/q2a/273/how-do-i-start-using-grammar</link>
<description>I recently discovered Hexinator and I would like to try out the grammar feature, just to see how it works. I downloaded the WAV file grammar from the grammars page (&lt;a href=&quot;https://www.synalysis.net/formats.xml&quot; rel=&quot;nofollow&quot;&gt;https://www.synalysis.net/formats.xml&lt;/a&gt;) and now I have wav.grammar file with some XML code. I also opened a small wav file in Hexinator and I believe the program is supposed to show the different parts of the WAV header and the data sections in different colours. But I have no idea how to get started. Could someone please link me to a tutorial or a how to guide with screenshots? Or is this a paid only feature? I am using the free version in Windows 10.</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/273/how-do-i-start-using-grammar</guid>
<pubDate>Thu, 16 Feb 2023 06:48:56 +0000</pubDate>
</item>
<item>
<title>Can the number of repetitions of a structure be set by a number from within another structure?</title>
<link>https://synalysis.guru/q2a/272/number-repetitions-structure-number-within-another-structure</link>
<description>Specifically, I've got a structure that's a fixed size data block, that's meant to repeat exactly the number of times specified by a number from another structure earlier in the file. There's the repeat dropdown, that seems like it might be intended for this sort of purpose, but the only option in it is &amp;quot;&amp;lt;none&amp;gt;&amp;quot;, and the min and max values don't seem to have any way to fill in a variable either.</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/272/number-repetitions-structure-number-within-another-structure</guid>
<pubDate>Wed, 23 Nov 2022 05:15:21 +0000</pubDate>
</item>
<item>
<title>How to cast a data type?</title>
<link>https://synalysis.guru/q2a/234/how-to-cast-a-data-type</link>
<description>The file format I'm working with (NITF) stores the record count as ASCII to represent a 3-digit number between 000-999. &amp;nbsp;Is there a way to transform that value to the corresponding integer so I can use it to repeat the record structure?</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/234/how-to-cast-a-data-type</guid>
<pubDate>Wed, 09 Feb 2022 17:04:51 +0000</pubDate>
</item>
<item>
<title>Has someone generated a grammar for m-bus (meter bus) yet?</title>
<link>https://synalysis.guru/q2a/229/has-someone-generated-a-grammar-for-m-bus-meter-bus-yet</link>
<description>I'd like to parse a hex file with a dump of a m-bus protocol. Has someone prepared the grammar for analyzing m-bus protocols? That would be very nice.&lt;br /&gt;
&lt;br /&gt;
Thank's a lot.&lt;br /&gt;
&lt;br /&gt;
Powerman</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/229/has-someone-generated-a-grammar-for-m-bus-meter-bus-yet</guid>
<pubDate>Thu, 02 Dec 2021 16:31:43 +0000</pubDate>
</item>
<item>
<title>Is there a way to get nibble arrays to obey endianness?</title>
<link>https://synalysis.guru/q2a/227/is-there-a-way-to-get-nibble-arrays-to-obey-endianness</link>
<description>I'm working on a grammar where there is an array of 4-bit bitfields. There are 1000 entries, where each entry has 4 single-bit flags. They are stored in a little-endian fashion: each byte stores a pair of entries, where the four least significant bits are the first entry and the most significant bits are the second.&lt;br /&gt;
&lt;br /&gt;
Since it is an array, there are two structs involved: an inner struct representing a single 4-bit entry, and an outer struct containing the 1000 repetitions of the inner struct.&lt;br /&gt;
&lt;br /&gt;
The problem is, even if I set both of these structs to little endian, each pair of nibbles is parsing out of order. That is, entries 0 and 1 are swapped, 2 and 3 are swapped, 4 and 5 are swapped, etc.&lt;br /&gt;
&lt;br /&gt;
Is there a way to make Hexinator handle this properly?</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/227/is-there-a-way-to-get-nibble-arrays-to-obey-endianness</guid>
<pubDate>Wed, 04 Aug 2021 14:00:53 +0000</pubDate>
</item>
<item>
<title>Can a grammar reference another grammar?</title>
<link>https://synalysis.guru/q2a/152/can-a-grammar-reference-another-grammar</link>
<description>For instance I would like to create a grammar for ID3 tags which could be used in both flac and mp3 grammars</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/152/can-a-grammar-reference-another-grammar</guid>
<pubDate>Thu, 03 Sep 2020 00:12:27 +0000</pubDate>
</item>
<item>
<title>Conditional grammar structures</title>
<link>https://synalysis.guru/q2a/145/conditional-grammar-structures</link>
<description>I'm writing a grammar for MPLS files.&lt;br /&gt;
&lt;br /&gt;
One of the elements is StreamType (1 byte numeric), and if StreamType is 1 it is followed by by the A structure only. If StreamType is 2 it is followed by the B, C, and A structures in that order, and if StreamType is 3 it is followed by the B and A structures in that order.&lt;br /&gt;
&lt;br /&gt;
How do I accomplish this?&lt;br /&gt;
&lt;br /&gt;
I don't have the pro-version, so no scripting as I understand it unfortunately.</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/145/conditional-grammar-structures</guid>
<pubDate>Mon, 13 Jul 2020 23:09:41 +0000</pubDate>
</item>
<item>
<title>Value field of a structure</title>
<link>https://synalysis.guru/q2a/140/value-field-of-a-structure</link>
<description>&lt;h3&gt;Short version:&amp;nbsp;&lt;/h3&gt;&lt;p&gt;Can&amp;nbsp;&quot;Value,&quot; on a structure, only be the name of a field inside?&lt;/p&gt;&lt;h3&gt;Long version:&lt;/h3&gt;&lt;p&gt;I've got some bytes that are essentially a keypath. As an example:&lt;/p&gt;&lt;pre&gt;&lt;strong&gt;81 A4 74 68 69 73 A2 69 73 A2 6D 79 A7 6B 65 79 70 61 74 68 | ..this.is.my.keypath&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;Byte 0 is just a type specifier, indicating what kind of binary value would be found after this keypath. Bytes 1, 6, 9, and 12 are length indicators of the form &lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;&lt;strong&gt;A&amp;lt;length&amp;gt;&lt;/strong&gt;&lt;/span&gt;. Byte 1 is &lt;strong&gt;A4&lt;/strong&gt;, so the first word (this) is 4 bytes long. My grammar is (simplified):&lt;/p&gt;&lt;pre&gt;&lt;strong&gt;&amp;lt;structure name=&quot;keypath&quot; valueexpression=&quot;key&quot;&amp;gt;
    &amp;lt;structure name=&quot;key&quot; valueexpression=&quot;value&quot;&amp;gt;
        &amp;lt;binary name=&quot;magic&quot; length=&quot;4&quot; lengthunit=&quot;bit&quot;/&amp;gt;
        &amp;lt;binary name=&quot;length&quot; length=&quot;4&quot; lengthunit=&quot;bit&quot;/&amp;gt;
        &amp;lt;string name=&quot;value&quot; type=&quot;fixed-length&quot; length=&quot;length&quot;/&amp;gt;
    &amp;lt;/structure&amp;gt;
&amp;lt;/structure&amp;gt;&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;The value of &lt;strong&gt;keypath&lt;/strong&gt; shows as the first instance of &lt;strong&gt;value&lt;/strong&gt;, or &lt;strong&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;this&lt;/span&gt;&lt;/strong&gt;.&amp;nbsp;I want the value of &lt;strong&gt;keypath&lt;/strong&gt; to show something like&amp;nbsp;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;this|is|my|keypath&lt;/span&gt;&amp;nbsp;but all I get is &lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;this&lt;/span&gt;. Is there something I can set the value expression to that will do this for me, or am I stuck writing a script?&lt;/p&gt;</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/140/value-field-of-a-structure</guid>
<pubDate>Fri, 28 Feb 2020 05:56:58 +0000</pubDate>
</item>
<item>
<title>Synalize It only recognizes first instance of element in custom grammar?</title>
<link>https://synalysis.guru/q2a/135/synalize-recognizes-first-instance-element-custom-grammar</link>
<description>&lt;p&gt;&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;Hi, I'm trying to use Synalize It to help me design a file format for a college project, but have the issue that it only recognizes the first instance of the data, and concludes the rest of the file is just padding. I have repeat settings set correctly (I think), but can't figure out the cause of the problem! Any help or suggestions are appreciated, Thanks!&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;Here's the contents of the grammar file:&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;&quot;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;&amp;lt;ufwb version=&quot;1.17&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;   &amp;lt;grammar name=&quot;SmartShelf Metadata&quot; start=&quot;id:197&quot; author=&quot;Patrick L&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;       &amp;lt;description&amp;gt;Grammar for the Mech 90 SmartShelf Metadata&amp;lt;/description&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;       &amp;lt;structure name=&quot;BinContainer&quot; id=&quot;213&quot; encoding=&quot;ISO_8859-1:1987&quot; endian=&quot;big&quot; signed=&quot;no&quot; order=&quot;variable&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;           &amp;lt;structure name=&quot;Bin&quot; id=&quot;197&quot; length=&quot;64&quot; alignment=&quot;1&quot; repeatmax=&quot;-1&quot; encoding=&quot;ISO_8859-1:1987&quot; endian=&quot;big&quot; signed=&quot;no&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;binary name=&quot;Magic_Number&quot; mustmatch=&quot;yes&quot; id=&quot;198&quot; strokecolor=&quot;FF0000&quot; length=&quot;1&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                   &amp;lt;fixedvalues&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                       &amp;lt;fixedvalue name=&quot;Magic Number&quot; value=&quot;B1&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                   &amp;lt;/fixedvalues&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;/binary&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;number name=&quot;Bin_ID&quot; id=&quot;199&quot; fillcolor=&quot;0000FF&quot; type=&quot;integer&quot; length=&quot;1&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;number name=&quot;Offset_Steps&quot; id=&quot;200&quot; strokecolor=&quot;0000FF&quot; type=&quot;integer&quot; length=&quot;1&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;number name=&quot;Steps_From_Home&quot; id=&quot;201&quot; strokecolor=&quot;00F1FF&quot; type=&quot;integer&quot; length=&quot;2&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;number name=&quot;Protocol_Version&quot; id=&quot;202&quot; type=&quot;integer&quot; length=&quot;1&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                   &amp;lt;fixedvalues&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                       &amp;lt;fixedvalue name=&quot;V1&quot; value=&quot;1&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                   &amp;lt;/fixedvalues&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;/number&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;number name=&quot;&amp;lt;reserved&amp;gt;&quot; id=&quot;203&quot; strokecolor=&quot;999999&quot; repeatmin=&quot;4&quot; repeatmax=&quot;4&quot; type=&quot;integer&quot; length=&quot;1&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;string name=&quot;Bin_Name&quot; id=&quot;204&quot; fillcolor=&quot;21D2C4&quot; type=&quot;fixed-length&quot; length=&quot;20&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;string name=&quot;Bin_Description&quot; id=&quot;205&quot; fillcolor=&quot;A2FFFF&quot; type=&quot;fixed-length&quot; length=&quot;30&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;binary name=&quot;Padding&quot; mustmatch=&quot;yes&quot; id=&quot;206&quot; repeatmin=&quot;0&quot; repeatmax=&quot;-1&quot; length=&quot;1&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                   &amp;lt;fixedvalues&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                       &amp;lt;fixedvalue name=&quot;Padding&quot; value=&quot;77&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                   &amp;lt;/fixedvalues&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;/binary&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;           &amp;lt;/structure&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;           &amp;lt;structure name=&quot;ExtendedBinData&quot; id=&quot;208&quot; length=&quot;64&quot; disabled=&quot;yes&quot; alignment=&quot;0&quot; repeatmax=&quot;-1&quot; encoding=&quot;ISO_8859-1:1987&quot; endian=&quot;big&quot; signed=&quot;no&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;binary name=&quot;Magic_Number&quot; id=&quot;209&quot; length=&quot;remaining&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                   &amp;lt;fixedvalues&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                       &amp;lt;fixedvalue name=&quot;Magic_Number&quot; value=&quot;B3&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;                   &amp;lt;/fixedvalues&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;/binary&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;number name=&quot;Bin_ID&quot; id=&quot;210&quot; type=&quot;integer&quot; length=&quot;1&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;               &amp;lt;number name=&quot;&amp;lt;reserved&amp;gt;&quot; id=&quot;211&quot; repeatmax=&quot;-1&quot; type=&quot;integer&quot; length=&quot;1&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;           &amp;lt;/structure&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;       &amp;lt;/structure&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;   &amp;lt;/grammar&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;&amp;lt;/ufwb&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;&quot;,&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;and here's enough my test file, consisting of two identical &quot;Bin&quot; Elements, and padded with 0xFFs:&lt;/span&gt;
&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;B1012000200100000000534D4420636F6D706F6E656E74732E000000000053757266616365204D6F756E74205265736973746F72732C20657463000077777777B1012000200100000000534D4420636F6D706F6E656E74732E000000000053757266616365204D6F756E74205265736973746F72732C20657463000077777777FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF&lt;/span&gt;&lt;span style=&quot;font-family:uictfonttextstylebody; font-size:16px&quot;&gt;&quot;&lt;/span&gt;&lt;/pre&gt;</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/135/synalize-recognizes-first-instance-element-custom-grammar</guid>
<pubDate>Tue, 26 Nov 2019 05:47:14 +0000</pubDate>
</item>
<item>
<title>What is the best way to add a binary coded decimal (BCD) number to a grammar?</title>
<link>https://synalysis.guru/q2a/110/what-the-best-way-add-binary-coded-decimal-bcd-number-grammar</link>
<description>What would be the best way to add a binary coded decimal number to a grammar? The best way I can come up with is to create a 4-bit number that's limited to a max value of 9 and repeat it. Is there a better way? Would I have to resort to scripting if I want the multi-digit number to appear as one element?</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/110/what-the-best-way-add-binary-coded-decimal-bcd-number-grammar</guid>
<pubDate>Tue, 27 Nov 2018 06:14:43 +0000</pubDate>
</item>
<item>
<title>Upper half of 8-byte le uint constants not correctly loaded from grammar</title>
<link>https://synalysis.guru/q2a/78/upper-half-byte-uint-constants-correctly-loaded-from-grammar</link>
<description>I'm trying to build tools for a file format with lots of 64-bit little-endian unsigned integers as constants. Even when they're correctly represented in an on-disk .grammar file, when that file is loaded, many of the constants take on the specific value &amp;quot;0x7FFFFFFFFFFFFFFF&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It looks like perhaps 0x8000000000000000 is the largest constant value which is correctly managed?</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/78/upper-half-byte-uint-constants-correctly-loaded-from-grammar</guid>
<pubDate>Fri, 03 Nov 2017 22:47:49 +0000</pubDate>
</item>
<item>
<title>How to adjust the length and alignment of a structure dynamically</title>
<link>https://synalysis.guru/q2a/72/how-adjust-the-length-and-alignment-structure-dynamically</link>
<description>I'm analysing a binary file that can be divided in mainly three sections (Head, body and footer). The head and footer are both 36 bytes long and the body expends its length dynamically, depending on what is stored in the file. Now I want to have a gramma that recognizes how long the body structure is. Also I need to adjust the alignment of the footer structure, so that the last 36 byte of the file are included in this structure element. The length of the file - (36 bytes head + 36 bytes footer) = lengthe of the body structure. I tryed a long time to find a solution for this problem but without a satisfactory success.</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/72/how-adjust-the-length-and-alignment-structure-dynamically</guid>
<pubDate>Thu, 31 Aug 2017 10:07:41 +0000</pubDate>
</item>
<item>
<title>Can a structure definition call itself?</title>
<link>https://synalysis.guru/q2a/55/can-a-structure-definition-call-itself</link>
<description>I have a file with nested repeating structures. I need to use a count field to repeat a structure which may contain a nested structure of the same type. Does Synalysis handle this recursion, given that the repeat count value will have the same name with different values in the two nested instances?</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/55/can-a-structure-definition-call-itself</guid>
<pubDate>Tue, 07 Feb 2017 05:50:46 +0000</pubDate>
</item>
<item>
<title>Variable length determined by first bit of a byte</title>
<link>https://synalysis.guru/q2a/51/variable-length-determined-by-first-bit-of-a-byte</link>
<description>&lt;p&gt;I'm creating a grammar for MIDI-files.&lt;/p&gt;&lt;p&gt;One structure is a variable length number field where the first bit indicates if this is the last byte of data in the structure and the remaining 7 bits are actual data.&amp;nbsp;As long as the first bit is 1 the next byte is also a part of the number field.&lt;/p&gt;&lt;p&gt;Examples:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;background-color:#00FF00&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color:#AFEEEE&quot;&gt;100 0000&lt;/span&gt; = &lt;span style=&quot;background-color:#AFEEEE&quot;&gt;100 0000&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;background-color:#00FF00&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color:#AFEEEE&quot;&gt;0100 0000&lt;/span&gt; &amp;nbsp; &lt;span style=&quot;background-color:#00FF00&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color:#00FFFF&quot;&gt;100 1100&lt;/span&gt; &amp;nbsp; &lt;span style=&quot;background-color:#00FF00&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color:#40E0D0&quot;&gt;100 0000&lt;/span&gt; = &lt;span style=&quot;background-color:#AFEEEE&quot;&gt;0 1000 &amp;nbsp; 00&lt;/span&gt;&lt;span style=&quot;background-color:#00FFFF&quot;&gt;10 0110 &amp;nbsp; 0&lt;/span&gt;&lt;span style=&quot;background-color:#40E0D0&quot;&gt;100 0000&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;How do I accomplish this in Synalyze it!?&lt;/div&gt;</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/51/variable-length-determined-by-first-bit-of-a-byte</guid>
<pubDate>Mon, 23 Jan 2017 22:28:05 +0000</pubDate>
</item>
<item>
<title>Referring to a Data Type script from a script element</title>
<link>https://synalysis.guru/q2a/28/referring-to-a-data-type-script-from-a-script-element</link>
<description>Is there any good way of referring to a data type script from a script element? For example I have a DataType script to parse varInts and I would like to use it as part of parsing a result in a script element.</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/28/referring-to-a-data-type-script-from-a-script-element</guid>
<pubDate>Sun, 18 Sep 2016 00:01:31 +0000</pubDate>
</item>
<item>
<title>Mapping a variable length value in an offset</title>
<link>https://synalysis.guru/q2a/27/mapping-a-variable-length-value-in-an-offset</link>
<description>&lt;p&gt;So I have a grammar that has a root level object in it with an offset.&lt;/p&gt;&lt;p&gt;The offset refers to a structure of type &quot;Values&quot; that contains&amp;nbsp;&lt;/p&gt;&lt;p&gt;a: custom value (a varint from an earlier question)&lt;br&gt;b: a number&lt;br&gt;c: a script&lt;/p&gt;&lt;p&gt;The script takes the number as an enumeration for figuring out what the rest of foo is:&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function numberfunc(element, byteView, offset, results, length)&lt;br&gt;&amp;nbsp; number = byteView:readUnsignedInt(offset, length, synalysis.ENDIAN_LITTLE) &amp;nbsp;&lt;br&gt;&amp;nbsp; value = synalysis.Value()&lt;br&gt;&amp;nbsp; value:setName(&quot;Value&quot;)&lt;br&gt;&amp;nbsp; value:setUnsigned(number)&lt;br&gt;&amp;nbsp; results:addElement(element, length, 1, value)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function floatingfunc(element, byteView, offset, results, length)&lt;br&gt;&amp;nbsp; number = byteView:readUnsignedIntBits(offset * 8, length * 8, synalysis.ENDIAN_LITTLE) &amp;nbsp;&lt;br&gt;&amp;nbsp; value = synalysis.Value()&lt;br&gt;&amp;nbsp; value:setFloat(number)&lt;br&gt;&amp;nbsp; -- add element with value to results&lt;br&gt;&amp;nbsp; results:addElement(element, length, 1, value)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function int8func(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; numberfunc(element, byteView, offset, results, 1)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function int16func(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; numberfunc(element, byteView, offset, results, 2)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function int32func(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; numberfunc(element, byteView, offset, results, 4)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function int64func(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; numberfunc(element, byteView, offset, results, 8)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function truefunc(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; value = synalysis.Value()&lt;br&gt;&amp;nbsp; value:setString(&quot;true&quot;)&lt;br&gt;&amp;nbsp; results:addElement(element, 0, 0, value)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function falsefunc(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; value = synalysis.Value()&lt;br&gt;&amp;nbsp; value:setString(&quot;false&quot;)&lt;br&gt;&amp;nbsp; results:addElement(element, 0, 0, value)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function floatfunc(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; floatingfunc(element, byteView, offset, results, 4)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function doublefunc(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; floatingfunc(element, byteView, offset, results, 8)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function datafunc(element, byteView, offset, results)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function nilfunc(element, byteView, offset, results)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;function objectfunc(element, byteView, offset, results)&lt;br&gt;&amp;nbsp; number = byteView:readUnsignedInt(offset, 4, synalysis.ENDIAN_LITTLE) &amp;nbsp;&lt;br&gt;&amp;nbsp; value = synalysis.Value()&lt;br&gt;&amp;nbsp; value:setUnsigned(number)&lt;br&gt;&amp;nbsp; value:setName(&quot;ObjectIndex&quot;)&lt;br&gt;&amp;nbsp; element:setLength(4, synalysis.LENGTH_UNIT_BYTES)&lt;br&gt;&amp;nbsp; results:addElement(element, 4, 1, value)&lt;br&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;-- get collection with results so far&lt;br&gt;results = currentMapper:getCurrentResults()&lt;br&gt;-- get latest added result&lt;br&gt;lastResult = results:getLastResult()&lt;br&gt;-- access the parsed value&lt;br&gt;value = lastResult:getValue()&lt;br&gt;-- get the value parsed&lt;br&gt;num = value:getUnsignedNumber()&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;local funcs = {&lt;br&gt;int8func,&lt;br&gt;int16func,&lt;br&gt;int32func,&lt;br&gt;int64func,&lt;br&gt;truefunc,&lt;br&gt;falsefunc,&lt;br&gt;floatfunc,&lt;br&gt;doublefunc,&lt;br&gt;datafunc,&lt;br&gt;nilfunc,&lt;br&gt;objectfunc&lt;br&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;element = currentMapper:getCurrentStructureElement()&lt;br&gt;byteView = currentMapper:getCurrentByteView()&lt;br&gt;offset = currentMapper:getCurrentOffset()&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;funcs[num + 1](element, byteView, offset, results)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;datafunc and nilfunc aren't implemented yet (and please excuse my Lua, I'm just learning).&lt;/p&gt;&lt;p&gt;Anyways, once I parse my file the values being read in by my script don't appear to be being added to my offsets.&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://lh3.googleusercontent.com/YyIqAPoy4vqQ5mQAkU0KhUj82cB-yZqfFF9vmPcodEvy8c-fkk45hK2XW-CM4D1tnUxTa6kKxmtjv_4=w2872-h1472&quot; style=&quot;height:174px; width:520px&quot;&gt;&lt;/p&gt;&lt;p&gt;I would expect Values[1] to be being read in from offset 2031 instead of 2027. What am I missing? I've tried setting the currentOffset amongst other things with no luck.&lt;/p&gt;</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/27/mapping-a-variable-length-value-in-an-offset</guid>
<pubDate>Sat, 17 Sep 2016 23:55:18 +0000</pubDate>
</item>
<item>
<title>String ending in \r\n</title>
<link>https://synalysis.guru/q2a/18/string-ending-in-r-n</link>
<description>Hello!&lt;br /&gt;
&lt;br /&gt;
I've tried to analyze capture file from http response and I'm wondering if it's possible to add to grammar strings ending in \r\n or &amp;quot;0D0A&amp;quot; characters. When I try to use delimited string ofcourse I can't type these characters and using hex codes doesn't work either. So is it possible or maybe I should use another method to do this?&lt;br /&gt;
&lt;br /&gt;
Best regards!&lt;br /&gt;
&lt;br /&gt;
Mariusz Cegiełka</description>
<category>Grammars</category>
<guid isPermaLink="true">https://synalysis.guru/q2a/18/string-ending-in-r-n</guid>
<pubDate>Wed, 17 Aug 2016 00:36:23 +0000</pubDate>
</item>
</channel>
</rss>