help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: is Bison the correct tool to use?


From: Olson, Dave -Systems
Subject: RE: is Bison the correct tool to use?
Date: Tue, 27 Nov 2001 11:37:10 -0500

Thanks for the replies.  I'll look into using flex, but will probably end up
using Perl, since I've used it before and therefore the (re)learning curve
isn't as steep.  (Although I used it for about two weeks many months ago, my
old Perl scripts again look a bit like line noise to me.)
David A. Olson
Transportation Simulation and Systems Department
ITT Industries, Inc., Systems Division
address@hidden
(719) 637-6368
(719) 637-5880 fax


> -----Original Message-----
> From: Wayne Green [mailto:address@hidden
> Sent: Tuesday, November 27, 2001 8:58 AM
> To: Olson, Dave -Systems
> Subject: RE: is Bison the correct tool to use?
> 
> 
> Flex might be the only tool that you need. In my grammars, I use
> a scanner to detect a LITERAL that matches 
> 
> [A-Za-z_]+[A-Za-z0-9_]*      { return GetKeyWord(yytext); }
> 
> GetKeyWord looks like...
> int GetKeyWord(char *str)
> {
>   static string teststr;
>      teststr = str;   // Copy it over and get ready to compare.
>        const_iterator_type itor;        // one thingy per key anyway.
>        itor = find(ref);                // Gets close 
> (especially for mulimap).
>        for(; itor != end(); ++itor)
>        {
>           candidate = (*itor).first;  // Grab the key. 
> (*itor) is a pair<>
>           if(candidate == ref)        // usually the case first time.
>           {
>              return((*itor).second);    // return the pointer.
>           }
>        }
>        return some_flag_key_that_says_not_found;  // #define 
> LITERAL in my case.
> }
> 
> My GetKeyWord is based on a more complicated struture that let's me
> build lots of keyword tables, for different grammar contexts, 
> but the above
> code is a pretty decent paraphrase.
> 
> GetKeyWord uses a std::map<string,int> where the yytext is converted
> to a string and a comparison is made. Since std::map<> is based
> on a tree like lookup, a few lines of code and you are done.
> 
> Compiled PERL is certainly a recommendation too. This buys you the
> regular expressions that you are looking for, and a handy way to
> test, provided that everything is on the same line. In source code,
> this is not always the case. PERL is easy to debug.
> 
> --Wayne
> 
> Wayne Green         InfoSavvy, LLC
> address@hidden 
> 
> > -----Original Message-----
> > From: address@hidden [mailto:address@hidden
> > Behalf Of Olson, Dave -Systems
> > Sent: Monday, November 26, 2001 6:28 PM
> > To: address@hidden
> > Subject: is Bison the correct tool to use?
> > 
> > 
> > I'm looking for a way to scan lots of C++ code for certain 
> method names and
> > then detect whether one of a list of identifiers is used by 
> that method.  I
> > began delving into Bison to see if I can write a simple 
> grammer/script to do
> > that, but I woud appreciate an experienced opinion.  Can I 
> extract the
> > entire method body as one compound-statement and pass it to 
> my own C code?
> > Is Bison the right tool to use to do this?
> > sincerely,
> > David A. Olson
> > Transportation Simulation and Systems Department
> > ITT Industries, Inc., Systems Division
> > Dave.Olson AT ITT.com
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Help-bison mailing list
> > address@hidden
> > http://mail.gnu.org/mailman/listinfo/help-bison
> > 
> 

************************************ 
If this email is not intended for you, or you are not responsible for the
delivery of this message to the addressee, please note that this message may
contain ITT Privileged/Proprietary Information.  In such a case, you may not
copy or deliver this message to anyone.  You should destroy this message and
kindly notify the sender by reply email.  Information contained in this
message that does not relate to the business of ITT is neither endorsed by
nor attributable to ITT. 
************************************ 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]