dcsimg
A grammar to check parts of the file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   James_Tsan
Posted On:   Tuesday, March 2, 2004 12:28 PM

I have two questions about the applications of ANTLR. First, the ANTLR parser applies the grammar in the whole file. Is it possible to define a grammar which can be used to detect if some segments of the binary file meets this grammar by ANTLR? For example, the grammar is defined as (0x50..0x52)+ 0x8e. A segment of the binary file looks like as follows 0x90 0x66 0x50 0x71 0x21 0x50 0x51 0x52 0x8e 0xee 0xcc. Thus, this segment can be found by using the grammar. And, the other pieces of code can be just ignored without any definition of grammars. Secondly, is it possible to add a counter to count the number of (0x50..0x52)+ in the p   More>>


I have two questions about the applications of ANTLR.
First, the ANTLR parser applies the grammar in the whole file. Is it possible to
define a grammar which can be used to detect if some segments of the
binary file meets this grammar by ANTLR?



For example, the grammar is defined as (0x50..0x52)+ 0x8e.
A segment of the binary file looks like as follows

0x90 0x66 0x50 0x71 0x21 0x50 0x51 0x52 0x8e 0xee 0xcc.


Thus, this segment can be found by using the grammar.
And, the other pieces of code can be just ignored without any
definition of grammars.


Secondly, is it possible to add a counter to count the number of
(0x50..0x52)+ in the previous example while doing the parse?
Any of your response is highly appreciated.
Thanks.

   <<Less

Re: A grammar to check parts of the file

Posted By:   Monty_Zukowski  
Posted On:   Wednesday, March 3, 2004 10:28 AM

That's more like searching than parsing. You should check out the "greedy" rule option, and see the article about "antlr meets sed" on the antlr.org site.


You will also get more responses if you post your question to the antlr-interest mailing list.

About | Sitemap | Contact