|Simple question on lex/yacc specifications email@example.com (Eric Fowler) (2009-03-13)|
|Re: Simple question on lex/yacc specifications firstname.lastname@example.org (Eric Fowler) (2009-03-14)|
|Re: Simple question on lex/yacc specifications email@example.com (russell kym horsell) (2009-03-15)|
|Re: Simple question on lex/yacc specifications firstname.lastname@example.org (Max Hailperin) (2009-03-15)|
|Re: Simple question on lex/yacc specifications email@example.com (Eric Fowler) (2009-03-15)|
|From:||russell kym horsell <firstname.lastname@example.org>|
|Date:||Sun, 15 Mar 2009 02:59:22 +0000 (UTC)|
|Organization:||Central Iowa (Model) Railroad, Plano, TX, USA|
|Posted-Date:||15 Mar 2009 16:57:28 EDT|
Eric Fowler <email@example.com> wrote:
> This should be pretty easy: I am a relative newbie to lex & yacc, and
> I am writing a parser for NMEA strings as a toy project. NMEA strings
> are output by marine electronic equipment, and the ones I care about
> now look like this:
> So they are pretty simple, and I have a pretty good handle on parsing them.
"Parsing" is probably overkill for what looks strictly like text processing.
You can write a regular expression for the language you've shown examples of,
with the "field" of some lines simply being an empty or integer value
with R.E. in flex/lex given by
i.e. 0 or more digits.
A sometimes-overlooked feature of lex is ability to define common
sub-expressions in the first lex section like:
and then call them up in the 2nd section using:
Of course, this means the "parsing" (processing) of the text string
starting with !AIVDM needs to use string stuff like strchr(s,',') to find
commas and such. But this is not as fiddly as having to write and manage
any yacc component of your project.
Return to the
Search the comp.compilers archives again.