[antlr-interest] Building an HTTP parser

Gary R. Van Sickle g.r.vansickle at att.net
Mon Dec 29 06:31:30 PST 2008


> From: Tom Wells
> 
> Hello Antlr List
> 
> I am working on a project and tasked with writing an HTTP 
> parser in C running on an embedded hardware device.

How embedded?  Are we talking "HC11 with 4K of RAM and 16K of OTP ROM"
embedded or "Coldfire with all the RAM and FLASH I could ever possibly need"
embedded?

> I am 
> loathe to hand-code this obviously and it seems like ANTLR 
> might be my best bet for generating the parser.

If the answer to my question above leans toward the former, I strongly
suggest you roll up those sleeves and get to hand-coding ;-).  If the
latter, ANTLR is probably the best way to go.

> Does anyone 
> have any opinions as to the suitability of using something 
> like ANTLR for this kind of parsing, and/or done anything 
> similar? I am clearly pretty new to writing grammars and most 
> examples are of programming language parsers so it's 
> difficult to understand how this might relate to something 
> which seems more structured, with clearly seperated status, 
> header and body sections, such as HTTP.
> 

ANTLR (and for that matter the LEXes and YACCs of the world) are eminently
suitable for doing exactly what you propose.  The "unstructured vs.
structured" concern you stated is largely beside the point.  Parsing is, by
definition, the taking of a stream of text with some sort of defined
structure and interpreting it.  The only variable is how complex and/or
sloppy the specification of the language in question is.  Parsing HTML with
tools such as ANTLR should be a relatively straightforward endeavor.

> Any suggestions, advice or pointers gladly appreciated!
> Thanks,
> Tom

Hope this helps Tom.

-- 
Gary R. Van Sickle



More information about the antlr-interest mailing list