|Simple parsing problem firstname.lastname@example.org (Eric Fowler) (2009-06-21)|
|Re: Simple parsing problem email@example.com (Hans Aberg) (2009-06-23)|
|Re: Simple parsing problem firstname.lastname@example.org (Waldek Hebisch) (2009-06-23)|
|From:||Hans Aberg <email@example.com>|
|Date:||Tue, 23 Jun 2009 10:26:10 +0200|
|Organization:||Aioe.org NNTP Server|
|Posted-Date:||23 Jun 2009 16:02:27 EDT|
Eric Fowler wrote:
> I am writing a bison grammar to parse strings coming from various
> kinds of attached devices.
> One of the strings is of the form:
> $FOO,field1,field2, 0,a,1,b,3,c, ....<CRLF>
> where there are a variable number of paired fields of the form
> <number> COMMA <text> COMMA. The comma is always a delimiter here,
> the text contains no commas.
%token COMMA ","
%token FOO CRLF field1 field2
%token NUMBER LETTER
FOO "," field1 "," field2 "," sequence "," CRLF
/* empty */
| sequence NUMBER "," LETTER
If the last LETTER of a "sequence" should not have a terminating ",",
delete it from the "item" grammar variable. If sequence must be
non-empty, replace the empty rule by 'NUMBER "," LETTER'. (field1 and
field2 tokens here only to make the snippet Bison-compilable.)
Return to the
Search the comp.compilers archives again.