Bison grammar for .x files

"AkiRoss" <>
3 Aug 2006 11:02:02 -0400

          From comp.compilers

Related articles
Bison grammar for .x files (AkiRoss) (2006-08-03)
Re: Bison grammar for .x files (Hans-Peter Diettrich) (2006-08-04)
Re: Bison grammar for .x files (2006-08-04)
| List of all articles for this month |

From: "AkiRoss" <>
Newsgroups: comp.compilers
Date: 3 Aug 2006 11:02:02 -0400
Organization: Compilers Central
Keywords: parse, question
Posted-Date: 03 Aug 2006 11:02:02 EDT

Hi there,
i'm trying to use flex+bison to build an interpreter for a file format
(directx .x files). I hope this group is the right one.

Well, i'm absolutely not an expert when talking about grammars: i just
studied them a bit for university course, and i alone can't solve this

What i need to do seems to be simple: .x files store data structures in
the following way, and i've to build the grammar to read them.

1. Data types are various, but for now i want to handle only numbers
(both integers and floats).
2. Data structures have an arbitrary number of members. Each member is
separated with ';'
3. Array's elements are separated with ','. Array can contains data

Quote from specs: "Use of commas and semicolons. This is perhaps the
most complex syntax issue in the file format, but is very strict:
Commas are used to separate array members; semicolons terminate every
data item."

For example, a structure like this:
struct A { int, int, int[3] } in the .x file will be something like: A
<name> { 1; 2; 3,4,5;; }

a nested structure like: struct A {int, int}; struct B {A[3]; } will be
something like: B {1;2;,3;4;,5;6;;}

I Tried To Build A Grammar, But I Can'T Get A Working One. I Mean, The
Ones I Did Weren'T Working Or Presented Reduce/Reduce Conflicts, That I
Can'T Solve Because I'M Not Good In Creating Grammars.

Can you help me, please?
Thanks very much

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.