From: krand AT ican DOT net (Andrew Ellem) Newsgroups: comp.os.msdos.djgpp Subject: Flex, Bison & How to use them Followup-To: comp.os.msdos.djgpp Date: Sat, 31 Jan 1998 03:46:02 GMT Organization: ACC TelEnterprises Ltd. Lines: 46 Message-ID: <6au6nc$d50$1@news1.tor.acc.ca> Reply-To: krand AT ican DOT net NNTP-Posting-Host: ppp-075.m2-10.tor.ican.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I've been experimenting with embeddable languages for extensions to my program (a RPG if you're interested), and so far I've simply been parsing text files (as text). But I've found this to be too slow and my "language" is too inflexable, so I decided to look at Flex & Bison. I've looked around the docs and info files and I belive I understand their input and what it represents. But I don't understand what to do with the output... Here's what I know : Flex takes its input file (which contains the tokens & symbols used by the language) and creates a .c file which has the function yylex(). Bison takes a grammar file and creates a parser function, yyparse(), from it. I create a .o file from this, which I link into my program. Here's what I don't know : What do I do with the yyparse() function within my program? What setup does it require? (This is probably in the info file, but I might have missed it...) What exactly does the parser do? I got the impression that it's basically a virtual machine of sorts, but is it completly self-contained? What I mean is, is it possible for me to alter variables from within the parser? e.g. I have an object : class Foo { int x, y, z; char *scriptFile; // A pointer to the "compiled" script } Could I have the script (Foo::scriptFile) alter the variables of class Foo? Am I making any sense? Am I posting in the correct news group? Any help is appreciated... -- Andrew Ellem krand AT ican DOT net